Commit 78c07ee
committed
Linux: Fix propagation of getprotobyname_r() errors.
pcap_nametoproto(), when Linux getprotobyname_r() fails, returns 0 to
fail quickly similarly to pcap_nametonetaddr() and pcap_nametoport().
However, the correct way for pcap_nametoproto() to fail is to return
PROTO_UNDEF. This is why on a Linux host with GNU libc and without the
/etc/protocols file pcap_nametoproto() and subsequently lookup_proto()
fail to fail, then pcap_compile() produces incorrect filter programs for
"proto NAME", "protochain NAME" and variations thereof:
checking whether getprotobyname_r is declared... yes
checking for the Linux getprotobyname_r()... yes
checking if features.h defines __GLIBC__... yes
@@ -1,6 +1,6 @@
(000) ldh [12]
(001) jeq #0x800 jt 2 jf 5
(002) ldb [23]
-(003) jeq #0x6 jt 4 jf 5
+(003) jeq #0x0 jt 4 jf 5
(004) ret #262144
(005) ret #0
Return the correct error value to fix this and discuss the outputs of
GNU getprotobyname_r() in a comment.
This bug manifested in an s390x Debian 12 container provided by OSU OSL.1 parent 3d05686 commit 78c07ee
2 files changed
+16
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
494 | 508 | | |
495 | 509 | | |
496 | 510 | | |
497 | 511 | | |
498 | 512 | | |
499 | | - | |
| 513 | + | |
500 | 514 | | |
501 | 515 | | |
502 | 516 | | |
| |||
0 commit comments