From 469938cb4012472d3d99ed7ead258aef3a5bc029 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Tue, 22 Aug 2000 12:54:21 +0000 Subject: [PATCH] Fixes to d2i_ASN1_OBJECT, ASN1_INTEGER_to_BN and a_strex.c --- CHANGES | 9 +++++++++ crypto/asn1/a_int.c | 2 +- crypto/asn1/a_object.c | 7 ++++--- crypto/asn1/a_strex.c | 10 +++++----- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index b01f3a07f8..278c98279c 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,15 @@ Changes between 0.9.5a and 0.9.6 [xx XXX 2000] + *) Fix various signed/unsigned issues to make a_strex,c + compile under VC++. + [Oscar Jacobsson ] + + *) ASN1 fixes. i2d_ASN1_OBJECT was not returning the correct + length if passed a buffer. ASN1_INTEGER_to_BN failed + if passed a NULL BN and its argument was negative. + [Steve Henson, pointed out by Sven Heiberg ] + *) Modification to PKCS#7 encoding routines to output definite length encoding. Since currently the whole structures are in memory there's not real point in using indefinite length diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c index bb8e9cf8f9..0db747eddf 100644 --- a/crypto/asn1/a_int.c +++ b/crypto/asn1/a_int.c @@ -465,7 +465,7 @@ BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai, BIGNUM *bn) if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL) ASN1err(ASN1_F_ASN1_INTEGER_TO_BN,ASN1_R_BN_LIB); - if(ai->type == V_ASN1_NEG_INTEGER) bn->neg = 1; + if(ai->type == V_ASN1_NEG_INTEGER) ret->neg = 1; return(ret); } diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c index 3873b98902..20caa2d3bd 100644 --- a/crypto/asn1/a_object.c +++ b/crypto/asn1/a_object.c @@ -65,11 +65,12 @@ int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp) { unsigned char *p; + int objsize; if ((a == NULL) || (a->data == NULL)) return(0); - if (pp == NULL) - return(ASN1_object_size(0,a->length,V_ASN1_OBJECT)); + objsize = ASN1_object_size(0,a->length,V_ASN1_OBJECT); + if (pp == NULL) return objsize; p= *pp; ASN1_put_object(&p,0,a->length,V_ASN1_OBJECT,V_ASN1_UNIVERSAL); @@ -77,7 +78,7 @@ int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp) p+=a->length; *pp=p; - return(a->length); + return(objsize); } int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) diff --git a/crypto/asn1/a_strex.c b/crypto/asn1/a_strex.c index f94ae2751b..02fe2bad1c 100644 --- a/crypto/asn1/a_strex.c +++ b/crypto/asn1/a_strex.c @@ -96,7 +96,7 @@ int send_bio_chars(void *arg, const void *buf, int len) int send_fp_chars(void *arg, const void *buf, int len) { if(!arg) return 1; - if(fwrite(buf, 1, len, arg) != len) return 0; + if(fwrite(buf, 1, len, arg) != (unsigned int)len) return 0; return 1; } @@ -123,7 +123,7 @@ static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, ch if(!io_ch(arg, tmphex, 6)) return -1; return 6; } - chtmp = c; + chtmp = (unsigned char)c; if(chtmp > 0x7f) chflgs = flags & ASN1_STRFLGS_ESC_MSB; else chflgs = char_type[chtmp] & flags; if(chflgs & CHARTYPE_BS_ESC) { @@ -200,12 +200,12 @@ static int do_buf(unsigned char *buf, int buflen, * otherwise each character will be > 0x7f and so the * character will never be escaped on first and last. */ - len = do_esc_char(utfbuf[i], flags | orflags, quotes, io_ch, arg); + len = do_esc_char(utfbuf[i], (unsigned char)(flags | orflags), quotes, io_ch, arg); if(len < 0) return -1; outlen += len; } } else { - len = do_esc_char(c, flags | orflags, quotes, io_ch, arg); + len = do_esc_char(c, (unsigned char)(flags | orflags), quotes, io_ch, arg); if(len < 0) return -1; outlen += len; } @@ -304,7 +304,7 @@ static int do_print_ex(char_io *io_ch, void *arg, unsigned long lflags, ASN1_STR unsigned char flags; quotes = 0; /* Keep a copy of escape flags */ - flags = lflags & ESC_FLAGS; + flags = (unsigned char)(lflags & ESC_FLAGS); type = str->type; -- 2.34.1