Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Fix cve-check-update looping processing META files #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions src/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,19 @@ static cve_string *nvdcve_make_fname(int year, const char *fext)

static char *nvdcve_meta_get_val(FILE *f, const char *field)
{
do {
char field_name[256], field_value[256];
int ret;

ret = fscanf(f, " %255[^: \f\n\r\t\v] :%255s", field_name, field_value);
char field_name[MAX_META_FILE_KEY_VALUE_SIZE];
char field_value[MAX_META_FILE_KEY_VALUE_SIZE];
char line[MAX_META_FILE_LINE_SIZE];
int ret;
while (fgets(line, MAX_META_FILE_LINE_SIZE, f)) {
ret = sscanf(line, " %255[^: ] : %255s", field_name, field_value);
if (ret != 2) {
if (ret != EOF) {
continue;
}
if (ferror(f)) {
if (errno == EINTR || errno == EAGAIN) {
clearerr(f);
continue;
}
}
return NULL;
}
if (streq(field_name, field)) {
fprintf(stderr, "Ignoring unparseable line in META file\n");
} else if (streq(field_name, field)) {
return strdup(field_value);
}
} while (1);
}
return NULL;
}

static bool nvdcve_data_ok(const char *meta, const char *data)
Expand Down
3 changes: 3 additions & 0 deletions src/update.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

#include "cve-string.h"

#define MAX_META_FILE_LINE_SIZE 512
#define MAX_META_FILE_KEY_VALUE_SIZE 256

cve_string *get_db_path(const char *path);

int update_required(const char *db_file);
Expand Down