Commit a40d656d authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Attempt to handle more gracefully (invalid) AVPs that contain an empty octetstring

parent d21c3a41
......@@ -1770,12 +1770,8 @@ static int parsedict_do_avp(struct dictionary * dict, struct avp * avp, int mand
return EBADMSG;
} );
avp->avp_storage.os.len = avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags );
if (avp->avp_storage.os.len) {
CHECK_MALLOC( avp->avp_storage.os.data = os0dup(avp->avp_source, avp->avp_storage.os.len) );
avp->avp_mustfreeos = 1;
} else {
avp->avp_storage.os.data = NULL;
}
CHECK_MALLOC( avp->avp_storage.os.data = os0dup(avp->avp_source, avp->avp_storage.os.len) );
avp->avp_mustfreeos = 1;
break;
case AVP_TYPE_INTEGER32:
......
......@@ -44,7 +44,8 @@
os0_t os0dup_int(os0_t s, size_t l) {
os0_t r;
CHECK_MALLOC_DO( r = malloc(l+1), return NULL );
memcpy(r, s, l); /* this might be faster than a strcpy or strdup because it can work with 32 or 64b blocks */
if (l)
memcpy(r, s, l); /* this might be faster than a strcpy or strdup because it can work with 32 or 64b blocks */
r[l] = '\0';
return r;
}
......@@ -57,7 +58,7 @@ int fd_os_cmp_int(uint8_t * os1, size_t os1sz, uint8_t * os2, size_t os2sz)
return -1;
if (os1sz > os2sz)
return 1;
return memcmp(os1, os2, os1sz);
return os1sz ? memcmp(os1, os2, os1sz) : 0;
}
/* a local version of tolower() that does not depend on LC_CTYPE locale */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment