More bugfixes

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1646 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2009-03-27 00:06:28 +00:00
parent d200d5a6ba
commit 518a4e8c1f

View File

@ -303,6 +303,8 @@ static inline int wget_parseheaders(struct wget_s *ws)
* we parse it.
*/
if (ndx > 0) /* Should always be true */
{
if (ws->line[0] == ISO_cr)
{
/* This was the last header line (i.e., and empty "\r\n"), so
@ -314,7 +316,9 @@ static inline int wget_parseheaders(struct wget_s *ws)
goto exit;
}
ws->line[ndx] = '\0';
/* Truncate the trailing \r\n */
ws->line[ndx-1] = '\0';
/* Check for specific HTTP header fields. */
@ -328,7 +332,7 @@ static inline int wget_parseheaders(struct wget_s *ws)
{
*dest = 0;
}
strncpy(ws->mimetype, ws->line + strlen(g_httpcontenttype) - 1, sizeof(ws->mimetype));
strncpy(ws->mimetype, ws->line + strlen(g_httpcontenttype), sizeof(ws->mimetype));
}
else
#endif
@ -336,7 +340,7 @@ static inline int wget_parseheaders(struct wget_s *ws)
{
/* Save a pointer to the location */
char *dest = ws->line + strlen(g_httplocation) - 1;
char *dest = ws->line + strlen(g_httplocation);
/* Concatenate the hostname */
@ -366,9 +370,10 @@ static inline int wget_parseheaders(struct wget_s *ws)
ws->filename[CONFIG_NETUTILS_WEBCLIENT_MAXFILENAME-1] = '\0';
nvdbg("New hostname='%s' filename='%s'\n", ws->hostname, ws->filename);
}
}
/* We're done parsing, so we reset the pointer and start the
* next line.
/* We're done parsing this line, so we reset the index to the start
* of the next line.
*/
ndx = 0;