changeset 13410:16832af22909

1224 lp may overwrite constant data Reviewed by: Gordon Ross <gwr@nexenta.com> Reviewed by: Albert Lee <trisk@nexenta.com> Approved by: Garret D'Amore <garrett@nexenta.com>
author Richard Lowe <richlowe@richlowe.net>
date Mon, 27 Jun 2011 18:29:43 +0100
parents a4e1558c0599
children 814f11fdc297
files usr/src/cmd/lp/cmd/lpadmin/options.c usr/src/cmd/lp/cmd/lpfilter.c usr/src/cmd/lp/cmd/lpforms.c usr/src/cmd/lp/cmd/lpusers.c usr/src/cmd/lp/lib/lp/isterminfo.c usr/src/cmd/lp/lib/lp/tidbit.c
diffstat 6 files changed, 28 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/lp/cmd/lpadmin/options.c	Fri Jul 22 09:27:57 2011 -0700
+++ b/usr/src/cmd/lp/cmd/lpadmin/options.c	Mon Jun 27 18:29:43 2011 +0100
@@ -27,8 +27,6 @@
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include "ctype.h"
 #include "stdio.h"
 #include "string.h"
@@ -155,7 +153,7 @@
 	char		*cp,
 			*rest,
 			**av;
-	char stroptsw[3] = "-X";
+	char		stroptsw[] = "-X";
 
 #if	defined(__STDC__)
 	typedef char * const *	stupid;	/* dumb-ass ANSI C */
@@ -259,14 +257,12 @@
 			 */
 			if (!*optarg) {
 				stroptsw[1] = optsw;
-				cp = stroptsw;
-				LP_ERRMSG1 (ERROR, E_LP_NULLARG, cp);
+				LP_ERRMSG1 (ERROR, E_LP_NULLARG, stroptsw);
 				done (1);
 			}
 			if (*optarg == '-') {
 				stroptsw[1] = optsw;
-				cp = stroptsw;
-				LP_ERRMSG1 (ERROR, E_LP_OPTARG, cp);
+				LP_ERRMSG1 (ERROR, E_LP_OPTARG, stroptsw);
 				done (1);
 			}
 			if (optsw == 'A')
@@ -278,8 +274,7 @@
 			 */
 			if (*optarg == '-') {
 				stroptsw[1] = optsw;
-				cp = stroptsw;
-				LP_ERRMSG1 (ERROR, E_LP_OPTARG, cp);
+				LP_ERRMSG1 (ERROR, E_LP_OPTARG, stroptsw);
 				done (1);
 			}
 			break;
@@ -574,12 +569,13 @@
 
 			} else {
 				stroptsw[1] = optsw;
-				cp = stroptsw;
 
 				if (strchr(OPT_LIST, optopt))
-					LP_ERRMSG1 (ERROR, E_LP_OPTARG, cp);
+					LP_ERRMSG1 (ERROR, E_LP_OPTARG,
+					    stroptsw);
 				else
-					LP_ERRMSG1 (ERROR, E_LP_OPTION, cp);
+					LP_ERRMSG1 (ERROR, E_LP_OPTION,
+					    stroptsw);
 				done (1);
 			}
 		}
--- a/usr/src/cmd/lp/cmd/lpfilter.c	Fri Jul 22 09:27:57 2011 -0700
+++ b/usr/src/cmd/lp/cmd/lpfilter.c	Mon Jun 27 18:29:43 2011 +0100
@@ -27,9 +27,6 @@
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
@@ -145,6 +142,7 @@
 
 	char			*filter,
 				*p;
+	char			stroptsw[] = "-X";
 
 
 	(void) setlocale (LC_ALL, "");
@@ -220,11 +218,11 @@
 			usage ();
 			exit (0);
 		}
-		(p = "-X")[1] = optopt;
+		stroptsw[1] = optopt;
 		if (strchr(OPT_LIST, optopt))
-			LP_ERRMSG1 (ERROR, E_LP_OPTARG, p);
+			LP_ERRMSG1 (ERROR, E_LP_OPTARG, stroptsw);
 		else
-			LP_ERRMSG1 (ERROR, E_LP_OPTION, p);
+			LP_ERRMSG1 (ERROR, E_LP_OPTION, stroptsw);
 		exit (1);
 
 	}
