From e53214b26f0ea10ed00a1962fde62f04867118bb Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 27 Jul 2002 07:39:50 +0000 Subject: [PATCH] ITS#1965: use snprintf --- servers/slurpd/args.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/servers/slurpd/args.c b/servers/slurpd/args.c index 4262952524..76b3cb8b62 100644 --- a/servers/slurpd/args.c +++ b/servers/slurpd/args.c @@ -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); -- 2.39.5