]> The Tcpdump Group git mirrors - libpcap/commitdiff
Use pcap_strlcpy() rather than strncpy() to fill in p->errbuf.
authorGuy Harris <[email protected]>
Thu, 3 Oct 2019 18:17:07 +0000 (11:17 -0700)
committerGuy Harris <[email protected]>
Thu, 3 Oct 2019 18:17:07 +0000 (11:17 -0700)
That's what we do elsewhere, as it guarantees that we null-terminate the
error message (not that we will ever overflow the buffer in that case,
as the error message is definitely shorter than the error buffer size).

pcap-dag.c

index 7de2963caf40bfeb7a231b0c4596727a9ec26bf6..928088feedc1475e2e9ec7988d597a527591fa66 100644 (file)
@@ -419,7 +419,8 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
                rlen = ntohs(header->rlen);
                if (rlen < dag_record_size)
                {
-                       strncpy(p->errbuf, "dag_read: record too small", PCAP_ERRBUF_SIZE);
+                       pcap_strlcpy(p->errbuf, "dag_read: record too small",
+                           PCAP_ERRBUF_SIZE);
                        return -1;
                }
                pd->dag_mem_bottom += rlen;