wireless-tools: Attempt to fix memory leak
We would leak all the results for all the scans. At some point in time the kernel OOM would kick-in and kill the process. Enable building with -ggdb3 for debug symbols and remmeber the old list head so we can free it. ==32240== 756 bytes in 3 blocks are definitely lost in loss record 7 of 8 ==32240== at 0x40291CC: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==32240== by 0x804BCF5: iw_process_scanning_token (iwlib.c:3059) ==32240== by 0x804BCF5: iw_process_scan (iwlib.c:3255) ==32240== by 0x804BEAF: iw_scan (iwlib.c:3310) ==32240== by 0x8048FD8: scan_wifi (wifi2udp.c:72) ==32240== by 0x8048DB2: main (wifi2udp.c:143)
This commit is contained in:
parent
43d3a03b72
commit
e1298b0b9d
|
@ -10,11 +10,11 @@ Subject: [PATCH 1/1] Add wifi2udp program
|
|||
2 files changed, 149 insertions(+), 1 deletion(-)
|
||||
create mode 100644 wifi2udp.c
|
||||
|
||||
Index: wireless_tools.29/Makefile
|
||||
Index: wireless_tools.30/Makefile
|
||||
===================================================================
|
||||
--- wireless_tools.29.orig/Makefile 2014-09-08 17:27:45.000000000 +0200
|
||||
+++ wireless_tools.29/Makefile 2014-09-08 17:32:52.065211007 +0200
|
||||
@@ -48,7 +48,7 @@
|
||||
--- wireless_tools.30.orig/Makefile
|
||||
+++ wireless_tools.30/Makefile
|
||||
@@ -50,7 +50,7 @@ WEXT_HEADER = wireless.$(WE_VERSION).h
|
||||
# Targets to build
|
||||
STATIC=libiw.a
|
||||
DYNAMIC=libiw.so.$(WT_VERSION)
|
||||
|
@ -23,7 +23,16 @@ Index: wireless_tools.29/Makefile
|
|||
MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
|
||||
MANPAGES7=wireless.7
|
||||
MANPAGES5=iftab.5
|
||||
@@ -135,6 +135,8 @@
|
||||
@@ -105,7 +105,7 @@ endif
|
||||
|
||||
# Other flags
|
||||
CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
|
||||
- -Wpointer-arith -Wcast-qual -Winline -I.
|
||||
+ -Wpointer-arith -Wcast-qual -Winline -I. -ggdb3
|
||||
#CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
|
||||
DEPFLAGS=-MMD
|
||||
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
|
||||
@@ -137,6 +137,8 @@ ifrename: ifrename.o $(IWLIB)
|
||||
|
||||
macaddr: macaddr.o $(IWLIB)
|
||||
|
||||
|
@ -32,11 +41,11 @@ Index: wireless_tools.29/Makefile
|
|||
iwmulticall: iwmulticall.o
|
||||
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
Index: wireless_tools.29/wifi2udp.c
|
||||
Index: wireless_tools.30/wifi2udp.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ wireless_tools.29/wifi2udp.c 2014-09-08 17:30:08.217211001 +0200
|
||||
@@ -0,0 +1,146 @@
|
||||
--- /dev/null
|
||||
+++ wireless_tools.30/wifi2udp.c
|
||||
@@ -0,0 +1,149 @@
|
||||
+
|
||||
+#include <unistd.h>
|
||||
+#include <stdio.h>
|
||||
|
@ -122,6 +131,7 @@ Index: wireless_tools.29/wifi2udp.c
|
|||
+ char bssid[20];
|
||||
+ char line[1024];
|
||||
+ char essid_escaped[50];
|
||||
+ wireless_scan *old_result;
|
||||
+ iw_sawap_ntop(&result->ap_addr, bssid);
|
||||
+
|
||||
+ escape_essid(result->b.essid, essid_escaped, 50);
|
||||
|
@ -131,7 +141,9 @@ Index: wireless_tools.29/wifi2udp.c
|
|||
+ rc = sendto(sock, line, strlen(line), 0, (struct sockaddr*)&remote, sizeof(remote));
|
||||
+ if (rc == -1)
|
||||
+ printf("Failed to send message: %s\n", strerror(errno));
|
||||
+ old_result = result;
|
||||
+ result = result->next;
|
||||
+ free(old_result);
|
||||
+ }
|
||||
+ sleep(delay);
|
||||
+ }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
THISDIR := "${@os.path.dirname(bb.data.getVar('FILE', d, True))}"
|
||||
FILESPATH =. "${@base_set_filespath(["${THISDIR}/files"], d)}:"
|
||||
|
||||
PRINC="6"
|
||||
PRINC="7"
|
||||
|
||||
SRC_URI += "file://0001-Add-wifi2udp-program.patch \
|
||||
file://wifi2udp.service"
|
||||
|
|
Loading…
Reference in New Issue