Check getline()-return-values properly
It's not useful when 0 is returned anyway, so be sure that we have a string with length > 0, this also solves some indexing-gotchas like "len - 1" and so on. Also, add checked getline()'s whenever it has been forgotten and clean up the error-messages.
This commit is contained in:
@@ -45,7 +45,7 @@ mdchecklist(FILE *listfp, struct crypt_ops *ops, uint8_t *md, size_t sz,
|
||||
int r;
|
||||
char *line = NULL, *file, *p;
|
||||
|
||||
while (getline(&line, &bufsiz, listfp) != -1) {
|
||||
while (getline(&line, &bufsiz, listfp) > 0) {
|
||||
if (!(file = strstr(line, " "))) {
|
||||
(*formatsucks)++;
|
||||
continue;
|
||||
|
@@ -13,7 +13,7 @@ getlines(FILE *fp, struct linebuf *b)
|
||||
size_t size = 0, linelen;
|
||||
ssize_t len;
|
||||
|
||||
while ((len = getline(&line, &size, fp)) != -1) {
|
||||
while ((len = getline(&line, &size, fp)) > 0) {
|
||||
if (++b->nlines > b->capacity) {
|
||||
b->capacity += 512;
|
||||
nline = erealloc(b->lines, b->capacity * sizeof(*b->lines));
|
||||
|
Reference in New Issue
Block a user