}
/* Copy the new device identifier into the correct memory location */
- strncpy(dev->name, tmpstring, strlen(tmpstring) + 1);
+ strlcpy(dev->name, tmpstring, strlen(tmpstring) + 1);
/* Create the new device description */
}
/* Copy the new device description into the correct memory location */
- strncpy(dev->description, tmpstring, strlen(tmpstring) + 1);
+ strlcpy(dev->description, tmpstring, strlen(tmpstring) + 1);
dev = dev->next;
}
return -1;
}
- strncpy(dev->name, tmpstring, stringlen);
+ strlcpy(dev->name, tmpstring, stringlen);
dev->name[stringlen] = 0;
}
/* Copy the new device description into the correct memory location */
- strncpy(dev->description, tmpstring, stringlen + 1);
+ strlcpy(dev->description, tmpstring, stringlen + 1);
pcap_close(fp);
}
}
/* Copy the new device name into the correct memory location */
- strncpy(dev->name, tmpstring2, stringlen + 1);
+ strlcpy(dev->name, tmpstring2, stringlen + 1);
}
if (findalldevs_if.desclen)
}
/* Copy the new device description into the correct memory location */
- strncpy(dev->description, tmpstring2, stringlen + 1);
+ strlcpy(dev->description, tmpstring2, stringlen + 1);
}
dev->flags = ntohl(findalldevs_if.flags);
{
case PCAP_SRC_FILE:
{
- strncpy(source, PCAP_SRC_FILE_STRING, PCAP_BUF_SIZE);
+ strlcpy(source, PCAP_SRC_FILE_STRING, PCAP_BUF_SIZE);
if ((name) && (*name))
{
- strncat(source, name, PCAP_BUF_SIZE);
+ strlcat(source, name, PCAP_BUF_SIZE);
return 0;
}
else
case PCAP_SRC_IFREMOTE:
{
- strncpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE);
+ strlcpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE);
if ((host) && (*host))
{
if ((strcspn(host, "aAbBcCdDeEfFgGhHjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ")) == strlen(host))
{
/* the host name does not contains alphabetic chars. So, it is a numeric address */
/* In this case we have to include it between square brackets */
- strncat(source, "[", PCAP_BUF_SIZE);
- strncat(source, host, PCAP_BUF_SIZE);
- strncat(source, "]", PCAP_BUF_SIZE);
+ strlcat(source, "[", PCAP_BUF_SIZE);
+ strlcat(source, host, PCAP_BUF_SIZE);
+ strlcat(source, "]", PCAP_BUF_SIZE);
}
else
- strncat(source, host, PCAP_BUF_SIZE);
+ strlcat(source, host, PCAP_BUF_SIZE);
if ((port) && (*port))
{
- strncat(source, ":", PCAP_BUF_SIZE);
- strncat(source, port, PCAP_BUF_SIZE);
+ strlcat(source, ":", PCAP_BUF_SIZE);
+ strlcat(source, port, PCAP_BUF_SIZE);
}
- strncat(source, "/", PCAP_BUF_SIZE);
+ strlcat(source, "/", PCAP_BUF_SIZE);
}
else
{
}
if ((name) && (*name))
- strncat(source, name, PCAP_BUF_SIZE);
+ strlcat(source, name, PCAP_BUF_SIZE);
return 0;
}
case PCAP_SRC_IFLOCAL:
{
- strncpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE);
+ strlcpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE);
if ((name) && (*name))
- strncat(source, name, PCAP_BUF_SIZE);
+ strlcat(source, name, PCAP_BUF_SIZE);
return 0;
}
{
/* We're on a local capture */
if (*ptr)
- strncpy(tmpname, ptr, PCAP_BUF_SIZE);
+ strlcpy(tmpname, ptr, PCAP_BUF_SIZE);
/* Clean the host name, since it is a remote capture */
/* NOTE: the host name has been assigned in the previous "ntoken= sscanf(...)" line */
}
if (host)
- strcpy(host, tmphost);
+ strlcpy(host, tmphost, PCAP_BUF_SIZE);
if (port)
- strcpy(port, tmpport);
+ strlcpy(port, tmpport, PCAP_BUF_SIZE);
if (type)
*type = tmptype;
*/
if (tmpname[0])
{
- strcpy(name, tmpname);
+ strlcpy(name, tmpname, PCAP_BUF_SIZE);
}
else
{
if (*ptr)
{
if (name)
- strncpy(name, ptr, PCAP_BUF_SIZE);
+ strlcpy(name, ptr, PCAP_BUF_SIZE);
if (type)
*type = PCAP_SRC_FILE;
if ((source) && (*source))
{
if (name)
- strncpy(name, source, PCAP_BUF_SIZE);
+ strlcpy(name, source, PCAP_BUF_SIZE);
if (type)
*type = PCAP_SRC_IFLOCAL;
break;
default:
- strcpy(errbuf, "Source type not supported");
+ strlcpy(errbuf, "Source type not supported", PCAP_ERRBUF_SIZE);
return NULL;
}
return fp;
return -1;
}
- strcat(hostlist, hoststr);
+ strlcat(hostlist, hoststr, PCAP_ERRBUF_SIZE);
hostlist[len - 1] = sep;
hostlist[len] = 0;
return -2;
}
- token = strtok(temphostlist, sep);
+ token = strltok(temphostlist, sep);
/* it avoids a warning in the compilation ('addrinfo used but not initialized') */
addrinfo = NULL;
SOCK_ASSERT(errbuf, 1);
/* Get next token */
- token = strtok(NULL, sep);
+ token = strltok(NULL, sep);
continue;
}
addrinfo = NULL;
/* Get next token */
- token = strtok(NULL, sep);
+ token = strltok(NULL, sep);
}
if (addrinfo)
(memcmp(&((struct sockaddr_in6 *) sockaddr)->sin6_addr, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(struct in6_addr)) == 0))
{
if (address)
- strncpy(address, SOCKET_NAME_NULL_DAD, addrlen);
+ strlcpy(address, SOCKET_NAME_NULL_DAD, addrlen);
return retval;
}
}
if (address)
{
- strncpy(address, SOCKET_NO_NAME_AVAILABLE, addrlen);
+ strlcpy(address, SOCKET_NO_NAME_AVAILABLE, addrlen);
address[addrlen - 1] = 0;
}
if (port)
{
- strncpy(port, SOCKET_NO_PORT_AVAILABLE, portlen);
+ strlcpy(port, SOCKET_NO_PORT_AVAILABLE, portlen);
port[portlen - 1] = 0;
}