diff options
author | Simon Josefsson <simon@josefsson.org> | 2012-05-31 16:34:28 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2012-05-31 16:34:28 +0200 |
commit | 0dd5f96848dc1b5b4357f9afade87fa05a3f79e5 (patch) | |
tree | a56a2bc05977938ad642a83c94ed1d41c7d32640 | |
parent | b2534125fcc53dd86640354a0282722bcbf1a8dc (diff) | |
download | libtasn1-0dd5f96848dc1b5b4357f9afade87fa05a3f79e5.tar.gz |
Silence compiler warnings about unsigned vs signed comparisons.
-rw-r--r-- | lib/decoding.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/decoding.c b/lib/decoding.c index 978a205..69482a4 100644 --- a/lib/decoding.c +++ b/lib/decoding.c @@ -62,7 +62,7 @@ long asn1_get_length_der (const unsigned char *der, int der_len, int *len) { unsigned int ans, sum, last; - unsigned int k, punt; + int k, punt; *len = 0; if (der_len <= 0) @@ -87,7 +87,7 @@ asn1_get_length_der (const unsigned char *der, int der_len, int *len) last = ans; ans = (ans*256) + der[punt++]; - if (ans < last) + if (ans < last) /* we wrapped around, no bignum support... */ return -2; } @@ -102,13 +102,13 @@ asn1_get_length_der (const unsigned char *der, int der_len, int *len) } sum = ans + *len; - + /* check for overflow as well INT_MAX as a maximum upper * limit for length */ if (sum >= INT_MAX || sum < ans) return -2; - - if (sum > der_len) + + if (((int) sum) > der_len) return -4; return ans; @@ -130,7 +130,8 @@ int asn1_get_tag_der (const unsigned char *der, int der_len, unsigned char *cls, int *len, unsigned long *tag) { - unsigned int punt, ris; + unsigned int ris; + int punt; unsigned int last; if (der == NULL || der_len < 2 || len == NULL) |