This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

sprintf bug on Linux




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]$


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]