-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
strncpys in libpcap should be strlcp #5
Comments
Commit bf2270d addressed NULL termination part of this report in 2002. |
A sufficient scope of this request would be to check that all |
There were already some The |
Or in the activate routine; I've added that check in 1099050. |
and the libpcap configure script checks for |
Done in pcap-bpf.c as well, with various commits. I'll look at cleaning up the (ancient) remaining code that's using |
This issue was opened on SourceForge in 2002. Resolving it properly would take to convert the remaining 10 instances of |
Yes. Just for the lulz, I took a look at various bits of network-interface-ioctl code in the Illumos kernel, treating it as a possible proxy for the Solaris kernel, and it's... inconsistent in how it handles the name field in network interface ioctl structures. My inclination would be to null-terminate them by using |
Would reporting the inconsistencies you found make things simpler? Some of the bugs I reported about illumos got fixed, or at least acknowledged. |
In the illumos-gate repository if (ipip->ipi_cmd_type == IF_CMD) {
/* This a old style SIOC[GS]IF* command */
ifr = (struct ifreq *)mp1->b_rptr;
/*
* Null terminate the string to protect against buffer
* overrun. String was generated by user code and may not
* be trusted.
*/
ifr->ifr_name[IFNAMSIZ - 1] = '\0';
name = ifr->ifr_name;
ci->ci_sin = (sin_t *)&ifr->ifr_addr;
ci->ci_sin6 = NULL;
ci->ci_lifr = (struct lifreq *)ifr;
} else {
/* This a new style SIOC[GS]LIF* command */
ASSERT(ipip->ipi_cmd_type == LIF_CMD);
lifr = (struct lifreq *)mp1->b_rptr;
/*
* Null terminate the string to protect against buffer
* overrun. String was generated by user code and may not
* be trusted.
*/
lifr->lifr_name[LIFNAMSIZ - 1] = '\0';
name = lifr->lifr_name;
ci->ci_sin = (sin_t *)&lifr->lifr_addr;
ci->ci_sin6 = (sin6_t *)&lifr->lifr_addr;
ci->ci_lifr = lifr;
} If this sanitizes every relevant |
This reduces the problem space of GH #5.
Furthermore, Commit 6b6d692 removes |
This addresses the remaining part of GH #5. Compile-tested on AIX 7.1.
Commit c3e5d0c removes |
Converted from SourceForge issue 599847, submitted by donhatch
All strncpys in libpcap should be changed to strlcpy.
Also, there is this strange thing in pcap-snit.c:
strncpy(ifr.ifr_name, device,
sizeof(ifr.ifr_name));
ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = ' ';
I don't understand why the space character is used
here; it seems to me
that it should be '\0'
(which will of course be unecessary when this strncpy
is changed to strlcpy).
The text was updated successfully, but these errors were encountered: