]> git.sur5r.net Git - openldap/commitdiff
ITS#1965: use snprintf
authorKurt Zeilenga <kurt@openldap.org>
Sat, 27 Jul 2002 07:39:50 +0000 (07:39 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 27 Jul 2002 07:39:50 +0000 (07:39 +0000)
servers/slurpd/args.c

index 42629525241d2da007d2b8c62565f58050362deb..76b3cb8b6272a44a5c0d524c3a76a2a07e5c7acd 100644 (file)
@@ -113,15 +113,16 @@ doargs(
            g->one_shot_mode = 1;
            break;
        case 'r':       /* slapd replog file */
-           strncpy( g->slapd_replogfile, optarg,
-                       sizeof(g->slapd_replogfile)-1 );
-               g->slapd_replogfile[sizeof(g->slapd_replogfile)-1] = '\0';
+               snprintf( g->slapd_replogfile, sizeof g->slapd_replogfile,
+                       "%s", optarg );
            rflag++;
            break;
-       case 't':       /* dir to use for our copies of replogs */
-           g->slurpd_rdir = (char *)malloc (strlen(optarg) + sizeof("/replica"));
-           sprintf(g->slurpd_rdir, "%s" LDAP_DIRSEP "replica", optarg);
-           break;
+       case 't': {     /* dir to use for our copies of replogs */
+               size_t sz;
+           g->slurpd_rdir = (char *)malloc (sz = (strlen(optarg) + sizeof("/replica")));
+           snprintf(g->slurpd_rdir, sz,
+                       "%s" LDAP_DIRSEP "replica", optarg);
+           } break;
        default:
            usage( g->myname );
            return( -1 );
@@ -135,11 +136,13 @@ doargs(
     }
 
     /* Set location/name of our private copy of the slapd replog file */
-    sprintf( g->slurpd_replogfile, "%s" LDAP_DIRSEP "%s", g->slurpd_rdir,
+    snprintf( g->slurpd_replogfile, sizeof g->slurpd_replogfile,
+               "%s" LDAP_DIRSEP "%s", g->slurpd_rdir,
            DEFAULT_SLURPD_REPLOGFILE );
 
     /* Set location/name of the slurpd status file */
-    sprintf( g->slurpd_status_file, "%s" LDAP_DIRSEP "%s", g->slurpd_rdir,
+    snprintf( g->slurpd_status_file, sizeof g->slurpd_status_file,
+               "%s" LDAP_DIRSEP "%s", g->slurpd_rdir,
            DEFAULT_SLURPD_STATUS_FILE );
 
        ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &ldap_debug);