Skip to content

Commit

Permalink
getline
Browse files Browse the repository at this point in the history
- Fix sonar issues by checking the buffer returned by `getline()`
  • Loading branch information
jelu committed Aug 12, 2020
1 parent 67bb9b8 commit a1dd55e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/config_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ int load_knowntlds(const char* file)
new_KnownTLDS[new_size] = ".";
new_size++;

while (getline(&buffer, &bufsize, fp) > 0) {
while (getline(&buffer, &bufsize, fp) > 0 && buffer) {
for (p = buffer; *p; p++) {
if (*p == '\r' || *p == '\n') {
*p = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/parse_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ int parse_conf(const char* file)
if (!(fp = fopen(file, "r"))) {
return 1;
}
while ((ret2 = getline(&buffer, &bufsize, fp)) > 0) {
while ((ret2 = getline(&buffer, &bufsize, fp)) > 0 && buffer) {
memset(tokens, 0, sizeof(conf_token_t) * PARSE_MAX_ARGS);
line++;
/*
Expand Down

0 comments on commit a1dd55e

Please sign in to comment.