From: Tim Kientzle Date: Fri, 11 Oct 2024 06:13:00 +0000 (-0700) Subject: Clarify crc32 variable names (#2367) X-Git-Tag: v3.8.0~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35e630174e18442f3b1ec432cef78a5b9b6818aa;p=thirdparty%2Flibarchive.git Clarify crc32 variable names (#2367) No functional change, just a tiny style improvement. Use `crc32_computed` to refer to the crc32 that the reader has computed and `crc32_read` to refer to the value that we read from the archive. That hopefully makes this code a tiny bit easier to follow. (It confused me recently when I was double-checking something in this area, so I thought an improvement here might help others.) --- diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c index af2831b36..9cf4d639a 100644 --- a/libarchive/archive_read_support_format_rar.c +++ b/libarchive/archive_read_support_format_rar.c @@ -1371,7 +1371,7 @@ read_header(struct archive_read *a, struct archive_entry *entry, char unp_size[8]; int ttime; struct archive_string_conv *sconv, *fn_sconv; - unsigned long crc32_val; + uint32_t crc32_computed, crc32_read; int ret = (ARCHIVE_OK), ret2; char *newptr; size_t newsize; @@ -1402,7 +1402,7 @@ read_header(struct archive_read *a, struct archive_entry *entry, "Invalid header size"); return (ARCHIVE_FATAL); } - crc32_val = crc32(0, (const unsigned char *)p + 2, 7 - 2); + crc32_computed = crc32(0, (const unsigned char *)p + 2, 7 - 2); __archive_read_consume(a, 7); if (!(rar->file_flags & FHD_SOLID)) @@ -1436,8 +1436,9 @@ read_header(struct archive_read *a, struct archive_entry *entry, return (ARCHIVE_FATAL); /* File Header CRC check. */ - crc32_val = crc32(crc32_val, h, (unsigned)(header_size - 7)); - if ((crc32_val & 0xffff) != archive_le16dec(rar_header.crc)) { + crc32_computed = crc32(crc32_computed, h, (unsigned)(header_size - 7)); + crc32_read = archive_le16dec(rar_header.crc); + if ((crc32_computed & 0xffff) != crc32_read) { #ifndef DONT_FAIL_ON_CRC_ERROR archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Header CRC error");