Skip to contentSkip to conversation

X.509: Add an ASN.1 decoder

DISCUSSION Dan Carpenter 1 participant 1 message Oct 3, 2012 Kernel janitors

lore
Share & tools
lore
#0 lore raw

Hello David Howells,

The patch 788380fa26a6: "X.509: Add an ASN.1 decoder" from Sep 24, 2012, leads to the following warning:
lib/asn1_decoder.c:320 asn1_ber_decoder()
warn: unsigned 'len' is never less than zero.

lib/asn1_decoder.c
315 skip_data:
316 if (!(flags & FLAG_CONS)) {
317 if (flags & FLAG_INDEFINITE_LENGTH) {
318 len = asn1_find_indefinite_length(
319 data + dp, datalen - dp, &errmsg, &dp);
320 if (len < 0)

                                            ^^^^^^^

asn1_find_indefinite_length() returns -1 on error but "len" is unsigned.

   321                                          goto error;
   322                          }
   323                          pr_debug("- LEAF: %zu\n", len);
   324                          dp += len;
   325                  }

regards,
dan carpenter