From 3b3652b814a23120d479c745d61086a67117eedd Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 20 Nov 2024 22:53:27 +0100 Subject: Fixed ignored retvals --- FICS/eco.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/FICS/eco.c b/FICS/eco.c index 7bcc83f..818003c 100644 --- a/FICS/eco.c +++ b/FICS/eco.c @@ -148,10 +148,16 @@ ECO_init(void) feof(fp)) break; - /* XXX */ - sscanf(ptmp, SCAN_FP_AND_ONMOVE, FENpos, onMove); - (void) strlcat(FENpos, " ", sizeof FENpos); - (void) strlcat(FENpos, onMove, sizeof FENpos); + if (sscanf(ptmp, SCAN_FP_AND_ONMOVE, FENpos, onMove) != 2) { + warnx("%s: sscanf() error (%s:%d)", __func__, + filename, i); + break; + } else if (strlcat(FENpos, " ", sizeof FENpos) >= sizeof FENpos || + strlcat(FENpos, onMove, sizeof FENpos) >= sizeof FENpos) { + warnx("%s: strlcat() error (%s:%d)", __func__, + filename, i); + break; + } (void) strlcpy(ptmp, "", sizeof tmp); if (fgets(ptmp, sizeof tmp, fp) == NULL || @@ -208,9 +214,16 @@ NIC_init(void) feof(fp)) break; - sscanf(ptmp, SCAN_FP_AND_ONMOVE, FENpos, onMove); - (void) strlcat(FENpos, " ", sizeof FENpos); - (void) strlcat(FENpos, onMove, sizeof FENpos); + if (sscanf(ptmp, SCAN_FP_AND_ONMOVE, FENpos, onMove) != 2) { + warnx("%s: sscanf() error (%s:%d)", __func__, + filename, i); + break; + } else if (strlcat(FENpos, " ", sizeof FENpos) >= sizeof FENpos || + strlcat(FENpos, onMove, sizeof FENpos) >= sizeof FENpos) { + warnx("%s: strlcat() error (%s:%d)", __func__, + filename, i); + break; + } (void) strlcpy(ptmp, "", sizeof tmp); if (fgets(ptmp, sizeof tmp, fp) == NULL || @@ -260,10 +273,16 @@ LONG_init(void) feof(fp)) break; - /* XXX */ - sscanf(ptmp, SCAN_FP_AND_ONMOVE, FENpos, onMove); - (void) strlcat(FENpos, " ", sizeof FENpos); - (void) strlcat(FENpos, onMove, sizeof FENpos); + if (sscanf(ptmp, SCAN_FP_AND_ONMOVE, FENpos, onMove) != 2) { + warnx("%s: sscanf() error (%s:%d)", __func__, + filename, i); + break; + } else if (strlcat(FENpos, " ", sizeof FENpos) >= sizeof FENpos || + strlcat(FENpos, onMove, sizeof FENpos) >= sizeof FENpos) { + warnx("%s: strlcat() error (%s:%d)", __func__, + filename, i); + break; + } (void) strlcpy(ptmp, "", sizeof tmp); if (fgets(ptmp, sizeof tmp, fp) == NULL || -- cgit v1.2.3