+ assert (len >= 0);
+ res = ber_declen(b, &ll, len);
+ if (res == -2)
+ {
+#if BER_ANY_DEBUG
+ if (bad)
+ yaz_log(LOG_LOG, "<<<<<<<<< return1 lev=%d res=%d", level, res);
+#endif
+ return -1; /* error */
+ }
+ if (res == -1)
+ {
+#if BER_ANY_DEBUG
+ if (bad)
+ yaz_log(LOG_LOG, "<<<<<<<<< return3 lev=%d res=-1", level);
+#endif
+ return 0; /* incomplete length */
+ }
+ if (ll > 5000000)
+ {
+#if BER_ANY_DEBUG
+ if (bad)
+ yaz_log(LOG_LOG, "<<<<<<<<< return2 lev=%d len=%d res=%d ll=%d",
+ level, len, res, ll);
+#endif
+ return -1; /* error */
+ }
+#if 0
+/* no longer necessary, since ber_declen never reads that far (returns -1) */