From 006d8e6d5ebc1f1a708f2ab81daee6a7b8e9542c Mon Sep 17 00:00:00 2001 From: Thomas Ries Date: Sun, 7 Feb 2021 17:58:27 +0100 Subject: [PATCH] fixed compiler warning in plugin_fix_bogus_via.c --- src/plugin_fix_bogus_via.c | 4 ++-- src/siproxd.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugin_fix_bogus_via.c b/src/plugin_fix_bogus_via.c index 00d9c14..9faa2f5 100644 --- a/src/plugin_fix_bogus_via.c +++ b/src/plugin_fix_bogus_via.c @@ -154,8 +154,8 @@ static int sip_patch_topvia(sip_ticket_t *ticket) { /* set new port number */ osip_free(via->port); - via->port=osip_malloc(6); /* 5 digits + \0 */ - snprintf(via->port, 5, "%u", ntohs(ticket->from.sin_port)); + via->port=osip_malloc(PORTSTRING_SIZE); /* 5 digits + \0 */ + snprintf(via->port, PORTSTRING_SIZE, "%u", ntohs(ticket->from.sin_port)); via->port[5-1] ='\0'; DEBUGC(DBCLASS_PLUGIN, "plugin_fix_bogus_via: -> %s:%s", diff --git a/src/siproxd.h b/src/siproxd.h index 4ad6b35..61c48ee 100644 --- a/src/siproxd.h +++ b/src/siproxd.h @@ -309,7 +309,8 @@ int unload_plugins(void); #define HOSTNAME_SIZE 128 /* max string length of a hostname */ #define USERNAME_SIZE 128 /* max string length of a username (auth) */ #define PASSWORD_SIZE 128 /* max string length of a password (auth) */ -#define IPSTRING_SIZE 16 /* stringsize of IP address xxx.xxx.xxx.xxx */ +#define IPSTRING_SIZE 16 /* stringsize of IP address xxx.xxx.xxx.xxx\0 */ +#define PORTSTRING_SIZE 6 /* stringsize of port number xxxxx\0 */ #define VIA_BRANCH_SIZE 128 /* max string length for via branch param */ /* scratch buffer for gethostbyname_r() */