unbound: moved to github
[packages.git] / net / redir / patches / 06_fix_shaper_buffer.patch
1 diff -Nur a/redir.c b/redir.c
2 --- a/redir.c   2005-10-22 23:20:05.235901424 -0400
3 +++ b/redir.c   2005-10-22 23:22:20.198384008 -0400
4 @@ -259,7 +259,7 @@
5  #endif
6            int *transproxy,
7  #ifndef NO_SHAPER
8 -           unsigned int * bufsize,
9 +           unsigned int * bufsizeout,
10             int * max_bandwidth,
11             int * random_wait,
12             int * wait_in_out,
13 @@ -366,7 +366,7 @@
14  
15  #ifndef NO_SHAPER
16                  case 'z':
17 -                  *bufsize = (unsigned int)atol(optarg);
18 +                  *bufsizeout = (unsigned int)atol(optarg);
19                    break;
20   
21                  case 'm':
22 @@ -593,7 +593,7 @@
23         unsigned long bytes_in = 0;
24         unsigned long bytes_out = 0;
25         unsigned int start_time, end_time;
26 -       char buf[bufsize];
27 +       char* buf = malloc(bufsize);
28  
29         /* Record start time */
30         start_time = (unsigned int) time(NULL);
31 @@ -632,7 +632,7 @@
32                 }
33  
34                 if(FD_ISSET(insock, &c_iofds)) {
35 -                       if((bytes = read(insock, buf, sizeof(buf))) <= 0)
36 +                       if((bytes = read(insock, buf, bufsize)) <= 0)
37                                 break;
38  #ifndef NO_FTP
39                         if (ftp & FTP_PORT)
40 @@ -647,7 +647,7 @@
41                         bytes_out += bytes;
42                 }
43                 if(FD_ISSET(outsock, &c_iofds)) {
44 -                       if((bytes = read(outsock, buf, sizeof(buf))) <= 0)
45 +                       if((bytes = read(outsock, buf, bufsize)) <= 0)
46                                 break;
47                         /* if we're correcting for PASV on ftp redirections, then
48                            fix buf and bytes to have the new address, among other
49 @@ -684,6 +684,7 @@
50                 syslog(LOG_NOTICE, "disconnect %d secs, %ld in %ld out",
51                        (end_time - start_time), bytes_in, bytes_out);
52         }
53 +       free(buf);
54         return;
55  }
56