fix: stop ctlwizchip() from dereferencing NULL arguments (AUD-005) - #184
Open
occamsshavingkit wants to merge 1 commit into
Open
fix: stop ctlwizchip() from dereferencing NULL arguments (AUD-005)#184occamsshavingkit wants to merge 1 commit into
occamsshavingkit wants to merge 1 commit into
Conversation
ctlwizchip() unconditionally evaluated uint8_t tmp = *(uint8_t*)arg before dispatching to the command case. CW_RESET_WIZCHIP requires no argument and CW_INIT_WIZCHIP explicitly supports arg == NULL for default socket buffers, so a documented no-argument call could dereference NULL. Fix: remove the unconditional dereference and move guarded reads into only the cases that require arg (CW_SYS_LOCK, CW_SYS_UNLOCK, CW_GET_SYSLOCK, CW_GET_PHYPOWMODE, CW_GET_PHYLINK). Each case returns -1 when arg == NULL. No-argument and default-argument commands proceed without dereferencing.
niansa
added a commit
to niansa/ioLibrary_Driver
that referenced
this pull request
Jul 29, 2026
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.
Summary
Fixes unconditional NULL dereference in
ctlwizchip()for documented no-argument commands.Problem
Ethernet/wizchip_conf.c:436unconditionally evaluateduint8_t tmp = *(uint8_t*) argbefore dispatching to the command case:CW_RESET_WIZCHIPrequires no argument andCW_INIT_WIZCHIPexplicitly supportsarg == NULLfor default socket buffers, so a documented no-argument call could dereference NULL.Fix
uint8_t tmp = *(uint8_t*) argat the top of the functionarg:CW_SYS_LOCK,CW_SYS_UNLOCK,CW_GET_SYSLOCK(W6100/W6300)CW_GET_PHYPOWMODE,CW_GET_PHYLINK(W5100S/W5200/W5500/W6100/W6300)-1whenarg == NULLCW_RESET_WIZCHIPandCW_INIT_WIZCHIPproceed without dereferencingVerification
_WIZCHIP_valuesctlwizchip(CW_RESET_WIZCHIP, NULL)andctlwizchip(CW_INIT_WIZCHIP, NULL)do not fault;CW_SYS_LOCKwith NULL returns-1