Skip to content

Fix CVE-2022-47012: uninitialized error buffer in gen_eth_init - #320

Merged
grossmj merged 2 commits into
masterfrom
copilot/fix-dynamips-vulnerability
Oct 6, 2026
Merged

grossmj merged 2 commits into
masterfrom
copilot/fix-dynamips-vulnerability

Conversation

Copilot AI commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

This fixes CVE-2022-47012. When opening a pcap device fails, gen_eth_init (common/gen_eth.c) prints pcap_errbuf. That buffer is never initialized, and libpcap doesn't promise to write it on every failure. In that case %s prints leftover stack memory. Without a terminating NUL, it can also read past the end of the buffer.

Changes (common/gen_eth.c)

  • gen_eth_init
    • pcap_errbuf is zero-initialized, and its last byte is set to NUL again before it is printed.
    • p starts out as NULL.
    • A NULL device is rejected before reaching pcap_open_live/pcap_open.
  • gen_eth_show_dev_list: pcap_errbuf is zero-initialized the same way.
char pcap_errbuf[PCAP_ERRBUF_SIZE] = { 0 };
...
pcap_error:
   pcap_errbuf[PCAP_ERRBUF_SIZE - 1] = '\0';
   fprintf(stderr, "gen_eth_init: unable to open device '%s' with PCAP (%s)\n", device, pcap_errbuf);

For reviewers

  • When libpcap does fill the buffer, the error message is unchanged.
  • The change is in the commit titled "Plan: fix CVE-2022-47012". Squash or reword it when merging.

Co-authored-by: grossmj <4752614+grossmj@users.noreply.github.com>
@grossmj
grossmj marked this pull request as ready for review October 6, 2026 14:20
Copilot AI changed the title [WIP] Fix vulnerability in dynamipsv0.2.25 Fix CVE-2022-47012: uninitialized error buffer in gen_eth_init Oct 6, 2026
Copilot AI requested a review from grossmj October 6, 2026 14:22
@grossmj
grossmj merged commit f14dc50 into master Oct 6, 2026
5 of 8 checks passed
@grossmj
grossmj deleted the copilot/fix-dynamips-vulnerability branch October 6, 2026 14:24
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.

dynamipsv0.2.25: 1 vulnerabilities (highest severity is: 7.5)

2 participants