sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit ed9985205bd14b09af841d25da48a0f23dc32802
parent c2db1b9ec63fe18ed25edf4fdf69102161c6402e
Author: sin <sin@2f30.org>
Date:   Tue,  4 Feb 2014 14:36:58 +0000

Explicitly check for '\0' at the start and exit early

Diffstat:
Muudecode.c | 7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/uudecode.c b/uudecode.c @@ -95,12 +95,11 @@ checkheader(FILE *fp, const char *s, const char *header, mode_t *mode, char **fn char *p, *q; size_t n; - if (fgets(bufs, sizeof(bufs), fp) == NULL) { + if (fgets(bufs, sizeof(bufs), fp) == NULL) if (ferror(fp)) eprintf("%s: read error:", s); - else - eprintf("empty or null header string\n"); - } + if (bufs[0] == '\0' || feof(fp)) + eprintf("empty or nil header string\n"); if ((p = strchr(bufs, '\n')) == NULL) eprintf("header string too long or non-newline terminated file\n"); p = bufs;