diff options
| author | Jinfeng Wang <jinfeng.wang.cn@windriver.com> | 2026-04-10 15:05:08 +0800 |
|---|---|---|
| committer | Anuj Mittal <anuj.mittal@oss.qualcomm.com> | 2026-04-15 14:12:18 +0530 |
| commit | f3e47be00a48203722057ed36d6fc0878a447000 (patch) | |
| tree | 24e4cfc712b2c2faa809d29f31e90b3e1d800277 | |
| parent | 9757d0151b92601c4c6fd05baf7e328afa000213 (diff) | |
| download | meta-openembedded-f3e47be00a48203722057ed36d6fc0878a447000.tar.gz | |
nmap: rename enum PCAP_SOCKET
The enum PCAP_SOCKET conflicts with the PCAP_SOCKET macro introduced in
libpcap 1.10.5. Use ifdefs to handle both old and new libpcap versions,
renaming the enum to NM_PCAP_SOCKET when the PCAP_SOCKET macro is defined.
Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com>
Signed-off-by: Anuj Mittal <anuj.mittal@oss.qualcomm.com>
| -rw-r--r-- | meta-oe/recipes-security/nmap/files/nmap-rename-enum-PCAP_SOCKET.patch | 81 | ||||
| -rw-r--r-- | meta-oe/recipes-security/nmap/nmap_7.80.bb | 1 |
2 files changed, 82 insertions, 0 deletions
diff --git a/meta-oe/recipes-security/nmap/files/nmap-rename-enum-PCAP_SOCKET.patch b/meta-oe/recipes-security/nmap/files/nmap-rename-enum-PCAP_SOCKET.patch new file mode 100644 index 0000000000..fd10f21a8f --- /dev/null +++ b/meta-oe/recipes-security/nmap/files/nmap-rename-enum-PCAP_SOCKET.patch | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | From 4b0a7a2ca9fb9019327f61da1e0ca5e72aec89e4 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jinfeng Wang <jinfeng.wang.cn@windriver.com> | ||
| 3 | Date: Fri, 10 Apr 2026 11:08:48 +0800 | ||
| 4 | Subject: [PATCH] nmap: fix PCAP_SOCKET enum conflict with libpcap >= 1.10.5 | ||
| 5 | |||
| 6 | The enum PCAP_SOCKET conflicts with the PCAP_SOCKET macro introduced in | ||
| 7 | libpcap 1.10.5 and fails to compile: | ||
| 8 | |||
| 9 | In file included from /path_to/tmp-glibc/work/corei7-64-wrs-linux/nmap/7.80/recipe-sysroot/usr/include/pcap/pcap.h:130, | ||
| 10 | from /path_to/tmp-glibc/work/corei7-64-wrs-linux/nmap/7.80/recipe-sysroot/usr/include/pcap.h:43, | ||
| 11 | from tcpip.h:140, | ||
| 12 | from nse_nsock.cc:4: | ||
| 13 | nse_nsock.cc:36:3: error: expected identifier before 'int' | ||
| 14 | 36 | PCAP_SOCKET = lua_upvalueindex(3), /* pcap socket metatable */ | ||
| 15 | | ^~~~~~~~~~~ | ||
| 16 | |||
| 17 | The enum PCAP_SOCKET is removed in nmap later version. But the removal commit | ||
| 18 | involves extra logic change, so just rename the enum PCAP_SOCKET to | ||
| 19 | NM_PCAP_SOCKET to make it work with libpcap >= 1.10.5. | ||
| 20 | |||
| 21 | Upstream-Status: Inappropriate [fix to work with libpcap >= 1.10.5] | ||
| 22 | |||
| 23 | Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com> | ||
| 24 | --- | ||
| 25 | nse_nsock.cc | 14 +++++++++++--- | ||
| 26 | 1 file changed, 11 insertions(+), 3 deletions(-) | ||
| 27 | |||
| 28 | diff --git a/nse_nsock.cc b/nse_nsock.cc | ||
| 29 | index df98666..db942e1 100644 | ||
| 30 | --- a/nse_nsock.cc | ||
| 31 | +++ b/nse_nsock.cc | ||
| 32 | @@ -33,7 +33,11 @@ | ||
| 33 | enum { | ||
| 34 | NSOCK_POOL = lua_upvalueindex(1), | ||
| 35 | NSOCK_SOCKET = lua_upvalueindex(2), /* nsock socket metatable */ | ||
| 36 | +#ifdef PCAP_SOCKET | ||
| 37 | + NM_PCAP_SOCKET = lua_upvalueindex(3), /* pcap socket metatable */ | ||
| 38 | +#else | ||
| 39 | PCAP_SOCKET = lua_upvalueindex(3), /* pcap socket metatable */ | ||
| 40 | +#endif | ||
| 41 | THREAD_SOCKETS = lua_upvalueindex(4), /* <Thread, Table of Sockets (keys)> */ | ||
| 42 | CONNECT_WAITING = lua_upvalueindex(5), /* Threads waiting to lock */ | ||
| 43 | KEY_PCAP = lua_upvalueindex(6) /* Keys to pcap sockets */ | ||
| 44 | @@ -1026,7 +1030,11 @@ static int l_pcap_open (lua_State *L) | ||
| 45 | nsock_iod_delete(*nsiod, NSOCK_PENDING_ERROR); | ||
| 46 | luaL_error(L, "can't open pcap reader on %s", device); | ||
| 47 | } | ||
| 48 | +#ifdef PCAP_SOCKET | ||
| 49 | + lua_pushvalue(L, NM_PCAP_SOCKET); | ||
| 50 | +#else | ||
| 51 | lua_pushvalue(L, PCAP_SOCKET); | ||
| 52 | +#endif | ||
| 53 | lua_setmetatable(L, -2); | ||
| 54 | lua_pushvalue(L, 7); /* the pcap socket key */ | ||
| 55 | lua_pushvalue(L, -2); /* the pcap socket nsiod */ | ||
| 56 | @@ -1134,7 +1142,7 @@ LUALIB_API int luaopen_nsock (lua_State *L) | ||
| 57 | /* library upvalues */ | ||
| 58 | nsock_pool nsp = new_pool(L); /* NSOCK_POOL */ | ||
| 59 | lua_newtable(L); /* NSOCK_SOCKET */ | ||
| 60 | - lua_newtable(L); /* PCAP_SOCKET */ | ||
| 61 | + lua_newtable(L); /* NM_PCAP_SOCKET or PCAP_SOCKET depending on libpcap version */ | ||
| 62 | nseU_weaktable(L, 0, MAX_PARALLELISM, "k"); /* THREAD_SOCKETS */ | ||
| 63 | nseU_weaktable(L, 0, 1000, "k"); /* CONNECT_WAITING */ | ||
| 64 | nseU_weaktable(L, 0, 0, "v"); /* KEY_PCAP */ | ||
| 65 | @@ -1154,11 +1162,11 @@ LUALIB_API int luaopen_nsock (lua_State *L) | ||
| 66 | lua_pop(L, 1); /* NSOCK_SOCKET */ | ||
| 67 | |||
| 68 | /* Create the nsock pcap metatable */ | ||
| 69 | - lua_pushvalue(L, top+3); /* PCAP_SOCKET */ | ||
| 70 | + lua_pushvalue(L, top+3); /* NM_PCAP_SOCKET or PCAP_SOCKET depending on libpcap version */ | ||
| 71 | for (i = top+1; i <= top+nupvals; i++) lua_pushvalue(L, i); | ||
| 72 | lua_pushcclosure(L, pcap_gc, nupvals); | ||
| 73 | lua_setfield(L, top+3, "__gc"); | ||
| 74 | - lua_pop(L, 1); /* PCAP_SOCKET */ | ||
| 75 | + lua_pop(L, 1); /* NM_PCAP_SOCKET or PCAP_SOCKET depending on libpcap version */ | ||
| 76 | |||
| 77 | #if HAVE_OPENSSL | ||
| 78 | /* Set up the SSL certificate userdata code in nse_ssl_cert.cc. */ | ||
| 79 | -- | ||
| 80 | 2.34.1 | ||
| 81 | |||
diff --git a/meta-oe/recipes-security/nmap/nmap_7.80.bb b/meta-oe/recipes-security/nmap/nmap_7.80.bb index f9fe82a91d..18b1a50246 100644 --- a/meta-oe/recipes-security/nmap/nmap_7.80.bb +++ b/meta-oe/recipes-security/nmap/nmap_7.80.bb | |||
| @@ -12,6 +12,7 @@ SRC_URI = "http://nmap.org/dist/${BP}.tar.bz2 \ | |||
| 12 | file://0002-Fix-building-with-libc.patch \ | 12 | file://0002-Fix-building-with-libc.patch \ |
| 13 | file://0001-Make-ndiff-support-python3.patch \ | 13 | file://0001-Make-ndiff-support-python3.patch \ |
| 14 | file://0001-configure.ac-make-ndiff-depend-on-python3.patch \ | 14 | file://0001-configure.ac-make-ndiff-depend-on-python3.patch \ |
| 15 | file://nmap-rename-enum-PCAP_SOCKET.patch \ | ||
| 15 | " | 16 | " |
| 16 | 17 | ||
| 17 | SRC_URI[md5sum] = "d37b75b06d1d40f27b76d60db420a1f5" | 18 | SRC_URI[md5sum] = "d37b75b06d1d40f27b76d60db420a1f5" |
