aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--FICS/obsproc.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/FICS/obsproc.c b/FICS/obsproc.c
index 4dd7b2d..08b4796 100644
--- a/FICS/obsproc.c
+++ b/FICS/obsproc.c
@@ -672,11 +672,11 @@ com_mailmoves(int p, param_list param)
PRIVATE int
old_mail_moves(int p, int mail, param_list param)
{
- FILE *fp;
+ FILE *fp = NULL;
char fname[MAX_FILENAME_SIZE] = { '\0' };
char tmp[2048] = { '\0' };
char *ptmp = tmp;
- int count;
+ int count = 0;
int p1, connected;
if (mail && (!parray[p].registered)) {
@@ -705,10 +705,16 @@ old_mail_moves(int p, int mail, param_list param)
return COM_OK;
}
- while (!feof(fp))
- fgets(tmp, 1024, fp);
+ while (fgets(tmp, sizeof tmp, fp) != NULL) {
+ /* null */;
+ }
+
+ if (sscanf(ptmp, "%d", &count) != 1) {
+ warnx("%s: sscanf() error", __func__);
+ fclose(fp);
+ return COM_FAILED;
+ }
- sscanf(ptmp, "%d", &count);
fclose(fp);
pprintf(p, "Last game for %s was history game %d.\n", parray[p1].name,
count);