summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-07-02 09:29:09 +0000
committerBenny Prijono <bennylp@teluu.com>2006-07-02 09:29:09 +0000
commitcb5e2e6455660972ad9fb32b9b2b13282637c104 (patch)
treee7e6618a049506e19a13fb42b1a3158f01360ecb
parenta07ddf779c3ed70101fabf03834b476d8261e3ac (diff)
Fixed bugs in scanner: (1) pj_cis_match() takes int argument, so when ASCII character above 127 is given, it will access the array with negative index, and (2) pj_scan_get_newline() may incorrectly eat two newlines when the second newline is a header continuation
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@570 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib-util/include/pjlib-util/scanner.h2
-rw-r--r--pjlib-util/src/pjlib-util/scanner.c20
2 files changed, 18 insertions, 4 deletions
diff --git a/pjlib-util/include/pjlib-util/scanner.h b/pjlib-util/include/pjlib-util/scanner.h
index ce9c625c..eb9135fe 100644
--- a/pjlib-util/include/pjlib-util/scanner.h
+++ b/pjlib-util/include/pjlib-util/scanner.h
@@ -156,7 +156,7 @@ PJ_DECL(void) pj_cis_invert( pj_cis_t *cis );
*
* @return Non-zero if match (not necessarily one).
*/
-PJ_INLINE(int) pj_cis_match( const pj_cis_t *cis, int c )
+PJ_INLINE(int) pj_cis_match( const pj_cis_t *cis, pj_uint8_t c )
{
return PJ_CIS_ISSET(cis, c);
}
diff --git a/pjlib-util/src/pjlib-util/scanner.c b/pjlib-util/src/pjlib-util/scanner.c
index df07a278..676fd026 100644
--- a/pjlib-util/src/pjlib-util/scanner.c
+++ b/pjlib-util/src/pjlib-util/scanner.c
@@ -401,9 +401,23 @@ PJ_DEF(void) pj_scan_get_newline( pj_scanner *scanner )
++scanner->line;
scanner->start_line = scanner->curptr;
- if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) {
- pj_scan_skip_whitespace(scanner);
- }
+ /**
+ * This probably is a bug, see PROTOS test #2480.
+ * This would cause scanner to incorrectly eat two new lines, e.g.
+ * when parsing:
+ *
+ * Content-Length: 120\r\n
+ * \r\n
+ * <space><space><space>...
+ *
+ * When pj_scan_get_newline() is called to parse the first newline
+ * in the Content-Length header, it will eat the second newline
+ * too because it thinks that it's a header continuation.
+ *
+ * if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) {
+ * pj_scan_skip_whitespace(scanner);
+ * }
+ */
}