aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-12-02 13:51:09 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-12-02 13:51:09 +0100
commit523224ecb31e716cb0fa6db31ee9b68f118f7fcd (patch)
tree34b3194d86423be2da72d00152206eb64dbc1609 /FICS
parent9b75deffe79860cc8e01d6d69fe09e1b06b08b48 (diff)
Improved old_mail_moves()
Diffstat (limited to 'FICS')
-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);