]> git.sur5r.net Git - openldap/commitdiff
snprintf cleanup
authorKurt Zeilenga <kurt@openldap.org>
Tue, 23 Jul 2002 18:31:42 +0000 (18:31 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 23 Jul 2002 18:31:42 +0000 (18:31 +0000)
clients/tools/ldapsearch.c
tests/progs/slapd-tester.c

index 1ab31acdaa4a98c452ab7fa08dff267495c745a4..471e20a07a8092a7d9c6425ce8f5ac964078eaee 100644 (file)
@@ -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 );
index 52c3f71f045188b967b591edf61f211dfb1ecbff..65a9a250836b341c98092a7a94fdd4bfccbcf691 100644 (file)
@@ -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 ));
 }