Module Name:src
Committed By: snj
Date: Mon Jun 29 23:22:24 UTC 2009
Modified Files:
src/games/hack [netbsd-5-0]: extern.h hack.do_name.c hack.eat.c
hack.end.c hack.fight.c hack.invent.c hack.main.c hack.objnam.c
hack.options.c hack.pri.c hack.rip.c hack.shk.c hack.topl.c
hack.unix.c
Log Message:
Pull up following revision(s) (requested by dholland in ticket #844):
games/hack/extern.h: revision 1.11
games/hack/hack.pri.c: revision 1.11
games/hack/hack.do_name.c: revision 1.9
games/hack/hack.fight.c: revision 1.10
games/hack/hack.topl.c: revision 1.10
games/hack/hack.invent.c: revision 1.12
games/hack/hack.rip.c: revision 1.10
games/hack/hack.options.c: revision 1.9
games/hack/hack.main.c: revision 1.12
games/hack/hack.eat.c: revision 1.8
games/hack/hack.shk.c: revision 1.10
games/hack/hack.end.c: revision 1.12
games/hack/hack.objnam.c: revision 1.9
games/hack/hack.unix.c: revision 1.12
sprintf - snprintf, plus some use of strlcpy/strlcat where appropriate
XXX: there's still one sprintf left which will take some hacking to expunge.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.8.1 src/games/hack/extern.h
cvs rdiff -u -r1.7 -r1.7.14.1 src/games/hack/hack.do_name.c \
src/games/hack/hack.objnam.c
cvs rdiff -u -r1.6 -r1.6.42.1 src/games/hack/hack.eat.c
cvs rdiff -u -r1.9 -r1.9.14.1 src/games/hack/hack.end.c \
src/games/hack/hack.pri.c
cvs rdiff -u -r1.8 -r1.8.14.1 src/games/hack/hack.fight.c \
src/games/hack/hack.rip.c src/games/hack/hack.topl.c
cvs rdiff -u -r1.10 -r1.10.30.1 src/games/hack/hack.invent.c
cvs rdiff -u -r1.10 -r1.10.14.1 src/games/hack/hack.main.c
cvs rdiff -u -r1.7 -r1.7.42.1 src/games/hack/hack.options.c
cvs rdiff -u -r1.8 -r1.8.30.1 src/games/hack/hack.shk.c
cvs rdiff -u -r1.9 -r1.9.42.1 src/games/hack/hack.unix.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/hack/extern.h
diff -u src/games/hack/extern.h:1.8 src/games/hack/extern.h:1.8.8.1
--- src/games/hack/extern.h:1.8 Mon Apr 28 20:22:54 2008
+++ src/games/hack/extern.h Mon Jun 29 23:22:24 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.8 2008/04/28 20:22:54 martin Exp $ */
+/* $NetBSD: extern.h,v 1.8.8.1 2009/06/29 23:22:24 snj Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -356,7 +356,7 @@
char *typename(int);
char *xname(struct obj *);
char *doname(struct obj *);
-void setan(const char *, char *);
+void setan(const char *, char *, size_t);
char *aobjnam(struct obj *, const char *);
char *Doname(struct obj *);
struct obj *readobjnam(char *);
Index: src/games/hack/hack.do_name.c
diff -u src/games/hack/hack.do_name.c:1.7 src/games/hack/hack.do_name.c:1.7.14.1
--- src/games/hack/hack.do_name.c:1.7 Mon Jan 28 06:55:41 2008
+++ src/games/hack/hack.do_name.c Mon Jun 29 23:22:24 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.do_name.c,v 1.7 2008/01/28 06:55:41 dholland Exp $ */
+/* $NetBSD: hack.do_name.c,v 1.7.14.1 2009/06/29 23:22:24 snj Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include sys/cdefs.h
#ifndef lint
-__RCSID($NetBSD: hack.do_name.c,v 1.7 2008/01/28 06:55:41 dholland Exp $);
+__RCSID($NetBSD: hack.do_name.c,v 1.7.14.1 2009/06/29 23:22:24 snj Exp $);
#endif/* not lint */
#include stdlib.h
@@ -274,7 +274,7 @@
{
static char buf[BUFSZ]; /* %% */
if (mtmp-mnamelth !vb) {
- (void) strcpy(buf, NAME(mtmp));
+ (void) strlcpy(buf, NAME(mtmp), sizeof(buf));
return (buf);
}
switch (mtmp-data-mlet) {
@@ -287,23 +287,23 @@
(void)
strcpy((char *) mtmp-mextra, !rn2(5) ? plname : gn);
}
- (void) sprintf(buf, %s's ghost, gn);
+ (void) snprintf(buf, sizeof(buf), %s's ghost, gn);
}
break;
case '@':
if (mtmp-isshk) {
- (void) strcpy(buf, shkname(mtmp));
+ (void) strlcpy(buf, shkname(mtmp), sizeof(buf));
break;
}
/* fall into next case */
default:
- (void) sprintf(buf, the %s%s,
+ (void) snprintf(buf, sizeof(buf), the %s%s,
mtmp-minvis ? invisible : ,
mtmp-data-mname);
}
if (vb mtmp-mnamelth) {
- (void) strcat(buf, called );
- (void) strcat(buf, NAME(mtmp));
+ (void) strlcat(buf, called , sizeof(buf));
+ (void) strlcat(buf, NAME(mtmp), sizeof(buf));
}
return (buf);
}
@@ -342,7 +342,7 @@
if (!strncmp(bp, the , 4))
bp += 4;
- (void) sprintf(buf, the %s %s, adj, bp);
+ (void) snprintf(buf, sizeof(buf), the %s %s, adj, bp);
return (buf);
}
Index: src/games/hack/hack.objnam.c
diff -u src/games/hack/hack.objnam.c:1.7 src/games/hack/hack.objnam.c:1.7.14.1
--- src/games/hack/hack.objnam.c:1.7 Mon Jan 28 06:55:42 2008
+++ src/games/hack/hack.objnam.c Mon Jun 29 23:22:24 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.objnam.c,v 1.7 2008/01/28 06:55:42 dholland