[PR #1329] fix: heap-buffer-overflow in run_length_encoding.c #1931

Open
opened 2026-01-29 15:26:23 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/TheAlgorithms/C/pull/1329
Author: @vil02
Created: 10/2/2023
Status: 🔄 Open

Base: masterHead: heap-buffer-overflow_in_run_length_encoding_patch


📝 Commits (1)

  • 9406e55 fix: heap-buffer-overflow

📊 Changes

1 file changed (+20 additions, -4 deletions)

View changed files

📝 misc/run_length_encoding.c (+20 -4)

📄 Description

Description of Change

Running run_length_encoding.c leads to heap-buffer-overflow. The encoded is one too short. Moreover, there is an error in this test case:
e5dad3fa8d/misc/run_length_encoding.c (L77)
Note that the last character of the output of the function run_length_encode has to be the same as the last character of the input.

This PR fixes the mentioned issues and adds new test cases.

References

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:

This PR fixes the heap-buffer-overflow in run_length_encoding.c.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/TheAlgorithms/C/pull/1329 **Author:** [@vil02](https://github.com/vil02) **Created:** 10/2/2023 **Status:** 🔄 Open **Base:** `master` ← **Head:** `heap-buffer-overflow_in_run_length_encoding_patch` --- ### 📝 Commits (1) - [`9406e55`](https://github.com/TheAlgorithms/C/commit/9406e553bedaf54e5ac4f0edcb0a907bf49b7b0b) fix: `heap-buffer-overflow` ### 📊 Changes **1 file changed** (+20 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `misc/run_length_encoding.c` (+20 -4) </details> ### 📄 Description #### Description of Change <!-- Thank you for your Pull Request. Please provide a description above and review the requirements below. Contributors guide: https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md --> Running [`run_length_encoding.c`](https://github.com/TheAlgorithms/C/blob/e5dad3fa8def3726ec850ca66a7f51521f8ad393/misc/run_length_encoding.c) leads to `heap-buffer-overflow`. The [`encoded`](https://github.com/TheAlgorithms/C/blob/e5dad3fa8def3726ec850ca66a7f51521f8ad393/misc/run_length_encoding.c#L32) is _one too short_. Moreover, there is an error in this test case: https://github.com/TheAlgorithms/C/blob/e5dad3fa8def3726ec850ca66a7f51521f8ad393/misc/run_length_encoding.c#L77 Note that the last character of the output of the function `run_length_encode` has to be the same as the last character of the input. This PR fixes the mentioned issues and adds new test cases. #### References <!-- Add any reference to previous pull-request or issue --> #### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [x] Added description of change - [x] Added file name matches [File name guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#File-Name-guidelines) - [x] Added tests and example, test must pass - [x] Relevant documentation/comments is changed or added - [x] PR title follows semantic [commit guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#Commit-Guidelines) - [x] Search previous suggestions before making a new one, as yours may be a duplicate. - [x] I acknowledge that all my contributions will be made under the project's license. Notes: <!-- Please add a one-line description for developers or pull request viewers --> This PR fixes the `heap-buffer-overflow` in [`run_length_encoding.c`](https://github.com/TheAlgorithms/C/blob/e5dad3fa8def3726ec850ca66a7f51521f8ad393/misc/run_length_encoding.c). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 15:26:23 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#1931