summaryrefslogtreecommitdiffstats
path: root/package/wireless-tools/patches/004-increase_iwlist_buffer.patch
blob: f2fdb124e694d0a3511afe3063664744032b283a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--- a/iwlist.c
+++ b/iwlist.c
@@ -792,7 +792,8 @@ print_scanning_info(int		skfd,
 	  if(iw_get_ext(skfd, ifname, SIOCGIWSCAN, &wrq) < 0)
 	    {
 	      /* Check if buffer was too small (WE-17 only) */
-	      if((errno == E2BIG) && (range.we_version_compiled > 16))
+	      if((errno == E2BIG) && (range.we_version_compiled > 16)
+	         && (buflen < 0xFFFF))
 		{
 		  /* Some driver may return very large scan results, either
 		   * because there are many cells, or because they have many
@@ -808,6 +809,10 @@ print_scanning_info(int		skfd,
 		  else
 		    buflen *= 2;
 
+                 /* wrq.u.data.length is 16 bits so max size is 65535 */
+                 if(buflen > 0xFFFF)
+                   buflen = 0xFFFF;
+
 		  /* Try again */
 		  goto realloc;
 		}
@@ -2152,6 +2157,7 @@ main(int	argc,
   char **args;			/* Command arguments */
   int count;			/* Number of arguments */
   const iwlist_cmd *iwcmd;
+  int goterr = 0;
 
   if(argc < 2)
     iw_usage(1);
@@ -2199,12 +2205,12 @@ main(int	argc,
 
   /* do the actual work */
   if (dev)
-    (*iwcmd->fn)(skfd, dev, args, count);
+    goterr = (*iwcmd->fn)(skfd, dev, args, count);
   else
     iw_enum_devices(skfd, iwcmd->fn, args, count);
 
   /* Close the socket. */
   iw_sockets_close(skfd);
 
-  return 0;
+  return goterr;
 }