From b75c256e3224f125b185c1a432e8c6e99483e2ff Mon Sep 17 00:00:00 2001 From: leitner Date: Thu, 7 Sep 2023 21:03:13 +0000 Subject: [PATCH] make sure scan_asn1rawint also works when char == unsigned char (default on ARM) --- scan_asn1rawint.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scan_asn1rawint.c b/scan_asn1rawint.c index 2164026..6e27c93 100644 --- a/scan_asn1rawint.c +++ b/scan_asn1rawint.c @@ -3,14 +3,15 @@ size_t scan_asn1rawint(const char* src,const char* max,size_t len,long* l) { size_t i; long m; + const signed char* s = (const signed char*)src; if (src>=max || (size_t)(max-src)>7); // -1 if negative, 0 otherwise + m=(*s>>7); // -1 if negative, 0 otherwise // look for and reject non-minimal encodings - if (len>1 && *src==m) { + if (len>1 && *s==m) { // we want to catch things like 00 01 // but a leading 0 byte is needed for 00 a0 because otherwise it would be -96 - if ((src[1]>>7)==m) + if ((s[1]>>7)==m) return 0; // non-minimal encoding /* This part is a bit counter intuitive. The code used to say this: @@ -29,7 +30,7 @@ size_t scan_asn1rawint(const char* src,const char* max,size_t len,long* l) { if (len>sizeof(m)) return 0; // value too large, does not fit for (i=0; i