Skip to content

fix(esp_modem): Output buffer not cleared when AT command returns empty response (IDFGH-17370)#1026

Open
JellevanKraaij wants to merge 1 commit intoespressif:masterfrom
JellevanKraaij:master
Open

fix(esp_modem): Output buffer not cleared when AT command returns empty response (IDFGH-17370)#1026
JellevanKraaij wants to merge 1 commit intoespressif:masterfrom
JellevanKraaij:master

Conversation

@JellevanKraaij
Copy link

@JellevanKraaij JellevanKraaij commented Mar 12, 2026

Description

When esp_modem_at() or esp_modem_at_raw() returns an empty response,
the output buffer p_out was not cleared. This caused callers to read
uninitialized or stale data when checking p_out after a successful AT
command that returns no payload (e.g. AT returns just OK with no
additional data).

This fix explicitly sets p_out[0] = '\0' when the response is empty,
ensuring callers can safely check the buffer without needing to
pre-initialize it themselves.

Testing

Tested on SIM7080G with esp-idf v5.5.3 using esp_modem_at(dce, "AT", buf, 1000).
Previously buf contained garbage when the command succeeded, now it is
correctly cleared to an empty string.


Note

Low Risk
Low risk, localized change to the C API output handling; main risk is minor behavior change for callers that previously relied on stale buffer contents when responses were empty.

Overview
Fixes esp_modem_at() and esp_modem_at_raw() to always write a valid C string to p_out when provided.

When the modem returns an empty payload, the functions now explicitly set p_out[0] = '\0' instead of leaving the buffer unchanged, preventing callers from reading stale/garbage data after successful commands with no response body.

Written by Cursor Bugbot for commit b45bee2. This will update automatically on new commits. Configure here.

@JellevanKraaij JellevanKraaij changed the title esp_modem: fix output buffer not cleared when AT command returns empty response fix(esp_modem): output buffer not cleared when AT command returns empty response Mar 12, 2026
@JellevanKraaij JellevanKraaij changed the title fix(esp_modem): output buffer not cleared when AT command returns empty response fix(esp_modem): Output buffer not cleared when AT command returns empty response Mar 12, 2026
@JellevanKraaij
Copy link
Author

Hi, could you let me know when the next release of esp_modem is planned?
I'm currently using a local fork as a workaround and would like to know
when I can switch back to the official release with this fix included.

@github-actions github-actions bot changed the title fix(esp_modem): Output buffer not cleared when AT command returns empty response fix(esp_modem): Output buffer not cleared when AT command returns empty response (IDFGH-17370) Mar 12, 2026
@espressif-bot espressif-bot added the Status: Opened Issue is new label Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Opened Issue is new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants