Skip to content

Fix: decrement past start of allocated memory in add_quoting#1075

Merged
greenbonebot merged 2 commits into
mainfrom
fix-cpeutils-add-quoting
Jun 2, 2026
Merged

Fix: decrement past start of allocated memory in add_quoting#1075
greenbonebot merged 2 commits into
mainfrom
fix-cpeutils-add-quoting

Conversation

@mattmundell

@mattmundell mattmundell commented May 29, 2026

Copy link
Copy Markdown
Contributor

What

Change the decrement of a pointer to be the decrement of a length, in add_quoting in cpeutils.c.

Why

This was leading to aborts in gvmd SCAP rebuilds on my Asan builds (and might be leading to empty fields in the CPE structs).

tmp_component is created by g_strdup. Doing strlen on tmp_component - 1 is reading into arbitrary memory. It's likely generally safe due to malloc padding, but may result in the length being off (if the byte before tmp_component is NULL).

Pretty sure the intention was just to decrement the length after.

I've confirmed with a test and -fsantize=address. Before the patch there were Asan leak warnings in the log, after the patch the warnings are gone.

Checklist

  • Tests

@mattmundell mattmundell requested review from a team as code owners May 29, 2026 13:26
@greenbonebot greenbonebot enabled auto-merge (rebase) May 29, 2026 13:27
@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 1b8d3b3.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@mattmundell mattmundell force-pushed the fix-cpeutils-add-quoting branch from ab9517d to 4065f86 Compare May 29, 2026 13:30
@greenbonebot greenbonebot merged commit d0f271b into main Jun 2, 2026
17 checks passed
@greenbonebot greenbonebot deleted the fix-cpeutils-add-quoting branch June 2, 2026 08:29
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.

3 participants