diff options
author | dholland <dholland@NetBSD.org> | 2008-02-24 06:12:49 +0000 |
---|---|---|
committer | dholland <dholland@NetBSD.org> | 2008-02-24 06:12:49 +0000 |
commit | 540e37d7ff8085f7cf6abac27b5f298a50d1af1e (patch) | |
tree | 0695ffca3668b86ba5555bc53d26a7ca83bed4aa /monop | |
parent | 84200264cf0a41781f9ebd56643526065acec647 (diff) | |
download | bsdgames-darwin-540e37d7ff8085f7cf6abac27b5f298a50d1af1e.tar.gz bsdgames-darwin-540e37d7ff8085f7cf6abac27b5f298a50d1af1e.tar.zst bsdgames-darwin-540e37d7ff8085f7cf6abac27b5f298a50d1af1e.zip |
Don't crash if we're asked to restore from /dev/null. (woops)
Diffstat (limited to 'monop')
-rw-r--r-- | monop/execute.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/monop/execute.c b/monop/execute.c index b8208fcc..6b5334a3 100644 --- a/monop/execute.c +++ b/monop/execute.c @@ -1,4 +1,4 @@ -/* $NetBSD: execute.c,v 1.20 2008/02/24 06:03:35 dholland Exp $ */ +/* $NetBSD: execute.c,v 1.21 2008/02/24 06:12:49 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)execute.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: execute.c,v 1.20 2008/02/24 06:03:35 dholland Exp $"); +__RCSID("$NetBSD: execute.c,v 1.21 2008/02/24 06:12:49 dholland Exp $"); #endif #endif /* not lint */ @@ -362,6 +362,7 @@ rest_f(const char *file) char xbuf[80]; STAT sbuf; char readbuf[512]; + int ret = 0; inf = fopen(file, "r"); if (inf == NULL) { @@ -389,11 +390,13 @@ rest_f(const char *file) sp = strchr(readbuf, '\n'); if (sp == NULL) { printf("file is corrupt: long lines.\n"); + ret = -1; break; } *sp = '\0'; if (restore_parseline(readbuf)) { + ret = -1; break; } } @@ -402,8 +405,16 @@ rest_f(const char *file) warnx("%s: read error", file); fclose(inf); + if (ret < 0) + return -1; + name_list[num_play] = "done"; + if (play == NULL || cur_p == NULL || num_play < 2) { + printf("save file is incomplete.\n"); + return -1; + } + /* * We could at this point crosscheck the following: * - there are only two GOJF cards floating around |