File: 1010-strn-buffer-overflow.patch

package info (click to toggle)
yamdi 1.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 256 kB
  • sloc: ansic: 1,638; makefile: 14
file content (28 lines) | stat: -rw-r--r-- 1,092 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Description: Avoid potential buffer overflow in strncpy.
 The strncpy() method do not write a null byte at the end if the buffer is
 to small for the entire string, so ensure there is a null byte present using other means.
 This avoid the following compiler warning:

yamdi.c:320:33: warning: ‘__builtin_strncpy’ specified bound 256 equals destination size [-Wstringop-truncation]
  320 |                                 strncpy(flv.options.creator, optarg, sizeof(flv.options.creator));
      |                                 ^

Author: Petter Reinholdtsen
Author: xiao sheng wen <atzlinux@debian.org>
Forwarded: no-need
Reviewed-by: xiao sheng wen <atzlinux@debian.org>
Last-Update: 2025-04-21
---
diff --git a/yamdi.c b/yamdi.c
index ac9e0e6..665acc2 100644
--- a/yamdi.c
+++ b/yamdi.c
@@ -317,7 +317,7 @@ int main(int argc, char **argv) {
 				tempfile = optarg;
 				break;
 			case 'c':
-				strncpy(flv.options.creator, optarg, sizeof(flv.options.creator));
+				strncpy(flv.options.creator, optarg, sizeof(flv.options.creator)-1);
 				break;
 			case 'l':
 			case 's':