Wind River Support Network

HomeDefectsLIN5-18886
Fixed

LIN5-18886 : CLONE - tftp-hpa-5.0-fix-NOSAPCE-ACK.patch only partial fix

Created: Jun 11, 2014    Updated: Dec 19, 2017
Resolved Date: Jun 17, 2014
Previous ID: LIN4-31485
Found In Version: 5.0.1
Fix Version: 5.0.1.16
Severity: Standard
Applicable for: Wind River Linux 5
Component/s: Userspace

Description

tftp-hpa becomes broken under the change introduced in the patch:

WR/wrlinux-4/layers/updates/RCPL-4.3-WRL.0022/wrll-userspace/networking/dist/tftp-hpa/patches/tftp-hpa-5.0-fix-NOSAPCE-ACK.patch

--- a/common/tftpsubs.c 2013-05-16 11:00:57.674129344 +0800
+++ b/common/tftpsubs.c 2013-05-16 11:00:39.931521120 +0800
@@ -206,20 +206,22 @@ int write_behind(FILE * file, int conver
 
     p = buf;
     ct = count;
+    count = 0;
     while (ct--) {              /* loop over the buffer */
         c = *p++;               /* pick up a character */
         if (prevchar == '\r') { /* if prev char was cr */
             if (c == '\n')      /* if have cr,lf then just */
-                fseek(file, -1, 1);     /* smash lf on top of the cr */
+                count = count - 1;
             else if (c == '\0') /* if have cr,nul then */
                 goto skipit;    /* just skip over the putc */
             /* else just fall through and allow it */
         }
-        putc(c, file);
+        buf[count] = c;
+        count ++;
       skipit:
         prevchar = c;
     }
-    return count;
+    return write(fileno(file), buf, count);
 }



The problem:
 if '\r' happens at the end of tftp transfer block and '\n' at the beginning of the next tftp transfer block then
 the previous '\r' is not replaced by '\n'.

 The introduced changes do not handle this case properly.
 The current buffer is modified only not the previous written file.

The previous file should also be corrected.

Steps to Reproduce

Transfer a file where a carriage return (\r) is at the end of a block and a new line (\n) is the first character of the following block.

Other Downloads


Live chat
Online