File: handle-ascii-conversions.patch

package info (click to toggle)
wput 0.6.2%2Bgit20130413-15
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,676 kB
  • sloc: ansic: 6,854; sh: 3,460; makefile: 72; sed: 16
file content (21 lines) | stat: -rw-r--r-- 789 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Description: Account for ASCII conversions when checking buffers
Author: 左刚 <zuogang@huawei.com>
Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=801949

--- a/src/ftp.c
+++ b/src/ftp.c
@@ -372,10 +372,12 @@
 			 * TODO NRV is enough, but maybe someone has time to play around... */
 			/* simply replace all \n by \r\n unless there is already an \n */
 			while( d < databuf + readbytes){
-				while ((p < convertbuf + DBUFSIZE) && (d < databuf + readbytes)){
-					if (*d == '\n' && *(d-1) != '\r'){
+				while ((p < convertbuf + sizeof(convertbuf)) && (d < databuf + readbytes)){
+					if (*d == '\n' && d != databuf && *(d-1) != '\r'){
 						*p++ = '\r';
 						crcount++;
+						if (p == convertbuf + sizeof(convertbuf))
+							break;
 					}
 					*p++ = *d++;
 				}