Calloc call fix#46
Merged
Merged
Conversation
json_script_file_from_blobmsg() passed name_len, a plain int, as a chunk size to calloc_a(). __calloc_a() reads chunk sizes as size_t through varargs, so on LP64 systems va_arg(ap, size_t) reads 8 bytes where only 4 were pushed. Widen name_len to size_t. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Link: openwrt#46 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
udebug_remote_buf_snapshot() passed data_size, a uint32_t, as a chunk size to calloc_a(). __calloc_a() reads chunk sizes as size_t through varargs, so on LP64 systems va_arg(ap, size_t) reads 8 bytes where only 4 were pushed. Cast data_size to size_t at the call site. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Link: openwrt#46 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Several local length variables stored the result of size_t-returning functions (strlen, blob_pad_len, blob_raw_len, array_list_length) in an int, which GCC's -Wconversion reports as a potentially value-changing narrowing conversion. Widen these variables (and one static helper and one static function parameter) to size_t where the int type was not needed: - avl-cmp: _min() and the memcmp() length in avl_blobcmp() - blob: len/delta in blob_fill_pad() - blobmsg_json: loop counters in blobmsg_add_array() and the length parameter of blobmsg_format_json_list() - jshn: loop counters in add_json_array() udebug_entry_printf() stored the int result of udebug_entry_vprintf() in a size_t; use int there instead. No functional change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Link: openwrt#46 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
blob.h is included by nearly every translation unit, so the conversions in its inline helpers were reported over and over: - blob_id(): hold the masked/shifted id in an unsigned int; the function already returns unsigned int - blob_pad_len(): use size_t for the length (matching blob_raw_len()) and an unsigned mask, instead of unsigned int and a signed ~mask - blob_get_int8/16/32/64(): make the intended reinterpretation of the unsigned value as signed explicit with a cast udebug-remote: rb->pcap_iface is a uint32_t, so assign ~0U instead of the signed ~0 (GCC flagged the latter as changing -1 to 4294967295). No functional change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Link: openwrt#46 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the wrong type uses for calloc and also some other type problems.