This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
sprintf bug on Linux
- To: <gcc-bugs at gcc dot gnu dot org>
- Subject: sprintf bug on Linux
- From: "Brian Keefe" <bkeefe at sportbrain dot com>
- Date: Fri, 28 Apr 2000 09:55:09 -0700
If I use
char b[2]
below rather than
char b[3],
the value of len is set to zero.
This does not happen on Solaris with gcc, nor on NT with MSVC.
I apologize for not following protocol for bug reporting, but after spending
10 minutes trying to figure it all out, it was either forget it or email
this.
-- Brian Keefe
sauth.c
void sb_MakeAuthenticationLogin(sb_EncryptionData* d)
{
int ix = 0;
int len = sizeof(d->FullSN);
for(ix = 0;ix < len;ix++)
{
char b[3]; // Linux gcc bug. On Solaris with gcc, 2 is ok. 2 is ok on
MSVC.
sprintf(b,"%02x",d->FullSN[len-ix-1]);
d->UserName[2*ix]=b[0];
d->UserName[2*ix+1]=b[1];
}
d->UserName[2*len]='\0';
}
[radius@blackberry cauth]$ uname -a
Linux blackberry.sportbrain 2.2.13-0.7smp #1 SMP Tue Nov 23 08:48:02 PST
1999 i6
86 unknown
[radius@blackberry cauth]$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
[radius@blackberry cauth]$