Skip to content

fix: use uint8_t* for SO_KEEPALIVEAUTO getter (AUD-002) - #181

Open
occamsshavingkit wants to merge 1 commit into
Wiznet:masterfrom
occamsshavingkit:fix/aud-002-keepaliveauto-getter-width
Open

fix: use uint8_t* for SO_KEEPALIVEAUTO getter (AUD-002)#181
occamsshavingkit wants to merge 1 commit into
Wiznet:masterfrom
occamsshavingkit:fix/aud-002-keepaliveauto-getter-width

Conversation

@occamsshavingkit

Copy link
Copy Markdown

Summary

Fixes type-width mismatch in the SO_KEEPALIVEAUTO socket option getter.

Problem

Ethernet/socket.c:1383 wrote the keepalive auto value through uint16_t*:

*(uint16_t*) arg = getSn_KPALVTR(sn);

But the setter at socket.c:1334 and the documented type at socket.h:583 both use uint8_t. A conforming caller passing uint8_t value has one adjacent byte overwritten and may trigger an unaligned halfword fault on strict-alignment MCUs.

Fix

Change uint16_t* to uint8_t*:

*(uint8_t*) arg = getSn_KPALVTR(sn);

Verification

  • Multi-chip compile check: passes for all 7 _WIZCHIP_ values
  • ASan/UBSan: canary test confirms exactly 1 byte written, adjacent bytes intact

The getter at socket.c:1383 wrote through uint16_t*, but the setter at
socket.c:1334 and the documented type at socket.h:583 both use uint8_t.
A conforming caller passing uint8_t had one adjacent byte overwritten
and could trigger an unaligned halfword fault on strict-alignment MCUs.
niansa added a commit to niansa/ioLibrary_Driver that referenced this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant