From cdaeed5c56f8d11c342ae0fd562b222547fec96a Mon Sep 17 00:00:00 2001 From: Ignacio Bortolazzi Date: Sun, 18 Apr 2021 09:51:59 +0200 Subject: [PATCH] removed strlen also because it to the same problems of strcmp and changed to strnlen --- tiny-json.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tiny-json.c b/tiny-json.c index 541d5da..e2caebc 100644 --- a/tiny-json.c +++ b/tiny-json.c @@ -44,9 +44,11 @@ typedef struct jsonStaticPool_s { json_t const* json_getProperty( json_t const* obj, char const* property ) { json_t const* sibling; for( sibling = obj->u.c.child; sibling; sibling = sibling->sibling ){ - if (strlen(property)>MAX_PROPERTY_SIZE) + if (strnlen (property,MAX_PROPERTY_SIZE)==MAX_PROPERTY_SIZE) { - return 0; + if (property[MAX_PROPERTY_SIZE] !='\0'){ + return 0; + } } else{ if ( sibling->name && !strncmp( sibling->name, property,MAX_PROPERTY_SIZE) ){