1- /* $NetBSD: main.c,v 1.16 2006/03/18 23:38:12 christos Exp $ */
1+ /* $NetBSD: main.c,v 1.17 2006/06/07 09:35:03 jnemeth Exp $ */
22
33/*-
44 * Copyright (c) 1990, 1993
@@ -51,7 +51,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993\n\
5151#if 0
5252static char sccsid [] = "@(#)main.c 8.1 (Berkeley) 5/31/93" ;
5353#else
54- __RCSID ("$NetBSD: main.c,v 1.16 2006/03/18 23:38:12 christos Exp $" );
54+ __RCSID ("$NetBSD: main.c,v 1.17 2006/06/07 09:35:03 jnemeth Exp $" );
5555#endif
5656#endif /* not lint */
5757
@@ -79,7 +79,7 @@ main(int argc, char *argv[])
7979
8080 start_time = seed = time (NULL );
8181
82- while ((ch = getopt (argc , argv , "ulstpg :f:r:" )) != -1 ) {
82+ while ((ch = getopt (argc , argv , ":u?lstpg :f:r:" )) != -1 ) {
8383 switch (ch ) {
8484 case '?' :
8585 case 'u' :
@@ -120,8 +120,7 @@ main(int argc, char *argv[])
120120 if (f_printpath ) {
121121 char buf [100 ];
122122
123- (void )strcpy (buf , _PATH_GAMES );
124- buf [strlen (buf ) - 1 ] = '\0' ;
123+ (void )strlcpy (buf , _PATH_GAMES , 100 );
125124 (void )puts (buf );
126125 }
127126
@@ -145,7 +144,6 @@ main(int argc, char *argv[])
145144 (void )signal (SIGQUIT , quit );
146145#ifdef BSD
147146 (void )signal (SIGTSTP , SIG_IGN );
148- (void )signal (SIGSTOP , SIG_IGN );
149147#endif
150148 (void )signal (SIGHUP , log_score_quit );
151149 (void )signal (SIGTERM , log_score_quit );
@@ -232,8 +230,8 @@ default_game(void)
232230 static char file [256 ];
233231 char line [256 ], games [256 ];
234232
235- (void )strcpy (games , _PATH_GAMES );
236- (void )strcat (games , GAMES );
233+ (void )strlcpy (games , _PATH_GAMES , 256 );
234+ (void )strlcat (games , GAMES , 256 );
237235
238236 if ((fp = fopen (games , "r" )) == NULL ) {
239237 warn ("fopen %s" , games );
@@ -246,8 +244,8 @@ default_game(void)
246244 }
247245 (void )fclose (fp );
248246 line [strlen (line ) - 1 ] = '\0' ;
249- (void )strcpy (file , _PATH_GAMES );
250- (void )strcat (file , line );
247+ (void )strlcpy (file , _PATH_GAMES , 256 );
248+ (void )strlcat (file , line , 256 );
251249 return (file );
252250}
253251
@@ -259,8 +257,8 @@ okay_game(const char *s)
259257 const char * ret = NULL ;
260258 char line [256 ], games [256 ];
261259
262- (void )strcpy (games , _PATH_GAMES );
263- (void )strcat (games , GAMES );
260+ (void )strlcpy (games , _PATH_GAMES , 256 );
261+ (void )strlcat (games , GAMES , 256 );
264262
265263 if ((fp = fopen (games , "r" )) == NULL ) {
266264 warn ("fopen %s" , games );
@@ -269,8 +267,8 @@ okay_game(const char *s)
269267 while (fgets (line , sizeof (line ), fp ) != NULL ) {
270268 line [strlen (line ) - 1 ] = '\0' ;
271269 if (strcmp (s , line ) == 0 ) {
272- (void )strcpy (file , _PATH_GAMES );
273- (void )strcat (file , line );
270+ (void )strlcpy (file , _PATH_GAMES , 256 );
271+ (void )strlcat (file , line , 256 );
274272 ret = file ;
275273 break ;
276274 }
@@ -293,8 +291,8 @@ list_games(void)
293291 char line [256 ], games [256 ];
294292 int num_games = 0 ;
295293
296- (void )strcpy (games , _PATH_GAMES );
297- (void )strcat (games , GAMES );
294+ (void )strlcpy (games , _PATH_GAMES , 256 );
295+ (void )strlcat (games , GAMES , 256 );
298296
299297 if ((fp = fopen (games , "r" )) == NULL ) {
300298 warn ("fopen %s" , games );
0 commit comments