mirror of
git://git.suckless.org/sbase
synced 2024-12-24 16:02:54 +00:00
Explicitly check for '\0' at the start and exit early
This commit is contained in:
parent
c2db1b9ec6
commit
ed9985205b
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user