diff options
author | Bill Meier <wmeier@newsguy.com> | 2009-03-18 00:03:41 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2009-03-18 00:03:41 +0000 |
commit | 0095250d83007597d820962ff3c41d520362f21c (patch) | |
tree | 96b1914553487970ecbe7cda51a3fcc3530d808a /inet_ntop.c | |
parent | 86ea84d2e48fd131c3cf67bf8b78f9185095d501 (diff) | |
download | wireshark-0095250d83007597d820962ff3c41d520362f21c.tar.gz wireshark-0095250d83007597d820962ff3c41d520362f21c.tar.bz2 wireshark-0095250d83007597d820962ff3c41d520362f21c.zip |
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.
svn path=/trunk/; revision=27766
Diffstat (limited to 'inet_ntop.c')
-rw-r--r-- | inet_ntop.c | 5 |
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); } |