Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/rpc.pcnfsd Add a statuslen argument to get_pr_statu...



details:   https://anonhg.NetBSD.org/src/rev/63121d400397
branches:  trunk
changeset: 794959:63121d400397
user:      apb <apb%NetBSD.org@localhost>
date:      Sat Mar 29 18:54:36 2014 +0000

description:
Add a statuslen argument to get_pr_status(), and use it
as the length in a call to strlcpy().  The previous code would
have used the size of a pointer as the length.

diffstat:

 usr.sbin/rpc.pcnfsd/extern.h       |   4 ++--
 usr.sbin/rpc.pcnfsd/pcnfsd_print.c |  14 ++++++++------
 usr.sbin/rpc.pcnfsd/pcnfsd_v2.c    |   4 ++--
 3 files changed, 12 insertions(+), 10 deletions(-)

diffs (99 lines):

diff -r 78bb968f0835 -r 63121d400397 usr.sbin/rpc.pcnfsd/extern.h
--- a/usr.sbin/rpc.pcnfsd/extern.h      Sat Mar 29 18:23:00 2014 +0000
+++ b/usr.sbin/rpc.pcnfsd/extern.h      Sat Mar 29 18:54:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.2 2009/04/18 13:02:36 lukem Exp $ */
+/*     $NetBSD: extern.h,v 1.3 2014/03/29 18:54:36 apb Exp $   */
 
 extern int             interrupted;
 extern pr_list         printers;
@@ -19,7 +19,7 @@
 void           free_pr_queue_item __P((pr_queue));
 struct passwd  *get_password __P((char *));
 pirstat                get_pr_status __P((printername, bool_t *, bool_t *, int *,
-                   bool_t *, char *));
+                   bool_t *, char *, size_t));
 void          *grab __P((int));
 pcrstat                pr_cancel __P((char *, char *, char *));
 pirstat                pr_init __P((char *, char *, char **));
diff -r 78bb968f0835 -r 63121d400397 usr.sbin/rpc.pcnfsd/pcnfsd_print.c
--- a/usr.sbin/rpc.pcnfsd/pcnfsd_print.c        Sat Mar 29 18:23:00 2014 +0000
+++ b/usr.sbin/rpc.pcnfsd/pcnfsd_print.c        Sat Mar 29 18:54:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcnfsd_print.c,v 1.12 2011/08/16 14:29:16 mbalmer Exp $        */
+/*     $NetBSD: pcnfsd_print.c,v 1.13 2014/03/29 18:54:36 apb Exp $    */
 
 /* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_print.c 1.7 92/01/24 19:58:58 SMI */
 /*
@@ -904,13 +904,14 @@
 */
 
 pirstat
-get_pr_status(pn, avail, printing, qlen, needs_operator, status)
+get_pr_status(pn, avail, printing, qlen, needs_operator, status, statuslen)
        printername pn;
        bool_t *avail;
        bool_t *printing;
        int    *qlen;
        bool_t *needs_operator;
        char   *status;
+       size_t statuslen;
 {
        char    buff[256];
        char    cmd[64];
@@ -949,10 +950,10 @@
                        if (!strstr(buff, "disabled"))
                                *printing = TRUE;
                        if (strstr(buff, "printing"))
-                               strlcpy(status, "printing", sizeof(status));
+                               strlcpy(status, "printing", statuslen);
                        else
                                if (strstr(buff, "idle"))
-                                       strlcpy(status, "idle", sizeof(status));
+                                       strlcpy(status, "idle", statuslen);
                        continue;
                }
                if (!strncmp(buff, "UX:", 3)) {
@@ -968,13 +969,14 @@
  * BSD way: lpc status
  */
 pirstat
-get_pr_status(pn, avail, printing, qlen, needs_operator, status)
+get_pr_status(pn, avail, printing, qlen, needs_operator, status, statuslen)
        printername pn;
        bool_t *avail;
        bool_t *printing;
        int    *qlen;
        bool_t *needs_operator;
        char   *status;
+       size_t statuslen;
 {
        char    cmd[128];
        char    buff[256];
@@ -1058,7 +1060,7 @@
                            strstr(buff2, "error") != NULL)
                                *needs_operator = TRUE;
                        if (*needs_operator || strstr(buff2, "waiting") != NULL)
-                               strlcpy(status, cp, sizeof(status));
+                               strlcpy(status, cp, statuslen);
                }
                pstat = PI_RES_OK;
                break;
diff -r 78bb968f0835 -r 63121d400397 usr.sbin/rpc.pcnfsd/pcnfsd_v2.c
--- a/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c   Sat Mar 29 18:23:00 2014 +0000
+++ b/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c   Sat Mar 29 18:54:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcnfsd_v2.c,v 1.12 2011/10/07 10:46:29 joerg Exp $     */
+/*     $NetBSD: pcnfsd_v2.c,v 1.13 2014/03/29 18:54:36 apb Exp $       */
 
 /* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_v2.c 1.2 91/12/18 13:26:13 SMI */
 /*
@@ -238,7 +238,7 @@
        static char status[128];
 
        res.stat = get_pr_status(arg->pn, &res.avail, &res.printing,
-           &res.qlen, &res.needs_operator, &status[0]);
+           &res.qlen, &res.needs_operator, &status[0], sizeof(status));
        res.status = &status[0];
        res.cm = &no_comment[0];
 



Home | Main Index | Thread Index | Old Index