INN commit: branches/2.5/lib (getnameinfo.c)

INN Commit rra at isc.org
Sun Nov 10 18:30:25 UTC 2013


    Date: Sunday, November 10, 2013 @ 10:30:25
  Author: iulius
Revision: 9565

getnameinfo.c:  sync with rra-c-util

Check the return status of snprintf instead of assuming that
it will always succeed.

Modified:
  branches/2.5/lib/getnameinfo.c

---------------+
 getnameinfo.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Modified: getnameinfo.c
===================================================================
--- getnameinfo.c	2013-11-10 18:27:16 UTC (rev 9564)
+++ getnameinfo.c	2013-11-10 18:30:25 UTC (rev 9565)
@@ -111,6 +111,7 @@
 {
     struct servent *srv;
     const char *protocol;
+    int status;
 
     /* Do the name lookup first unless told not to. */
     if (!(flags & NI_NUMERICSERV)) {
@@ -125,7 +126,8 @@
     }
 
     /* Just convert the port number to ASCII. */
-    if ((socklen_t) snprintf(service, servicelen, "%hu", port) > servicelen)
+    status = snprintf(service, servicelen, "%hu", port);
+    if (status < 0 || (socklen_t) status > servicelen)
         return EAI_OVERFLOW;
     return 0;
 }



More information about the inn-committers mailing list