olsrd: security fixes for olsrd plugins
[feed/routing.git] / olsrd / patches / 002-hotfix-long-http-headers-txtinfo.patch
1 commit d68c96cf53f188030452aadec466aa6389e81511
2 Author: Henning Rogge <hrogge@gmail.com>
3 Date: Tue May 13 21:23:36 2014 +0200
4
5 Hotfix for much too long http headers
6
7 diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
8 index b56545d..2bcce41 100644
9 --- a/lib/txtinfo/src/olsrd_txtinfo.c
10 +++ b/lib/txtinfo/src/olsrd_txtinfo.c
11 @@ -301,8 +301,15 @@ ipc_action(int fd, void *data __attribute__ ((unused)), unsigned int flags __att
12 FD_ZERO(&rfds);
13 FD_SET((unsigned int)ipc_connection, &rfds); /* Win32 needs the cast here */
14 if (0 <= select(ipc_connection + 1, &rfds, NULL, NULL, &tv)) {
15 - char requ[128];
16 - ssize_t s = recv(ipc_connection, (void *)&requ, sizeof(requ), 0); /* Win32 needs the cast here */
17 + char requ[1024];
18 + ssize_t s = recv(ipc_connection, (void *)&requ, sizeof(requ)-1, 0); /* Win32 needs the cast here */
19 +
20 + if (s == sizeof(requ)-1) {
21 + /* input was much too long, just skip the rest */
22 + char dummy[1024];
23 +
24 + while (recv(ipc_connection, (void *)&dummy, sizeof(dummy), 0) == sizeof(dummy), 0);
25 + }
26 if (0 < s) {
27 requ[s] = 0;
28 /* To print out neighbours only on the Freifunk Status
29 @@ -329,6 +336,7 @@ ipc_action(int fd, void *data __attribute__ ((unused)), unsigned int flags __att
30 if (0 != strstr(requ, "/ver")) send_what |= SIW_VERSION;
31 }
32 }
33 +
34 if ( send_what == 0 ) send_what = SIW_ALL;
35 }
36