|
From: Kevin's C. B. A. <kev...@pl...> - 2007-03-11 00:52:17
|
Update of /cvsroot/libteklti/libteklti/src In directory planetsaphire.com:/tmp/cvs-serv2630/src Modified Files: dbunixproc.c Log Message: FIX: Improper error checking of strtol()s. Index: dbunixproc.c =================================================================== RCS file: /cvsroot/libteklti/libteklti/src/dbunixproc.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C 2 -d -p -r1.4 -r1.5 *** dbunixproc.c 15 Feb 2007 11:08:48 -0000 1.4 --- dbunixproc.c 11 Mar 2007 00:59:28 -0000 1.5 *************** int teklti_retrieve_userdbline_results ( *** 107,113 **** --- 107,117 ---- ) { + char * errbuf; unsigned int i; unsigned int j; + /* Make sure errbuf is NULL. */ + errbuf = NULL; + /* First, get the username. */ uinfo->TekUserInfo_Username = char2uchar(line); *************** int teklti_retrieve_userdbline_results ( *** 140,146 **** /* Now, let's process the user id. */ ! uinfo->TekUserInfo_UserID = (uid_t)strtol(line, NULL, 0); ! if ( errno ) ! return 1; /* Let's find the next NULL. */ --- 144,151 ---- /* Now, let's process the user id. */ ! uinfo->TekUserInfo_UserID = (uid_t)strtol(line, &errbuf, 0); ! if ( errbuf != NULL ) ! if ( *errbuf != '\0' ) ! return 1; /* Let's find the next NULL. */ *************** int teklti_retrieve_userdbline_results ( *** 159,165 **** /* Now, let's process the group id. */ ! uinfo->TekUserInfo_GroupID = (gid_t)strtol(line, NULL, 0); ! if ( errno ) ! return 1; /* Let's find the next NULL. */ --- 164,171 ---- /* Now, let's process the group id. */ ! uinfo->TekUserInfo_GroupID = (gid_t)strtol(line, &errbuf, 0); ! if ( errbuf != NULL ) ! if ( *errbuf != '\0' ) ! return 1; /* Let's find the next NULL. */ *************** char * teklti_find_userdbline_username ( *** 304,314 **** char * teklti_find_userdbline_uid ( char * line, uid_t userid ) { char * tmp; unsigned int i; unsigned long j; ! /* Make sure j is reset. */ j = 0; i = 0; /* Let's compare the usernames. */ --- 310,322 ---- char * teklti_find_userdbline_uid ( char * line, uid_t userid ) { + char * errbuf; char * tmp; unsigned int i; unsigned long j; ! /* Make sure j, i, and errbuf are reset. */ j = 0; i = 0; + errbuf = NULL; /* Let's compare the usernames. */ *************** char * teklti_find_userdbline_uid ( char *** 323,330 **** { /* Convert the string to a unsigned long. */ ! j = strtoul(line, NULL, 0); /* Check to see if it's corrupt. */ ! /*if ( errno ) ! return (char *)-1;*/ /* Comare the userid. */ if ( j == (unsigned long)userid ) --- 331,339 ---- { /* Convert the string to a unsigned long. */ ! j = strtoul(line, &errbuf, 0); /* Check to see if it's corrupt. */ ! if ( errbuf != NULL ) ! if ( *errbuf != '\0' ) ! return NULL; /* Comare the userid. */ if ( j == (unsigned long)userid ) |