From 66427701ea1ef06adfbd6f0b8b6143dd78d1a101 Mon Sep 17 00:00:00 2001 From: mycroft Date: Sun, 26 Jul 1998 15:23:39 +0000 Subject: [PATCH] const poisoning. --- usr.bin/lock/lock.c | 7 ++++--- usr.bin/su/su.c | 10 +++++----- usr.bin/tftp/tftp.c | 17 +++++++++-------- usr.bin/window/ww.h | 5 +++-- usr.bin/window/wwerror.c | 6 +++--- usr.sbin/bootp/common/report.c | 6 +++--- usr.sbin/bootp/common/report.h | 4 ++-- 7 files changed, 29 insertions(+), 26 deletions(-) diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c index e6a61651ff21..5b476daeba96 100644 --- a/usr.bin/lock/lock.c +++ b/usr.bin/lock/lock.c @@ -1,4 +1,4 @@ -/* $NetBSD: lock.c,v 1.13 1998/07/06 06:51:23 mrg Exp $ */ +/* $NetBSD: lock.c,v 1.14 1998/07/26 15:23:39 mycroft Exp $ */ /* * Copyright (c) 1980, 1987, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1987, 1993\n\ #if 0 static char sccsid[] = "@(#)lock.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: lock.c,v 1.13 1998/07/06 06:51:23 mrg Exp $"); +__RCSID("$NetBSD: lock.c,v 1.14 1998/07/26 15:23:39 mycroft Exp $"); #endif /* not lint */ /* @@ -102,7 +102,8 @@ main(argc, argv) struct tm *timp; time_t curtime; int ch, sectimeout, usemine; - char *ap, *mypw, *ttynam, *tzn; + char *ap, *mypw, *ttynam; + const char *tzn; char hostname[MAXHOSTNAMELEN + 1], s[BUFSIZ], s1[BUFSIZ]; if (!(pw = getpwuid(getuid()))) diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c index 5b64eda79ed1..87609a46b7b8 100644 --- a/usr.bin/su/su.c +++ b/usr.bin/su/su.c @@ -1,4 +1,4 @@ -/* $NetBSD: su.c,v 1.24 1998/07/06 11:44:49 mrg Exp $ */ +/* $NetBSD: su.c,v 1.25 1998/07/26 15:24:34 mycroft Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. @@ -44,7 +44,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)su.c 8.3 (Berkeley) 4/2/94";*/ #else -__RCSID("$NetBSD: su.c,v 1.24 1998/07/06 11:44:49 mrg Exp $"); +__RCSID("$NetBSD: su.c,v 1.25 1998/07/26 15:24:34 mycroft Exp $"); #endif #endif /* not lint */ @@ -88,7 +88,7 @@ static int koktologin __P((char *, char *, char *)); int main __P((int, char **)); -static int chshell __P((char *)); +static int chshell __P((const char *)); static char *ontty __P((void)); @@ -324,9 +324,9 @@ badlogin: static int chshell(sh) - char *sh; + const char *sh; { - char *cp; + const char *cp; while ((cp = getusershell()) != NULL) if (!strcmp(cp, sh)) diff --git a/usr.bin/tftp/tftp.c b/usr.bin/tftp/tftp.c index 51fa0ca7501b..91aa01105660 100644 --- a/usr.bin/tftp/tftp.c +++ b/usr.bin/tftp/tftp.c @@ -1,4 +1,4 @@ -/* $NetBSD: tftp.c,v 1.7 1997/10/20 00:46:38 lukem Exp $ */ +/* $NetBSD: tftp.c,v 1.8 1998/07/26 15:26:18 mycroft Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)tftp.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: tftp.c,v 1.7 1997/10/20 00:46:38 lukem Exp $"); +__RCSID("$NetBSD: tftp.c,v 1.8 1998/07/26 15:26:18 mycroft Exp $"); #endif #endif /* not lint */ @@ -326,9 +326,9 @@ makerequest(request, name, tp, mode) return (cp - (char *)tp); } -struct errmsg { +const struct errmsg { int e_code; - char *e_msg; + const char *e_msg; } errmsgs[] = { { EUNDEF, "Undefined error code" }, { ENOTFOUND, "File not found" }, @@ -351,21 +351,22 @@ static void nak(error) int error; { - struct errmsg *pe; + const struct errmsg *pe; struct tftphdr *tp; int length; tp = (struct tftphdr *)ackbuf; tp->th_opcode = htons((u_short)ERROR); - tp->th_code = htons((u_short)error); for (pe = errmsgs; pe->e_code >= 0; pe++) if (pe->e_code == error) break; if (pe->e_code < 0) { - pe->e_msg = strerror(error - 100); tp->th_code = EUNDEF; + strcpy(tp->th_msg, strerror(error - 100)); + } else { + tp->th_code = htons((u_short)error); + strcpy(tp->th_msg, pe->e_msg); } - strcpy(tp->th_msg, pe->e_msg); length = strlen(pe->e_msg) + 4; if (trace) tpacket("sent", tp, length); diff --git a/usr.bin/window/ww.h b/usr.bin/window/ww.h index 11b150d8af4f..2d5fb5d06ba3 100644 --- a/usr.bin/window/ww.h +++ b/usr.bin/window/ww.h @@ -1,4 +1,4 @@ -/* $NetBSD: ww.h,v 1.11 1997/12/31 06:55:16 thorpej Exp $ */ +/* $NetBSD: ww.h,v 1.12 1998/07/26 15:28:20 mycroft Exp $ */ /* * Copyright (c) 1983, 1993 @@ -338,7 +338,8 @@ void wwdumpsmap __P((void)); void wwdumpwin __P((struct ww *)); void wwend __P((int)); int wwenviron __P((struct ww *)); -char *wwerror __P((void)); +const char * + wwerror __P((void)); void wwflush __P((void)); void wwframe __P((struct ww *, struct ww *)); void wwframec __P((struct ww *, int, int, char)); diff --git a/usr.bin/window/wwerror.c b/usr.bin/window/wwerror.c index 2910c74d82ff..ed20f09e18fa 100644 --- a/usr.bin/window/wwerror.c +++ b/usr.bin/window/wwerror.c @@ -1,4 +1,4 @@ -/* $NetBSD: wwerror.c,v 1.4 1997/11/21 08:37:19 lukem Exp $ */ +/* $NetBSD: wwerror.c,v 1.5 1998/07/26 15:28:20 mycroft Exp $ */ /* * Copyright (c) 1983, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)wwerror.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: wwerror.c,v 1.4 1997/11/21 08:37:19 lukem Exp $"); +__RCSID("$NetBSD: wwerror.c,v 1.5 1998/07/26 15:28:20 mycroft Exp $"); #endif #endif /* not lint */ @@ -49,7 +49,7 @@ __RCSID("$NetBSD: wwerror.c,v 1.4 1997/11/21 08:37:19 lukem Exp $"); #include #include "ww.h" -char * +const char * wwerror() { switch (wwerrno) { diff --git a/usr.sbin/bootp/common/report.c b/usr.sbin/bootp/common/report.c index 102c60e53ae6..555448e5efb0 100644 --- a/usr.sbin/bootp/common/report.c +++ b/usr.sbin/bootp/common/report.c @@ -1,8 +1,8 @@ -/* $NetBSD: report.c,v 1.3 1998/03/14 04:39:55 lukem Exp $ */ +/* $NetBSD: report.c,v 1.4 1998/07/26 15:33:34 mycroft Exp $ */ #include #ifndef lint -__RCSID("$NetBSD: report.c,v 1.3 1998/03/14 04:39:55 lukem Exp $"); +__RCSID("$NetBSD: report.c,v 1.4 1998/07/26 15:33:34 mycroft Exp $"); #endif /* @@ -140,7 +140,7 @@ report(priority, fmt, va_alist) /* * Return pointer to static string which gives full filesystem error message. */ -char * +const char * get_errmsg() { extern int errno; diff --git a/usr.sbin/bootp/common/report.h b/usr.sbin/bootp/common/report.h index c9011f2d0db4..4b15da80d258 100644 --- a/usr.sbin/bootp/common/report.h +++ b/usr.sbin/bootp/common/report.h @@ -1,4 +1,4 @@ -/* $NetBSD: report.h,v 1.2 1998/01/09 08:09:15 perry Exp $ */ +/* $NetBSD: report.h,v 1.3 1998/07/26 15:33:34 mycroft Exp $ */ /* report.h */ @@ -10,6 +10,6 @@ extern void report_init P((int nolog)); extern void report P((int, char *, ...)); -extern char *get_errmsg P((void)); +extern const char *get_errmsg P((void)); #undef P