diff libfdproto/ostr.c @ 752:9e9840ccf059

Attempt to handle more gracefully (invalid) AVPs that contain an empty octetstring
author Sebastien Decugis <sdecugis@nict.go.jp>
date Sat, 24 Sep 2011 09:45:14 +0200
parents 5d529eb0ad33
children 9beef9a09faa
line wrap: on
line diff
--- a/libfdproto/ostr.c	Thu Sep 22 21:10:00 2011 +0200
+++ b/libfdproto/ostr.c	Sat Sep 24 09:45:14 2011 +0200
@@ -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 @@
 		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 */
"Welcome to our mercurial repository"