blob: e994f2840292c70b259cd0fa6098164276656f83 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001From 6ed1eb8829dee351b54e183bc42c007cb306aaa5 Mon Sep 17 00:00:00 2001
2From: Zhang Xiao <xiao.zhang@windriver.com>
3Date: Wed, 11 Jun 2014 14:01:16 +0800
4Subject: [PATCH] tftp-hpa: bug fix on separated CR and LF
5
6In ascii mode, if the CR and LF was separated into different transfer
7blocks, LF will be just dropped instead of replacing the previous CR.
8Add a checking on the first character to fix it.
9
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060010Upstream-Status: Pending
Patrick Williamsb48b7b42016-08-17 15:04:38 -050011
12Signed-off-by: Zhang Xiao <xiao.zhang@windriver.com>
13---
14 common/tftpsubs.c | 8 ++++++++
15 1 file changed, 8 insertions(+)
16
17diff --git a/common/tftpsubs.c b/common/tftpsubs.c
18index b4d4ffe..b4ea3f2 100644
19--- a/common/tftpsubs.c
20+++ b/common/tftpsubs.c
21@@ -207,6 +207,14 @@ int write_behind(FILE * file, int convert)
22 p = buf;
23 ct = count;
24 count = 0;
25+
26+ /* Check the first character together with prevchar */
27+ c = *p;
28+ if ((prevchar == '\r') && (c == '\n')) {
29+ lseek(fileno(file), -1, SEEK_CUR);
30+ count++;
31+ }
32+
33 while (ct--) { /* loop over the buffer */
34 c = *p++; /* pick up a character */
35 if (prevchar == '\r') { /* if prev char was cr */
36--
371.8.5.2.233.g932f7e4
38