--- a/usr/src/cmd/lp/cmd/lpforms.c	Fri Jul 22 09:27:57 2011 -0700
+++ b/usr/src/cmd/lp/cmd/lpforms.c	Mon Jun 27 18:29:43 2011 +0100
@@ -27,8 +27,6 @@
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <locale.h>
 #include "stdio.h"
 #include "errno.h"
@@ -152,6 +150,7 @@
 	char *			u		= 0;
 	char *			cp;
 	char *			rest;
+	char			stroptsw[]	= "-X";
 
 	Action			action		= 0;
 
@@ -203,13 +202,13 @@
 		case 'A':
 		case 'u':
 			if (!*optarg) {
-				(cp = "-X")[1] = c;
-				LP_ERRMSG1 (ERROR, E_LP_NULLARG, cp);
+				stroptsw[1] = c;
+				LP_ERRMSG1 (ERROR, E_LP_NULLARG, stroptsw);
 				exit (1);
 			}
 			if (*optarg == '-') {
-				(cp = "-X")[1] = c;
-				LP_ERRMSG1 (ERROR, E_LP_OPTARG, cp);
+				stroptsw[1] = c;
+				LP_ERRMSG1 (ERROR, E_LP_OPTARG, stroptsw);
 				exit (1);
 			}
 			break;
@@ -332,11 +331,11 @@
 				usage ();
 				exit (0);
 			}
-			(cp = "-X")[1] = optopt;
+			stroptsw[1] = optopt;
 			if (strchr(OPT_LIST, optopt))
-				LP_ERRMSG1 (ERROR, E_LP_OPTARG, cp);
+				LP_ERRMSG1 (ERROR, E_LP_OPTARG, stroptsw);
 			else
-				LP_ERRMSG1 (ERROR, E_LP_OPTION, cp);
+				LP_ERRMSG1 (ERROR, E_LP_OPTION, stroptsw);
 			exit (1);
 
 		}
--- a/usr/src/cmd/lp/cmd/lpusers.c	Fri Jul 22 09:27:57 2011 -0700
+++ b/usr/src/cmd/lp/cmd/lpusers.c	Mon Jun 27 18:29:43 2011 +0100
@@ -27,8 +27,6 @@
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /* lpusers [-q priority-level] -u (user-list | "")
    lpusers -d priority-level
    lpusers -l
@@ -60,6 +58,7 @@
 	list = FALSE, limit = -1, deflt = -1;
     int fd;
     char *userlist = 0, *user, **users, *p;
+    char stroptsw[] = "-X";
     short status;
     struct user_priority *ppri_tbl, *ld_priority_file();
     extern char *optarg;
@@ -127,12 +126,13 @@
 	    userlist = optarg;
 	    break;
 	case '?':
-	    if (optopt == '?') goto usage;
-	    (p = "-X")[1] = optopt;
+	    if (optopt == '?')
+		    goto usage;
+	    stroptsw[1] = optopt;
 	    if (strchr("ldqu", optopt))
-		LP_ERRMSG1(ERROR, E_LP_OPTARG, p);
+		LP_ERRMSG1(ERROR, E_LP_OPTARG, stroptsw);
 	    else
-		LP_ERRMSG1(ERROR, E_LP_OPTION, p);
+		LP_ERRMSG1(ERROR, E_LP_OPTION, stroptsw);
 	    exit(1);
 	}
 
--- a/usr/src/cmd/lp/lib/lp/isterminfo.c	Fri Jul 22 09:27:57 2011 -0700
+++ b/usr/src/cmd/lp/lib/lp/isterminfo.c	Mon Jun 27 18:29:43 2011 +0100
@@ -22,10 +22,6 @@
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
-
-#ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.9	*/
-/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
-
 #include "fcntl.h"
 #include "errno.h"
 #include "string.h"
@@ -180,7 +176,7 @@
 #endif
 {
 	char			*path,
-				*type_letter	= "X";
+				type_letter[]	= "X";
 
 	int			ret;
 
--- a/usr/src/cmd/lp/lib/lp/tidbit.c	Fri Jul 22 09:27:57 2011 -0700
+++ b/usr/src/cmd/lp/lib/lp/tidbit.c	Mon Jun 27 18:29:43 2011 +0100
@@ -26,9 +26,6 @@
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.12	*/
-
 #include "errno.h"
 #include "string.h"
 #include "sys/types.h"
@@ -441,7 +438,7 @@
 				*term;
 #endif
 {
-	char			*first_letter	= "X",
+	char			first_letter[]	= "X",
 				*path;
 
 	int			fd;