From bf9d2417a1e73697873a5f5099dac4bb3eb4b2d9 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 1 Aug 2013 11:21:09 -0400 Subject: [PATCH 1/2] fix string off-by-one bugs --- helper.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/helper.c b/helper.c index b09963c..4fbbae5 100644 --- a/helper.c +++ b/helper.c @@ -508,12 +508,12 @@ void get_fqdn(){ memset(&hlp, 0, sizeof(hlp)); if (hostname) { - strncpy(fqdn, hostname, FQDN_SIZE); - strncpy(hname, hostname, 100); + strncpy(fqdn, hostname, FQDN_SIZE-1); + strncpy(hname, hostname, sizeof(hname)-1); } else { if ((uname(&un))==0) { - strncpy(hname, un.nodename, 100); + strncpy(hname, un.nodename, sizeof(hname)-1); } else { if (gethostname(&hname[0], namelen) < 0) { @@ -532,7 +532,7 @@ void get_fqdn(){ snprintf(fqdn, FQDN_SIZE, "%s.%s", hname, dname); } else { - strncpy(fqdn, hname, FQDN_SIZE); + strncpy(fqdn, hname, FQDN_SIZE-1); } #endif } @@ -541,15 +541,15 @@ void get_fqdn(){ he=gethostbyname(hname); if (he) { if (numeric == 1) { - snprintf(hlp, 15, "%s", inet_ntoa(*(struct in_addr *) he->h_addr_list[0])); - strncpy(fqdn, hlp, FQDN_SIZE); + snprintf(hlp, sizeof(hlp), "%s", inet_ntoa(*(struct in_addr *) he->h_addr_list[0])); + strncpy(fqdn, hlp, FQDN_SIZE-1); } else { if ((strchr(he->h_name, '.'))!=NULL && (strchr(hname, '.'))==NULL) { - strncpy(fqdn, he->h_name, FQDN_SIZE); + strncpy(fqdn, he->h_name, FQDN_SIZE-1); } else { - strncpy(fqdn, hname, FQDN_SIZE); + strncpy(fqdn, hname, FQDN_SIZE-1); } } } @@ -561,7 +561,7 @@ void get_fqdn(){ if ((strchr(fqdn, '.'))==NULL) { if (hostname) { fprintf(stderr, "warning: %s is not resolvable... continouing anyway\n", fqdn); - strncpy(fqdn, hostname, FQDN_SIZE); + strncpy(fqdn, hostname, FQDN_SIZE-1); } else { fprintf(stderr, "error: this FQDN or IP is not valid: %s\n", fqdn); From 4779ff12fec9cbff0e983a5140bbcfcd30ee3f8e Mon Sep 17 00:00:00 2001 From: Andrew Pogrebennyk Date: Wed, 7 Aug 2013 15:08:38 +0200 Subject: [PATCH 2/2] update changelog --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index 8dcd36c..b12de7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +ngcp-sipsak (0.9.6+sipwise6) unstable; urgency=low + + [ Richard Fuchs ] + * fix string off-by-one bugs + + -- Andrew Pogrebennyk Wed, 07 Aug 2013 15:08:28 +0200 + ngcp-sipsak (0.9.6+sipwise5) unstable; urgency=low [ Michael Prokop ]