#undef NDEBUG
[util-vserver.git] / util-vserver / lib / bcaps-v13.c
index 6918158..6a0a6db 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/capability.h>
 
 #include <string.h>
+#include <strings.h>
 #include <assert.h>
 
 #ifndef CAP_QUOTACTL
@@ -70,8 +71,9 @@ static struct Mapping_uint64 const VALUES[] = {
 inline static char const *
 removePrefix(char const *str, size_t *len)
 {
-  if (strncasecmp("cap_", str, 4)==0) {
-    if (len && *len) *len -= 4;
+  if ((len==0 || *len==0 || *len>4) &&
+      strncasecmp("cap_", str, 4)==0) {
+    if (len && *len>4) *len -= 4;
     return str+4;
   }
   else