From ab8fc6018c840995578683e91fe2742b46f01f43 Mon Sep 17 00:00:00 2001 From: Joshua Kwan Date: Sun, 4 Jan 2004 01:05:22 +0000 Subject: [PATCH] use strlcpy git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@61 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- Makefile | 2 +- dgamelaunch.c | 6 +++--- dgamelaunch.h | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6aa8279..cc906a7 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ CC = gcc LDFLAGS = CFLAGS = -g3 $(optimize) -Wall $(DEFS) DEFS = -DVERSION=\"$(VERSION)\" -SRCS = virus.c ttyrec.c dgamelaunch.c io.c ttyplay.c stripgfx.c +SRCS = virus.c ttyrec.c dgamelaunch.c io.c ttyplay.c stripgfx.c strlcpy.c OBJS = $(SRCS:.c=.o) LIBS = -lncurses -lcrypt -lutil diff --git a/dgamelaunch.c b/dgamelaunch.c index 10b6379..2e6459c 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -314,14 +314,14 @@ populate_games (int *l) *replacestr = '\0'; games[len]->name = malloc (strlen (pdirent->d_name) + 1); - strncpy (games[len]->name, pdirent->d_name, + strlcpy (games[len]->name, pdirent->d_name, strlen (pdirent->d_name) + 1); games[len]->date = malloc (11); - strncpy (games[len]->date, replacestr + 1, 10); + strlcpy (games[len]->date, replacestr + 1, 11); games[len]->time = malloc (9); - strncpy (games[len]->time, replacestr + 12, 8); + strlcpy (games[len]->time, replacestr + 12, 9); games[len]->idle_time = pstat.st_mtime; diff --git a/dgamelaunch.h b/dgamelaunch.h index 25349f6..909c02d 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -71,4 +71,7 @@ extern void write_canned_rcfile (char *target); extern void editoptions (void); extern void writefile (int requirenew); +/* strlcpy.c */ +extern size_t strlcpy(char *dst, const char *src, size_t siz); + #endif