aboutsummaryrefslogtreecommitdiffstats
path: root/inet_ntop.c
diff options
context:
space:
mode:
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2009-03-18 00:03:41 +0000
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2009-03-18 00:03:41 +0000
commit8ed221915bb0c1e6436e25d489176856e6a20406 (patch)
tree96b1914553487970ecbe7cda51a3fcc3530d808a /inet_ntop.c
parentdd620209cc9cfcdb9ece90ec55913b568d01e39e (diff)
From Jakub Zawadzki: Glib2 g_snprintf doesn't return -1;
Also: from me: fix an "off by 1" issue in inet_ntop_4 which could result in a trailing character of the output string being truncated rather than an ENOSPC error being reported. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27766 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'inet_ntop.c')
-rw-r--r--inet_ntop.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/inet_ntop.c b/inet_ntop.c
index e240f94b65..31580c02c8 100644
--- a/inet_ntop.c
+++ b/inet_ntop.c
@@ -130,9 +130,8 @@ inet_ntop4(src, dst, size)
int nprinted;
nprinted = g_snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
- if (nprinted < 0)
- return (NULL); /* we assume "errno" was set by "g_snprintf()" */
- if ((size_t)nprinted > size) {
+ /* Note: nprinted *excludes* the trailing '\0' character */
+ if ((size_t)nprinted >= size) {
errno = ENOSPC;
return (NULL);
}