Commit 42614238 42614238e0a5b9b56f37c3107d5f1d653afbc3d4 by Alain Magloire

header.c

overrun corrected
1 parent d3e3053a
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
26 #include <stdlib.h> 26 #include <stdlib.h>
27 #include <errno.h> 27 #include <errno.h>
28 28
29 static int header_parse (header_t h, const char *blurb, size_t len); 29 static int header_parse (header_t h, const char *blurb, int len);
30 static int header_read (istream_t is, char *buf, size_t buflen, 30 static int header_read (istream_t is, char *buf, size_t buflen,
31 off_t off, ssize_t *pnread); 31 off_t off, ssize_t *pnread);
32 static int header_write (ostream_t os, const char *buf, size_t buflen, 32 static int header_write (ostream_t os, const char *buf, size_t buflen,
...@@ -120,7 +120,7 @@ header_destroy (header_t *ph, void *owner) ...@@ -120,7 +120,7 @@ header_destroy (header_t *ph, void *owner)
120 * on how to handle the case. 120 * on how to handle the case.
121 */ 121 */
122 static int 122 static int
123 header_parse (header_t header, const char *blurb, size_t len) 123 header_parse (header_t header, const char *blurb, int len)
124 { 124 {
125 char *header_end; 125 char *header_end;
126 char *header_start; 126 char *header_start;
...@@ -153,7 +153,7 @@ header_parse (header_t header, const char *blurb, size_t len) ...@@ -153,7 +153,7 @@ header_parse (header_t header, const char *blurb, size_t len)
153 else 153 else
154 { 154 {
155 len -= (header_end - header_start2 + 1); 155 len -= (header_end - header_start2 + 1);
156 if (len == 0) 156 if (len < 0)
157 { 157 {
158 header_end = NULL; 158 header_end = NULL;
159 break; 159 break;
...@@ -183,8 +183,8 @@ header_parse (header_t header, const char *blurb, size_t len) ...@@ -183,8 +183,8 @@ header_parse (header_t header, const char *blurb, size_t len)
183 && strncmp (header_start, "From ", 5) == 0) 183 && strncmp (header_start, "From ", 5) == 0)
184 { 184 {
185 header->hdr[header->hdr_count - 1].fn = header_start; 185 header->hdr[header->hdr_count - 1].fn = header_start;
186 header->hdr[header->hdr_count - 1].fn_end = header_start + 6; 186 header->hdr[header->hdr_count - 1].fn_end = header_start + 4;
187 header->hdr[header->hdr_count - 1].fv = header_start + 6; 187 header->hdr[header->hdr_count - 1].fv = header_start + 5;
188 header->hdr[header->hdr_count - 1].fv_end = header_end; 188 header->hdr[header->hdr_count - 1].fv_end = header_end;
189 } 189 }
190 else 190 else
......