mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-18 22:06:04 +01:00
9f0af0e072
Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
63 lines
1.8 KiB
Text
63 lines
1.8 KiB
Text
#! /bin/sh /usr/share/dpatch/dpatch-run
|
|
## 06_fix_shaper_buffer.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
|
|
##
|
|
## All lines beginning with `## DP:' are a description of the patch.
|
|
## DP: properly allocate copyloop buffer
|
|
|
|
@DPATCH@
|
|
diff -urNad redir-2.2.1~/redir.c redir-2.2.1/redir.c
|
|
--- redir-2.2.1~/redir.c 2005-10-22 23:20:05.235901424 -0400
|
|
+++ redir-2.2.1/redir.c 2005-10-22 23:22:20.198384008 -0400
|
|
@@ -260,7 +260,7 @@
|
|
#endif
|
|
int *transproxy,
|
|
#ifndef NO_SHAPER
|
|
- unsigned int * bufsize,
|
|
+ unsigned int * bufsizeout,
|
|
int * max_bandwidth,
|
|
int * random_wait,
|
|
int * wait_in_out,
|
|
@@ -367,7 +367,7 @@
|
|
|
|
#ifndef NO_SHAPER
|
|
case 'z':
|
|
- *bufsize = (unsigned int)atol(optarg);
|
|
+ *bufsizeout = (unsigned int)atol(optarg);
|
|
break;
|
|
|
|
case 'm':
|
|
@@ -594,7 +594,7 @@
|
|
unsigned long bytes_in = 0;
|
|
unsigned long bytes_out = 0;
|
|
unsigned int start_time, end_time;
|
|
- char buf[bufsize];
|
|
+ char* buf = malloc(bufsize);
|
|
|
|
/* Record start time */
|
|
start_time = (unsigned int) time(NULL);
|
|
@@ -637,7 +637,7 @@
|
|
}
|
|
|
|
if(FD_ISSET(insock, &c_iofds)) {
|
|
- if((bytes = read(insock, buf, sizeof(buf))) <= 0)
|
|
+ if((bytes = read(insock, buf, bufsize)) <= 0)
|
|
break;
|
|
#ifndef NO_FTP
|
|
if (ftp & FTP_PORT)
|
|
@@ -652,7 +652,7 @@
|
|
bytes_out += bytes;
|
|
}
|
|
if(FD_ISSET(outsock, &c_iofds)) {
|
|
- if((bytes = read(outsock, buf, sizeof(buf))) <= 0)
|
|
+ if((bytes = read(outsock, buf, bufsize)) <= 0)
|
|
break;
|
|
/* if we're correcting for PASV on ftp redirections, then
|
|
fix buf and bytes to have the new address, among other
|
|
@@ -689,6 +689,7 @@
|
|
syslog(LOG_NOTICE, "disconnect %d secs, %ld in %ld out",
|
|
(end_time - start_time), bytes_in, bytes_out);
|
|
}
|
|
+ free(buf);
|
|
return;
|
|
}
|
|
|