blob: 5a62e1584dd4d954fcbed56f47ada0263a81efe6 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From d8950ad273d79ec516468289adbd427e681dbc66 Mon Sep 17 00:00:00 2001
2From: Mingli Yu <mingli.yu@windriver.com>
3Date: Mon, 30 Jul 2018 01:22:56 -0700
4Subject: [PATCH] src/tcp.c: increase the size of szHname
5
6Increase the size of szHname to fix below
7error:
8| ../../git/src/tcp.c: In function 'relpTcpSetRemHost':
9| ../../git/src/tcp.c:352:57: error: '%s' directive output may be truncated writing up to 1024 bytes into a region of size 1011 [-Werror=format-truncation=]
10| snprintf((char*)szHname, NI_MAXHOST, "[MALICIOUS:IP=%s]", szIP);
11| ^~ ~~~~
12| In file included from /poky-build/tmp/work/i586-poky-linux/librelp/1.2.16-r0/recipe-sysroot/usr/include/stdio.h:862,
13| from ../../git/src/tcp.c:38:
14| /poky-build/tmp/work/i586-poky-linux/librelp/1.2.16-r0/recipe-sysroot/usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 16 and 1040 bytes into a destination of size 1025
15| return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
16| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17| __bos (__s), __fmt, __va_arg_pack ());
18| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19| cc1: all warnings being treated as errors
20| Makefile:536: recipe for target 'librelp_la-tcp.lo' failed
21
22Upstream-Status: Submitted[https://github.com/rsyslog/librelp/pull/118]
23
24Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
25---
26 src/tcp.c | 4 ++--
27 1 file changed, 2 insertions(+), 2 deletions(-)
28
29diff --git a/src/tcp.c b/src/tcp.c
30index fb34dc7..2c38b0b 100644
31--- a/src/tcp.c
32+++ b/src/tcp.c
33@@ -319,7 +319,7 @@ relpTcpSetRemHost(relpTcp_t *const pThis, struct sockaddr *pAddr)
34 relpEngine_t *pEngine;
35 int error;
36 unsigned char szIP[NI_MAXHOST] = "";
37- unsigned char szHname[NI_MAXHOST] = "";
38+ unsigned char szHname[1045] = "";
39 struct addrinfo hints, *res;
40 size_t len;
41
42@@ -349,7 +349,7 @@ relpTcpSetRemHost(relpTcp_t *const pThis, struct sockaddr *pAddr)
43 if(getaddrinfo((char*)szHname, NULL, &hints, &res) == 0) {
44 freeaddrinfo (res);
45 /* OK, we know we have evil, so let's indicate this to our caller */
46- snprintf((char*)szHname, NI_MAXHOST, "[MALICIOUS:IP=%s]", szIP);
47+ snprintf((char*)szHname, sizeof(szHname), "[MALICIOUS:IP=%s]", szIP);
48 pEngine->dbgprint("Malicious PTR record, IP = \"%s\" HOST = \"%s\"", szIP, szHname);
49 iRet = RELP_RET_MALICIOUS_HNAME;
50 }
51--
522.17.1
53