File: 0006-rtl_eeprom-fix-warnings.patch

package info (click to toggle)
rtl-sdr 0.6.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,660 kB
  • sloc: ansic: 9,305; python: 102; sh: 86; makefile: 74; xml: 57
file content (42 lines) | stat: -rw-r--r-- 1,232 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 3c263b745121d9f4df95fd06910a00eba98a2f11 Mon Sep 17 00:00:00 2001
From: Steve Markgraf <steve@steve-m.de>
Date: Fri, 1 Nov 2019 02:18:54 +0100
Subject: [PATCH 06/33] rtl_eeprom: fix warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Account for \0 string terminator when calling strncpy().

Fixes the following GCC 9 warning:
warning: ‘__builtin_strncpy’ specified
bound 256 equals destination size
---
 src/rtl_eeprom.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/rtl_eeprom.c b/src/rtl_eeprom.c
index f562d73..24be900 100644
--- a/src/rtl_eeprom.c
+++ b/src/rtl_eeprom.c
@@ -370,14 +370,14 @@ int main(int argc, char **argv)
 	}
 
 	if (manuf_str)
-		strncpy((char*)&conf.manufacturer, manuf_str, MAX_STR_SIZE);
+		strncpy((char*)&conf.manufacturer, manuf_str, MAX_STR_SIZE - 1);
 
 	if (product_str)
-		strncpy((char*)&conf.product, product_str, MAX_STR_SIZE);
+		strncpy((char*)&conf.product, product_str, MAX_STR_SIZE - 1);
 
 	if (serial_str) {
 		conf.have_serial = 1;
-		strncpy((char*)&conf.serial, serial_str, MAX_STR_SIZE);
+		strncpy((char*)&conf.serial, serial_str, MAX_STR_SIZE - 1);
 	}
 
 	if (ir_endpoint != 0)
-- 
2.30.2