Fix bug completeBER_n WRT too nested BER
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 21 May 2012 12:46:49 +0000 (14:46 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 21 May 2012 12:46:49 +0000 (14:46 +0200)
Function completeBER_n could return 0 (incomplete package) in case
where the BER package was considered too nested (return value of -2).

src/ber_any.c

index d5edc77..905b0c4 100644 (file)
@@ -109,10 +109,9 @@ int completeBER_n(const unsigned char *buf, int len, int level)
     {
         if (b[0] == 0 && b[1] == 0)
             break;
-        if (!(res = completeBER_n(b, len, level+1)))
-            return 0;
-        if (res == -1)
-            return -1;
+        res = completeBER_n(b, len, level+1);
+        if (res <= 0)
+            return res;
         b += res;
         len -= res;
     }