]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - compat/getnameinfo.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / compat / getnameinfo.cc
index f70fa7d8e3e22719932ec58aca6a812f32361f95..b0bb7afd14a204cbac2353ee79841531dc5e98d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -13,7 +13,7 @@
  * Update/Maintenance History:
  *
  *    16-Aug-2007 : Copied from fetchmail 6.3.8
- *                      - added protection around libray headers
+ *                      - added protection around library headers
  *                      - added use of alternative name xgetnameinfo
  *                        to split from any OS-provided.
  *
@@ -203,12 +203,12 @@ found:
         if (sp) {
             if (strlen(sp->s_name) + 1 > servlen)
                 return EAI_OVERFLOW;
-            strncpy(serv, sp->s_name, servlen);
+            xstrncpy(serv, sp->s_name, servlen);
         } else {
             snprintf(numserv, sizeof(numserv), "%u", ntohs(port));
             if (strlen(numserv) + 1 > servlen)
                 return EAI_OVERFLOW;
-            strncpy(serv, numserv, servlen);
+            xstrncpy(serv, numserv, servlen);
         }
     }
 
@@ -301,7 +301,7 @@ found:
 #endif
                 return EAI_OVERFLOW;
             }
-            strncpy(host, hp->h_name, hostlen);
+            xstrncpy(host, hp->h_name, hostlen);
 #if USE_GETIPNODEBY
             freehostent(hp);
 #endif
@@ -351,7 +351,7 @@ int flags;
     numaddrlen = strlen(numaddr);
     if (numaddrlen + 1 > hostlen) /* don't forget terminator */
         return EAI_OVERFLOW;
-    strncpy(host, numaddr, hostlen);
+    xstrncpy(host, numaddr, hostlen);
 
     if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
         char zonebuf[SQUIDHOSTNAMELEN];