Message ID | 20200928123010.34222-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | channel_curl: Strip CR in addition to LF from headers | expand |
On 28.09.20 14:30, Christian Storm wrote: > Commit 09fd046 introduced stripping LF from returned headers > for easier processing. However, some servers send CR+LF, so > strip LF, CR, and CR+LF. > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > corelib/channel_curl.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c > index 3339f91..c329a14 100644 > --- a/corelib/channel_curl.c > +++ b/corelib/channel_curl.c > @@ -419,7 +419,8 @@ static size_t channel_callback_headers(char *buffer, size_t size, size_t nitems, > key = info; > val = p + 1; /* Next char after ':' */ > while(isspace((unsigned char)*val)) val++; > - /* Remove '\n' from header's value. */ > + /* Remove '\n', '\r', and '\r\n' from header's value. */ > + *strchrnul(val, '\r') = '\0'; > *strchrnul(val, '\n') = '\0'; > /* For multiple same-key headers, only the last is saved. */ > dict_set_value(dict, key, val); > Acked-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
On 28.09.20 14:30, Christian Storm wrote: > Commit 09fd046 introduced stripping LF from returned headers > for easier processing. However, some servers send CR+LF, so > strip LF, CR, and CR+LF. > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > corelib/channel_curl.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c > index 3339f91..c329a14 100644 > --- a/corelib/channel_curl.c > +++ b/corelib/channel_curl.c > @@ -419,7 +419,8 @@ static size_t channel_callback_headers(char *buffer, size_t size, size_t nitems, > key = info; > val = p + 1; /* Next char after ':' */ > while(isspace((unsigned char)*val)) val++; > - /* Remove '\n' from header's value. */ > + /* Remove '\n', '\r', and '\r\n' from header's value. */ > + *strchrnul(val, '\r') = '\0'; > *strchrnul(val, '\n') = '\0'; > /* For multiple same-key headers, only the last is saved. */ > dict_set_value(dict, key, val); > Applied to -master, thanks ! Best regards, Stefano Babic
diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 3339f91..c329a14 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -419,7 +419,8 @@ static size_t channel_callback_headers(char *buffer, size_t size, size_t nitems, key = info; val = p + 1; /* Next char after ':' */ while(isspace((unsigned char)*val)) val++; - /* Remove '\n' from header's value. */ + /* Remove '\n', '\r', and '\r\n' from header's value. */ + *strchrnul(val, '\r') = '\0'; *strchrnul(val, '\n') = '\0'; /* For multiple same-key headers, only the last is saved. */ dict_set_value(dict, key, val);
Commit 09fd046 introduced stripping LF from returned headers for easier processing. However, some servers send CR+LF, so strip LF, CR, and CR+LF. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- corelib/channel_curl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)