diff options
author | Yang Luo <hsluoyz@qq.com> | 2016-07-29 16:44:59 +0800 |
---|---|---|
committer | Yang Luo <hsluoyz@qq.com> | 2016-07-29 16:44:59 +0800 |
commit | 5074e7d95b82853668e05445399ee119ef7d0ad8 (patch) | |
tree | 6feb476df1e272d707098cd96294c73086dd679d /pcap-new.c | |
parent | 2fc98f9a355a97a69f8701cd7822ed5d6537c579 (diff) |
Fix MSVC compile warnings on the WinPcap specific code.
Diffstat (limited to 'pcap-new.c')
-rw-r--r-- | pcap-new.c | 54 |
1 files changed, 27 insertions, 27 deletions
@@ -166,7 +166,7 @@ int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **all } /* 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 */ @@ -189,7 +189,7 @@ int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **all } /* 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; } @@ -312,7 +312,7 @@ int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **all return -1; } - strncpy(dev->name, tmpstring, stringlen); + strlcpy(dev->name, tmpstring, stringlen); dev->name[stringlen] = 0; @@ -331,7 +331,7 @@ int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **all } /* 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); } @@ -514,7 +514,7 @@ int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **all } /* 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) @@ -546,7 +546,7 @@ int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **all } /* 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); @@ -668,10 +668,10 @@ int pcap_createsrcstr(char *source, int type, const char *host, const char *port { 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 @@ -683,27 +683,27 @@ int pcap_createsrcstr(char *source, int type, const char *host, const char *port 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 { @@ -712,17 +712,17 @@ int pcap_createsrcstr(char *source, int type, const char *host, const char *port } 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; } @@ -801,7 +801,7 @@ int pcap_parsesrcstr(const char *source, int *type, char *host, char *port, char { /* 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 */ @@ -815,9 +815,9 @@ int pcap_parsesrcstr(const char *source, int *type, char *host, char *port, char } 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; @@ -830,7 +830,7 @@ int pcap_parsesrcstr(const char *source, int *type, char *host, char *port, char */ if (tmpname[0]) { - strcpy(name, tmpname); + strlcpy(name, tmpname, PCAP_BUF_SIZE); } else { @@ -851,7 +851,7 @@ int pcap_parsesrcstr(const char *source, int *type, char *host, char *port, char if (*ptr) { if (name) - strncpy(name, ptr, PCAP_BUF_SIZE); + strlcpy(name, ptr, PCAP_BUF_SIZE); if (type) *type = PCAP_SRC_FILE; @@ -872,7 +872,7 @@ int pcap_parsesrcstr(const char *source, int *type, char *host, char *port, char if ((source) && (*source)) { if (name) - strncpy(name, source, PCAP_BUF_SIZE); + strlcpy(name, source, PCAP_BUF_SIZE); if (type) *type = PCAP_SRC_IFLOCAL; @@ -979,7 +979,7 @@ pcap_t *pcap_open(const char *source, int snaplen, int flags, int read_timeout, break; default: - strcpy(errbuf, "Source type not supported"); + strlcpy(errbuf, "Source type not supported", PCAP_ERRBUF_SIZE); return NULL; } return fp; @@ -1254,7 +1254,7 @@ int pcap_remoteact_list(char *hostlist, char sep, int size, char *errbuf) return -1; } - strcat(hostlist, hoststr); + strlcat(hostlist, hoststr, PCAP_ERRBUF_SIZE); hostlist[len - 1] = sep; hostlist[len] = 0; |