From: Kurt Zeilenga Date: Tue, 23 Jul 2002 18:31:42 +0000 (+0000) Subject: snprintf cleanup X-Git-Tag: NO_SLAP_OP_BLOCKS~1350 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f5e209138b64a36634dd0ba40d603f3e92cf4948;p=openldap snprintf cleanup --- diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index 1ab31acdaa..471e20a07a 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -167,10 +167,8 @@ urlize(char *url) { char *p; - if (*LDAP_DIRSEP != '/') - { - for (p = url; *p; p++) - { + if (*LDAP_DIRSEP != '/') { + for (p = url; *p; p++) { if (*p == *LDAP_DIRSEP) *p = '/'; } @@ -1193,7 +1191,8 @@ print_entry( { int tmpfd; /* write value to file */ - sprintf( tmpfname, "%s" LDAP_DIRSEP "ldapsearch-%s-XXXXXX", + snprintf( tmpfname, sizeof tmpfname, + "%s" LDAP_DIRSEP "ldapsearch-%s-XXXXXX", tmpdir, a ); tmpfp = NULL; @@ -1219,7 +1218,7 @@ print_entry( fclose( tmpfp ); - sprintf( url, "%s%s", urlpre, + snprintf( url, sizeof url, "%s%s", urlpre, &tmpfname[strlen(tmpdir) + sizeof(LDAP_DIRSEP) - 1] ); urlize( url ); diff --git a/tests/progs/slapd-tester.c b/tests/progs/slapd-tester.c index 52c3f71f04..65a9a25083 100644 --- a/tests/progs/slapd-tester.c +++ b/tests/progs/slapd-tester.c @@ -181,7 +181,8 @@ main( int argc, char **argv ) */ sanum = 0; - sprintf( scmd, "%s%s%s", progdir, LDAP_DIRSEP, SEARCHCMD ); + snprintf( scmd, sizeof scmd, "%s" LDAP_DIRSEP SEARCHCMD, + progdir ); sargs[sanum++] = scmd; sargs[sanum++] = "-h"; sargs[sanum++] = host; @@ -200,7 +201,8 @@ main( int argc, char **argv ) */ ranum = 0; - sprintf( rcmd, "%s%s%s", progdir, LDAP_DIRSEP, READCMD ); + snprintf( rcmd, sizeof rcmd, "%s" LDAP_DIRSEP READCMD, + progdir ); rargs[ranum++] = rcmd; rargs[ranum++] = "-h"; rargs[ranum++] = host; @@ -217,7 +219,8 @@ main( int argc, char **argv ) */ aanum = 0; - sprintf( acmd, "%s%s%s", progdir, LDAP_DIRSEP, ADDCMD ); + snprintf( acmd, sizeof acmd, "%s" LDAP_DIRSEP ADDCMD, + progdir ); aargs[aanum++] = acmd; aargs[aanum++] = "-h"; aargs[aanum++] = host; @@ -268,7 +271,8 @@ get_file_name( char *dirname, char *filename ) { char buf[MAXPATHLEN]; - sprintf( buf, "%s%s%s", dirname, LDAP_DIRSEP, filename ); + snprintf( buf, sizeof buf, "%s" LDAP_DIRSEP "%s", + dirname, filename ); return( strdup( buf )); }