Module Name: src Committed By: apb Date: Sat Mar 29 18:54:37 UTC 2014
Modified Files: src/usr.sbin/rpc.pcnfsd: extern.h pcnfsd_print.c pcnfsd_v2.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/rpc.pcnfsd/extern.h cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/rpc.pcnfsd/pcnfsd_print.c \ src/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/rpc.pcnfsd/extern.h diff -u src/usr.sbin/rpc.pcnfsd/extern.h:1.2 src/usr.sbin/rpc.pcnfsd/extern.h:1.3 --- src/usr.sbin/rpc.pcnfsd/extern.h:1.2 Sat Apr 18 13:02:36 2009 +++ src/usr.sbin/rpc.pcnfsd/extern.h Sat Mar 29 18:54:36 2014 @@ -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_list_item __P((pr_list)); 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 **)); Index: src/usr.sbin/rpc.pcnfsd/pcnfsd_print.c diff -u src/usr.sbin/rpc.pcnfsd/pcnfsd_print.c:1.12 src/usr.sbin/rpc.pcnfsd/pcnfsd_print.c:1.13 --- src/usr.sbin/rpc.pcnfsd/pcnfsd_print.c:1.12 Tue Aug 16 14:29:16 2011 +++ src/usr.sbin/rpc.pcnfsd/pcnfsd_print.c Sat Mar 29 18:54:36 2014 @@ -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 @@ free_pr_queue_item(curr) */ 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 @@ get_pr_status(pn, avail, printing, qlen, 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 @@ get_pr_status(pn, avail, printing, qlen, * 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 @@ get_pr_status(pn, avail, printing, qlen, 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; Index: src/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c diff -u src/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c:1.12 src/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c:1.13 --- src/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c:1.12 Fri Oct 7 10:46:29 2011 +++ src/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c Sat Mar 29 18:54:36 2014 @@ -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 @@ pcnfsd2_pr_status_2_svc(arg, req) 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];