summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--games/hack/hack.end.c10
-rw-r--r--games/hack/hack.main.c23
-rw-r--r--games/hack/hack.options.c7
-rw-r--r--games/hack/hack.shk.c7
-rw-r--r--games/hack/hack.shknam.c7
-rw-r--r--games/hack/hack.u_init.c7
6 files changed, 24 insertions, 37 deletions
diff --git a/games/hack/hack.end.c b/games/hack/hack.end.c
index 36e3feec3eb..542b9d5084f 100644
--- a/games/hack/hack.end.c
+++ b/games/hack/hack.end.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hack.end.c,v 1.8 2003/05/19 06:30:56 pjanzen Exp $ */
+/* $OpenBSD: hack.end.c,v 1.9 2003/07/06 02:07:45 avsm Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -62,7 +62,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: hack.end.c,v 1.8 2003/05/19 06:30:56 pjanzen Exp $";
+static const char rcsid[] = "$OpenBSD: hack.end.c,v 1.9 2003/07/06 02:07:45 avsm Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -340,10 +340,8 @@ topten()
t0->plchar = pl_character[0];
t0->sex = (flags.female ? 'F' : 'M');
t0->uid = uid;
- (void) strncpy(t0->name, plname, NAMSZ);
- (t0->name)[NAMSZ] = 0;
- (void) strncpy(t0->death, killer, DTHSZ);
- (t0->death)[DTHSZ] = 0;
+ (void) strlcpy(t0->name, plname, sizeof t0->name);
+ (void) strlcpy(t0->death, killer, sizeof t0->death);
(void) strlcpy(t0->date, getdate(), sizeof t0->date);
/* assure minimum number of points */
diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c
index 2f44c8051e7..d240035272e 100644
--- a/games/hack/hack.main.c
+++ b/games/hack/hack.main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hack.main.c,v 1.12 2003/05/19 06:30:56 pjanzen Exp $ */
+/* $OpenBSD: hack.main.c,v 1.13 2003/07/06 02:07:45 avsm Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -62,7 +62,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: hack.main.c,v 1.12 2003/05/19 06:30:56 pjanzen Exp $";
+static const char rcsid[] = "$OpenBSD: hack.main.c,v 1.13 2003/07/06 02:07:45 avsm Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -155,13 +155,11 @@ main(int argc, char **argv)
initoptions();
if(!*plname && (s = getenv("LOGNAME")))
- (void) strncpy(plname, s, sizeof(plname)-1);
+ (void) strlcpy(plname, s, sizeof(plname));
if(!*plname && (s = getenv("USER")))
- (void) strncpy(plname, s, sizeof(plname)-1);
+ (void) strlcpy(plname, s, sizeof(plname));
if(!*plname && (s = getlogin()))
- (void) strncpy(plname, s, sizeof(plname)-1);
- if(*plname)
- plname[sizeof(plname)-1] = '\0';
+ (void) strlcpy(plname, s, sizeof(plname));
}
/*
@@ -225,22 +223,17 @@ main(int argc, char **argv)
#endif
case 'u':
if(argv[0][2]) {
- (void) strncpy(plname, argv[0]+2, sizeof(plname)-1);
- plname[sizeof(plname)-1] = '\0';
+ (void) strlcpy(plname, argv[0]+2, sizeof(plname));
} else if(argc > 1) {
argc--;
argv++;
- (void) strncpy(plname, argv[0], sizeof(plname)-1);
- plname[sizeof(plname)-1] = '\0';
+ (void) strlcpy(plname, argv[0], sizeof(plname));
} else
printf("Player name expected after -u\n");
break;
default:
/* allow -T for Tourist, etc. */
- (void) strncpy(pl_character, argv[0]+1,
- sizeof(pl_character)-1);
- plname[sizeof(pl_character)-1] = '\0';
-
+ (void) strlcpy(pl_character, argv[0]+1, sizeof(pl_character));
/* printf("Unknown option: %s\n", *argv); */
}
}
diff --git a/games/hack/hack.options.c b/games/hack/hack.options.c
index c96bbcf59bf..df669911f49 100644
--- a/games/hack/hack.options.c
+++ b/games/hack/hack.options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hack.options.c,v 1.7 2003/05/19 06:30:56 pjanzen Exp $ */
+/* $OpenBSD: hack.options.c,v 1.8 2003/07/06 02:07:45 avsm Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -62,7 +62,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: hack.options.c,v 1.7 2003/05/19 06:30:56 pjanzen Exp $";
+static const char rcsid[] = "$OpenBSD: hack.options.c,v 1.8 2003/07/06 02:07:45 avsm Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -171,8 +171,7 @@ parseoptions(char *opts, boolean from_env)
}
op = strchr(opts,':');
if(!op) goto bad;
- (void) strncpy(plname, op+1, sizeof(plname)-1);
- plname[sizeof(plname)-1] = '\0';
+ (void) strlcpy(plname, op+1, sizeof(plname));
return;
}
diff --git a/games/hack/hack.shk.c b/games/hack/hack.shk.c
index 3de4e273245..eb72e05571a 100644
--- a/games/hack/hack.shk.c
+++ b/games/hack/hack.shk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hack.shk.c,v 1.9 2003/05/19 06:30:56 pjanzen Exp $ */
+/* $OpenBSD: hack.shk.c,v 1.10 2003/07/06 02:07:45 avsm Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -62,7 +62,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: hack.shk.c,v 1.9 2003/05/19 06:30:56 pjanzen Exp $";
+static const char rcsid[] = "$OpenBSD: hack.shk.c,v 1.10 2003/07/06 02:07:45 avsm Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -332,8 +332,7 @@ inshop()
/* He seems to be new here */
ESHK(shopkeeper)->visitct = 0;
ESHK(shopkeeper)->following = 0;
- (void) strncpy(ESHK(shopkeeper)->customer,plname,PL_NSIZ-1);
- ESHK(shopkeeper)->customer[PL_NSIZ-1] = '\0';
+ (void) strlcpy(ESHK(shopkeeper)->customer,plname,PL_NSIZ);
NOTANGRY(shopkeeper) = 1;
}
if(!ESHK(shopkeeper)->following) {
diff --git a/games/hack/hack.shknam.c b/games/hack/hack.shknam.c
index e792f601198..4a7aa133e73 100644
--- a/games/hack/hack.shknam.c
+++ b/games/hack/hack.shknam.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hack.shknam.c,v 1.6 2003/05/19 06:30:56 pjanzen Exp $ */
+/* $OpenBSD: hack.shknam.c,v 1.7 2003/07/06 02:07:45 avsm Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -62,7 +62,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: hack.shknam.c,v 1.6 2003/05/19 06:30:56 pjanzen Exp $";
+static const char rcsid[] = "$OpenBSD: hack.shknam.c,v 1.7 2003/07/06 02:07:45 avsm Exp $";
#endif /* not lint */
#include "hack.h"
@@ -200,8 +200,7 @@ findname(char *nampt, size_t len, char let)
/* Not enough names, try general name */
if(let) findname(nampt, len, 0);
else {
- (void) strncpy(nampt, "Dirk", len-1);
- nampt[len-1] = '\0';
+ (void) strlcpy(nampt, "Dirk", len);
}
return;
}
diff --git a/games/hack/hack.u_init.c b/games/hack/hack.u_init.c
index ddb617c9f0b..a1642e5eba4 100644
--- a/games/hack/hack.u_init.c
+++ b/games/hack/hack.u_init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hack.u_init.c,v 1.7 2003/05/19 06:30:56 pjanzen Exp $ */
+/* $OpenBSD: hack.u_init.c,v 1.8 2003/07/06 02:07:45 avsm Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -62,7 +62,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: hack.u_init.c,v 1.7 2003/05/19 06:30:56 pjanzen Exp $";
+static const char rcsid[] = "$OpenBSD: hack.u_init.c,v 1.8 2003/07/06 02:07:45 avsm Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -244,8 +244,7 @@ beginner:
got_suffix:
- (void) strncpy(pl_character, roles[i], PL_CSIZ-1);
- pl_character[PL_CSIZ-1] = 0;
+ (void) strlcpy(pl_character, roles[i], sizeof pl_character);
flags.beginner = 1;
u = zerou;
u.usym = '@';