Changeset 654 for pjproject/trunk


Ignore:
Timestamp:
Aug 6, 2006 2:11:52 PM (18 years ago)
Author:
bennylp
Message:

Change unescaping function in scanner and string.c to NOT unescape when '%' is not followed by hex digits.

Location:
pjproject/trunk/pjlib-util/src/pjlib-util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/src/pjlib-util/scanner.c

    r583 r654  
    304304    do { 
    305305        if (*s == '%') { 
    306             if (s+3 <= scanner->end) { 
    307                 /* This doesn't check if the hex digits are valid. 
    308                  * If they dont' it will produce garbage characters, but 
    309                  * no harm is done to the application (e.g. no illegal 
    310                  * memory access. 
    311                  */ 
     306            if (s+3 <= scanner->end && pj_isxdigit(*(s+1)) &&  
     307                pj_isxdigit(*(s+2)))  
     308            { 
    312309                *dst = (pj_uint8_t) ((pj_hex_digit_to_val(*(s+1)) << 4) + 
    313310                                      pj_hex_digit_to_val(*(s+2))); 
  • pjproject/trunk/pjlib-util/src/pjlib-util/string.c

    r67 r654  
    3535 
    3636    while (src != end) { 
    37         if (*src == '%' && src < end-2) { 
     37        if (*src == '%' && src < end-2 && pj_isxdigit(*(src+1)) &&  
     38            pj_isxdigit(*(src+2)))  
     39        { 
    3840            *dst = (pj_uint8_t) ((pj_hex_digit_to_val(*(src+1)) << 4) +  
    3941                                 pj_hex_digit_to_val(*(src+2))); 
Note: See TracChangeset for help on using the changeset viewer.