Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/ypserv use bounded string ops (one strcpy remaining)



details:   https://anonhg.NetBSD.org/src/rev/bb6581fcfa30
branches:  trunk
changeset: 549402:bb6581fcfa30
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Jul 14 05:55:38 2003 +0000

description:
use bounded string ops (one strcpy remaining)

diffstat:

 usr.sbin/ypserv/mkalias/mkalias.c            |   6 +++---
 usr.sbin/ypserv/revnetgroup/parse_netgroup.c |  13 +++++--------
 2 files changed, 8 insertions(+), 11 deletions(-)

diffs (68 lines):

diff -r 4475e1c33d58 -r bb6581fcfa30 usr.sbin/ypserv/mkalias/mkalias.c
--- a/usr.sbin/ypserv/mkalias/mkalias.c Mon Jul 14 05:21:25 2003 +0000
+++ b/usr.sbin/ypserv/mkalias/mkalias.c Mon Jul 14 05:55:38 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkalias.c,v 1.10 2002/07/06 21:31:55 wiz Exp $ */
+/*     $NetBSD: mkalias.c,v 1.11 2003/07/14 05:55:38 itojun Exp $ */
 
 /*
  * Copyright (c) 1997 Mats O Jansson <moj%stacken.kth.se@localhost>
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mkalias.c,v 1.10 2002/07/06 21:31:55 wiz Exp $");
+__RCSID("$NetBSD: mkalias.c,v 1.11 2003/07/14 05:55:38 itojun Exp $");
 #endif
 
 #include <sys/types.h>
@@ -303,7 +303,7 @@
        }
 
        if (new_db != NULL) {
-               sprintf(datestr, "%010d", (int)time(NULL));
+               snprintf(datestr, sizeof(datestr), "%010d", (int)time(NULL));
                key.dptr = YP_LAST_KEY;
                key.dsize = strlen(YP_LAST_KEY);
                val.dptr = datestr;
diff -r 4475e1c33d58 -r bb6581fcfa30 usr.sbin/ypserv/revnetgroup/parse_netgroup.c
--- a/usr.sbin/ypserv/revnetgroup/parse_netgroup.c      Mon Jul 14 05:21:25 2003 +0000
+++ b/usr.sbin/ypserv/revnetgroup/parse_netgroup.c      Mon Jul 14 05:55:38 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse_netgroup.c,v 1.4 2003/01/28 22:35:24 wiz Exp $ */
+/*     $NetBSD: parse_netgroup.c,v 1.5 2003/07/14 05:55:39 itojun Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: parse_netgroup.c,v 1.4 2003/01/28 22:35:24 wiz Exp $");
+__RCSID("$NetBSD: parse_netgroup.c,v 1.5 2003/07/14 05:55:39 itojun Exp $");
 #endif
 
 /*
@@ -115,11 +115,8 @@
                rng_endnetgrent();
                if (parse_netgrp(group))
                        rng_endnetgrent();
-               else {
-                       grouphead.grname = (char *)
-                               malloc(strlen(group) + 1);
-                       strcpy(grouphead.grname, group);
-               }
+               else
+                       grouphead.grname = strdup(group);
        }
        nextgrp = grouphead.gr;
 }
@@ -305,7 +302,7 @@
        char *data = NULL;
 
        data = lookup (gtable, group);
-       sprintf(line, "%s %s", group, data);
+       snprintf(line, sizeof(line), "%s %s", group, data);
        pos = (char *)&line;
 #ifdef CANT_HAPPEN
        if (*pos == '#')



Home | Main Index | Thread Index | Old Index