I ran into a problem with getting bus errors when
trying to run sendmail with stock RedHat 6.0 on my
ss20 system at home. I was able to narrow down the
problem to the following line in 8.9.3's main.c code:
snprintf(ipbuf, sizeof ipbuf, "[%.100s]",
inet_ntoa(*((struct in_addr *) hp->h_addr_list[i])));
I posted a message in comp.mail.sendmail regarding
operation of snprintf and received feedback from Casper Dik
(Sun network security engineer) that pointed out
"You're casting a char* to a struct and then dereferencing it;
the system you're working on doesn't allow this and your
process dies with a bus error. This bit of code; of
h_addr_list[i] is not properly aligned, then it
cannot be dereferenced as if it is a struct in_addr."
Per Hedeland picked up on the message thread and suggested
the following patch that fixes the problem:
--- main.c.ORIG Sun Jan 10 00:31:13 1999
+++ main.c Sat Oct 30 04:29:25 1999
@@ -528,10 +528,12 @@
{
for (i = 0; hp->h_addr_list[i] != NULL; i++)
{
+ struct in_addr sin_addr;
char ipbuf[103];
+ bcopy(hp->h_addr_list[i], &sin_addr,
INADDRSZ);
snprintf(ipbuf, sizeof ipbuf,
"[%.100s]",
- inet_ntoa(*((struct in_addr *)
hp->h_addr_list[i])));
+ inet_ntoa(sin_addr));
if (tTd(0, 4))
printf("\ta.k.a.: %s\n", ipbuf);
setclass('w', ipbuf);
After posting that this patch worked, the following was then
stated by Per and confirmed by Casper: "I believe the Intel
architecture is more forgiving about alignment errors (at a
cost, of course) than the Sparc. Also whether this actually
becomes a misalignment depends on a number of factors, from the details
of declarations in the resolver library source to the policies of the
linker - as I wrote before, I'm somewhat surprised that it did for you.
It's still a bug, of course... - thanks to Casper for spotting it!"
Casper suggested that may be a bug with glibc library for sparc.
Could someone look into this and see if it is a problem that
should be fixed, if it hasn't already?
Thanks,
Bob
-
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of the message to [EMAIL PROTECTED]