/*
- * Copyright (C) 1996-2014 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.
* 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.
*
* - use xinet_ntop instead of inet_ntop
* - use SQUIDHOSTNAMELEN instead of MAXHOSTNAMELEN
*
+ * 13-Jan-2015 : Various fixed for C++ and MinGW native build
+ *
* Original License and code follows.
*/
#include "squid.h"
#endif
int
-xgetnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
-const struct sockaddr *sa;
-socklen_t salen;
-char *host;
-size_t hostlen;
-char *serv;
-size_t servlen;
-int flags;
+xgetnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
{
const struct afd *afd;
struct servent *sp;
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);
}
}
#endif
return EAI_OVERFLOW;
}
- strncpy(host, hp->h_name, hostlen);
+ xstrncpy(host, hp->h_name, hostlen);
#if USE_GETIPNODEBY
freehostent(hp);
#endif
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];