Skip to content

Commit

Permalink
librc: avoid using fixed-size buffers for paths
Browse files Browse the repository at this point in the history
Use heap allocations instead. This avoids warnings:

```
../src/librc/librc.c: In function ‘rc_service_mark’:
../src/librc/librc.c:817:58: warning: ‘/’ directive output may be truncated writing 1 byte into a region of size between 0 and 4095 [-Wformat-truncation=]
  817 |                         snprintf(was, sizeof(was), "%s/%s/%s",
      |                                                          ^
../src/librc/librc.c:817:25: note: ‘snprintf’ output 3 or more bytes (assuming 4098) into a destination of size 4096
  817 |                         snprintf(was, sizeof(was), "%s/%s/%s",
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  818 |                             file, dir->value, base);
      |                             ~~~~~~~~~~~~~~~~~~~~~~~
../src/librc/librc.c:822:58: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
  822 |                         snprintf(was, sizeof(was), "%s/%s", file, dir->value);
      |                                                          ^
../src/librc/librc.c:822:25: note: ‘snprintf’ output 2 or more bytes (assuming 4097) into a destination of size 4096
  822 |                         snprintf(was, sizeof(was), "%s/%s", file, dir->value);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
  • Loading branch information
floppym authored and williamh committed Jun 3, 2024
1 parent 3d30b6f commit 70be1c0
Showing 1 changed file with 197 additions and 122 deletions.
Loading

0 comments on commit 70be1c0

Please sign in to comment.