From 6d3025be561bbc4287654aca1e967dbbc0d1b79a Mon Sep 17 00:00:00 2001 From: Alamy Liu Date: Thu, 27 Feb 2020 12:01:25 -0800 Subject: [PATCH 1/2] Allow escape/special character in string Consider the case of PEM certificate. This modification give it a chance to scan over those escape characters. e.g.: '\t': 0x09 '\n': 0x0A Signed-off-by: Alamy Liu --- tiny-json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiny-json.c b/tiny-json.c index b856690..8df171c 100644 --- a/tiny-json.c +++ b/tiny-json.c @@ -130,7 +130,7 @@ static unsigned char getCharFromUnicode( unsigned char const* str ) { static char* parseString( char* str ) { unsigned char* head = (unsigned char*)str; unsigned char* tail = (unsigned char*)str; - for( ; *head >= ' '; ++head, ++tail ) { + for( ; *head; ++head, ++tail ) { if ( *head == '\"' ) { *tail = '\0'; return (char*)++head; From bc67e17024ca89b4c5bc3f8c718132df8e48ba1a Mon Sep 17 00:00:00 2001 From: Alamy Liu Date: Fri, 28 Feb 2020 13:50:15 -0800 Subject: [PATCH 2/2] Fix ArmClang compiling error: isdigit() Signed-off-by: Alamy Liu --- tiny-json.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tiny-json.c b/tiny-json.c index 8df171c..ce27497 100644 --- a/tiny-json.c +++ b/tiny-json.c @@ -2,7 +2,7 @@ /* - + Licensed under the MIT License . SPDX-License-Identifier: MIT Copyright (c) 2016-2018 Rafa Garcia . @@ -24,7 +24,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + */ #include @@ -245,7 +245,7 @@ static char* nullValue( char* ptr, json_t* property ) { * @retval Null pointer if any error occur. */ static char* expValue( char* ptr ) { if ( *ptr == '-' || *ptr == '+' ) ++ptr; - if ( !isdigit( *ptr ) ) return 0; + if ( !isdigit( (int)(*ptr) ) ) return 0; ptr = goNum( ++ptr ); return ptr; } @@ -255,7 +255,7 @@ static char* expValue( char* ptr ) { * @retval Pointer to first non numerical after the string. If success. * @retval Null pointer if any error occur. */ static char* fraqValue( char* ptr ) { - if ( !isdigit( *ptr ) ) return 0; + if ( !isdigit( (int)(*ptr) ) ) return 0; ptr = goNum( ++ptr ); if ( !ptr ) return 0; return ptr; @@ -269,12 +269,12 @@ static char* fraqValue( char* ptr ) { * @retval Null pointer if any error occur. */ static char* numValue( char* ptr, json_t* property ) { if ( *ptr == '-' ) ++ptr; - if ( !isdigit( *ptr ) ) return 0; + if ( !isdigit( (int)(*ptr) ) ) return 0; if ( *ptr != '0' ) { ptr = goNum( ptr ); if ( !ptr ) return 0; } - else if ( isdigit( *++ptr ) ) return 0; + else if ( isdigit( (int)(*++ptr) ) ) return 0; property->type = JSON_INTEGER; if ( *ptr == '.' ) { ptr = fraqValue( ++ptr ); @@ -440,7 +440,7 @@ static char* goBlank( char* str ) { * @return The final pointer value or null pointer if the null character was found. */ static char* goNum( char* str ) { for( ; *str != '\0'; ++str ) { - if ( !isdigit( *str ) ) + if ( !isdigit( (int)(*str) ) ) return str; } return 0;