Skip to content

Commit

Permalink
Fix possible null pointer write or memory corruption during CDX read
Browse files Browse the repository at this point in the history
  • Loading branch information
the-blank-x committed Jan 26, 2024
1 parent c1fe609 commit 8f34226
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/warc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1508,16 +1508,14 @@ warc_process_cdx_line (char *lineptr, int field_num_original_url,
bytes. */
idx_t checksum_l;
char * checksum_v;
char *digest;
base32_decode_alloc (checksum, strlen (checksum), &checksum_v,
&checksum_l);
xfree (checksum);

if (checksum_v != NULL && checksum_l == SHA1_DIGEST_SIZE)
{
/* This is a valid line with a valid checksum. */
memcpy (digest, checksum_v, SHA1_DIGEST_SIZE);
store_warc_record(original_url, NULL, record_id, digest);
store_warc_record(original_url, NULL, record_id, checksum_v);
xfree (checksum_v);
}
else
Expand Down

0 comments on commit 8f34226

Please sign in to comment.