termination of strings in solaris 9
Hi,
I have quite a bit of code that has been working for some time under solaris 8. When upgrading to Solaris 9 ( sparc) we ran into problem with
strings NOT terminated with NULL. Earlier it was possible to get the compiler to accept that and instead space-fill up to to the declared length. I have tried almost every flag in the c-compiler ( Studio 11) but not been lucky to get it OK. Hopefully someone has been more persistent than I ( or got more luck).
/Lars Wallin
[495 byte] By [
lasse50] at [2007-11-26 8:18:30]

# 2
Hi , the routine is quite small and are using a special library to handle the informix database. Part of the code is as follows:
1)
if( op == '1' )
cc = iod("C1,GF","si002",&si002buf,"*","F,loginid,EQ",&neclogin,"Q");
else
[b] cc = iod("C2,GF","si002",&si002buf,"*","F,loginid,EQ",&neclogin,"Q");
if ( cc != IODOK )
{
fprintf(err,"ERROR: Hittade inte Login: %s, cc = %d\n",login,cc);
cc = iod("EV,ET","*");
znsysdel();
printf("-1");
return( -1);
}
fill (pass,sizeof pass,NULL);
fill (necpass,sizeof necpass,NULL);
movst(argv[2],0,pass,0,v2l);
decryptSJ(pass, v2l);
movst(si002buf.pass,0,necpass,0,v2l);
zndecry(necpass, strlen(necpass));
fill(fillpass, sizeof fillpass,NULL);
movst(pass,0,fillpass,0,strlen(pass));
if( znstcp(necpass,fillpass,znlength(necpass, strlen(necpass))))
{
fprintf(err,"ERROR: L鰏enorden 鋜 fel.\n");
cc = iod("EV,ET","*");
znsysdel();
printf("-2");
return( -2);
}
fill(dbbeh,sizeof dbbeh,NULL);
movst(si002buf.sit004,0,dbbeh,0,8);
fprintf(err,"Test av NULL i -xc99=nOne -xchar=u & Xt: %s %d \n",si002buf.sit
004,strlen(si002buf.sit004));
movst(dbbeh,0,beh,0,8);
if(znstcp("sisujava",beh,8))
- --
2) The structure of the database record:
sisu@hagbard$ cat si002.sfi
struct SI002P/* autogenerated 2006-06-27 11:13:20 */
{
unsigned char loginid[12];
unsigned char sign[8];
unsigned char pass[10];
double datchgd;
int sit011;
int knr;
unsigned char sit012[1];
int sit001;
int sit002;
int sit003;
unsigned char sit004[8];
unsigned char sit005[8];
unsigned char sit006[8];
unsigned char sit007[8];
unsigned char sit008[8];
unsigned char sit009[8];
};
=====================================================
3) The result when running the routine:
sisu@hagbard$ cat AuthChk*
AuthChk.bin startad : 06-06-27 11:23:39
Parametrarna 鋜 (rgpq ),(rgpq ),(null) och (0)
L鋘gder: 4 4
znstart OK!
znappin sisu98 OK!
OP si002 OK!
Login innan konv: (rgpq)
Login efter konv: (sisu)
Test av NULL i -xc99=nOne -xchar=u & Xt: sisujavaALL
48
OK, Operation Successful!
======================================================
It looks as if "strlen" think that the string is 48 Chars, when it is only 8 chars when it's not terminated by NULL.
--
Hope this will give enough information. Otherwise pse come back for more.
Lasse50