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

Commit b0426e6

Browse files
author
Sergey Popovich
committed
update: Compare computed vs expected sha256 digit string ignoring case
We produce sha256 digest string using %x snprintf() qualifier for each byte of digest which uses alphabetic characters from "a" to "f" in lower case to represent integer values from 10 to 15. Previously all of the NVD META files supply sha256 digest string for corresponding XML file in lower case. However due to some reason this changed recently to provide digest digits in upper case causing fetched data consistency checks to fail. This prevents database from being updated periodically. While commit c4f6e94 (update: Do not treat sha256 failure as fatal if requested) adds useful option to skip digest validation at all and thus provides workaround for this situation, it might be unacceptable for some deployments where we need to ensure that downloaded data is consistent before start parsing it and update SQLite database. Use strcasecmp() to compare two digest strings case insensitively and addressing this case. Signed-off-by: Sergey Popovich <[email protected]>
1 parent c4f6e94 commit b0426e6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/update.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static bool nvdcve_data_ok(const char *meta, const char *data)
187187
snprintf(&csum_data[idx], len, "%02hhx", digest[i]);
188188
}
189189

190-
ret = streq(csum_meta, csum_data);
190+
ret = !strcasecmp(csum_meta, csum_data);
191191

192192
err_unmap:
193193
munmap(buffer, length);

0 commit comments

Comments
 (0)