Skip to content

Conversation

@bcoles
Copy link
Contributor

@bcoles bcoles commented Jan 19, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes memory leaks, buffer overflows, and a buffer overread vulnerability across multiple files in the mettle codebase.

Changes:

  • Fixed realloc memory leak pattern in TLV packet functions
  • Replaced unsafe sprintf calls with snprintf to prevent buffer overflows
  • Added proper cleanup on error paths to prevent memory leaks
  • Fixed buffer overread in console command parsing

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
mettle/src/tlv.c Fixed realloc memory leaks in tlv_packet_add_child_raw and tlv_packet_add_raw by storing realloc result in new pointer and freeing original on failure
mettle/src/stdapi/sys/memory.c Added memory cleanup for read_str and matches on realloc failure; replaced sprintf with snprintf to prevent buffer overflow
mettle/src/stdapi/audio/linux_output.c Fixed memory leak by using goto cleanup pattern to ensure ctx->buffer and ctx are always freed on error paths
mettle/src/stdapi/audio/linux_mic.c Added missing stdlib.h include; added cleanup for sound_device and proc_asound_pcm; replaced sprintf with snprintf
mettle/src/console.c Fixed buffer overread by properly parsing command with whitespace skipping and validation before accessing module name
mettle/src/buffer_queue.c Fixed memory leak by calling buffer_queue_drain_all before freeing queue to clean up all buffered data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant