Fix wrong numbers being passed as string lengths
(Imported from upstream's 0b142f022e2c5072295e00ebc11c5b707a726d74.)
Modified further because these ought to just be BIO_puts.
Change-Id: I8b70d70d0f626bb19b455adb4f0e08bacf453c1d
Reviewed-on: https://boringssl-review.googlesource.com/4002
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/asn1/asn1_par.c b/crypto/asn1/asn1_par.c
index 53b11fe..aff3e2b 100644
--- a/crypto/asn1/asn1_par.c
+++ b/crypto/asn1/asn1_par.c
@@ -137,7 +137,7 @@
#endif
if (j & 0x80)
{
- if (BIO_write(bp,"Error in encoding\n",18) <= 0)
+ if (BIO_puts(bp, "Error in encoding\n") <= 0)
goto end;
ret=0;
goto end;
@@ -165,7 +165,7 @@
if (j & V_ASN1_CONSTRUCTED)
{
ep=p+len;
- if (BIO_write(bp,"\n",1) <= 0) goto end;
+ if (BIO_puts(bp, "\n") <= 0) goto end;
if (len > length)
{
BIO_printf(bp,
@@ -196,7 +196,7 @@
else if (xclass != 0)
{
p+=len;
- if (BIO_write(bp,"\n",1) <= 0) goto end;
+ if (BIO_puts(bp, "\n") <= 0) goto end;
}
else
{
@@ -210,7 +210,7 @@
(tag == V_ASN1_UTCTIME) ||
(tag == V_ASN1_GENERALIZEDTIME))
{
- if (BIO_write(bp,":",1) <= 0) goto end;
+ if (BIO_puts(bp, ":") <= 0) goto end;
if ((len > 0) &&
BIO_write(bp,(const char *)p,(int)len)
!= (int)len)
@@ -221,12 +221,12 @@
opp=op;
if (d2i_ASN1_OBJECT(&o,&opp,len+hl) != NULL)
{
- if (BIO_write(bp,":",1) <= 0) goto end;
+ if (BIO_puts(bp, ":") <= 0) goto end;
i2a_ASN1_OBJECT(bp,o);
}
else
{
- if (BIO_write(bp,":BAD OBJECT",11) <= 0)
+ if (BIO_puts(bp, ":BAD OBJECT") <= 0)
goto end;
}
}
@@ -238,7 +238,7 @@
ii=d2i_ASN1_BOOLEAN(NULL,&opp,len+hl);
if (ii < 0)
{
- if (BIO_write(bp,"Bad boolean\n",12) <= 0)
+ if (BIO_puts(bp, "Bad boolean\n") <= 0)
goto end;
}
BIO_printf(bp,":%d",ii);
@@ -273,7 +273,7 @@
if (printable)
/* printable string */
{
- if (BIO_write(bp,":",1) <= 0)
+ if (BIO_puts(bp, ":") <= 0)
goto end;
if (BIO_write(bp,(const char *)opp,
os->length) <= 0)
@@ -283,7 +283,7 @@
/* not printable => print octet string
* as hex dump */
{
- if (BIO_write(bp,"[HEX DUMP]:",11) <= 0)
+ if (BIO_puts(bp, "[HEX DUMP]:") <= 0)
goto end;
for (i=0; i<os->length; i++)
{
@@ -297,7 +297,7 @@
{
if (!nl)
{
- if (BIO_write(bp,"\n",1) <= 0)
+ if (BIO_puts(bp, "\n") <= 0)
goto end;
}
if (!BIO_hexdump(bp, opp,
@@ -323,9 +323,9 @@
bs=d2i_ASN1_INTEGER(NULL,&opp,len+hl);
if (bs != NULL)
{
- if (BIO_write(bp,":",1) <= 0) goto end;
+ if (BIO_puts(bp, ":") <= 0) goto end;
if (bs->type == V_ASN1_NEG_INTEGER)
- if (BIO_write(bp,"-",1) <= 0)
+ if (BIO_puts(bp, "-") <= 0)
goto end;
for (i=0; i<bs->length; i++)
{
@@ -335,13 +335,13 @@
}
if (bs->length == 0)
{
- if (BIO_write(bp,"00",2) <= 0)
+ if (BIO_puts(bp, "00") <= 0)
goto end;
}
}
else
{
- if (BIO_write(bp,"BAD INTEGER",11) <= 0)
+ if (BIO_puts(bp, "BAD INTEGER") <= 0)
goto end;
}
M_ASN1_INTEGER_free(bs);
@@ -355,9 +355,9 @@
bs=d2i_ASN1_ENUMERATED(NULL,&opp,len+hl);
if (bs != NULL)
{
- if (BIO_write(bp,":",1) <= 0) goto end;
+ if (BIO_puts(bp, ":") <= 0) goto end;
if (bs->type == V_ASN1_NEG_ENUMERATED)
- if (BIO_write(bp,"-",1) <= 0)
+ if (BIO_puts(bp, "-") <= 0)
goto end;
for (i=0; i<bs->length; i++)
{
@@ -367,13 +367,13 @@
}
if (bs->length == 0)
{
- if (BIO_write(bp,"00",2) <= 0)
+ if (BIO_puts(bp, "00") <= 0)
goto end;
}
}
else
{
- if (BIO_write(bp,"BAD ENUMERATED",11) <= 0)
+ if (BIO_puts(bp, "BAD ENUMERATED") <= 0)
goto end;
}
M_ASN1_ENUMERATED_free(bs);
@@ -382,7 +382,7 @@
{
if (!nl)
{
- if (BIO_write(bp,"\n",1) <= 0)
+ if (BIO_puts(bp, "\n") <= 0)
goto end;
}
if (!BIO_hexdump(bp,p,
@@ -394,7 +394,7 @@
if (!nl)
{
- if (BIO_write(bp,"\n",1) <= 0) goto end;
+ if (BIO_puts(bp, "\n") <= 0) goto end;
}
p+=len;
if ((tag == V_ASN1_EOC) && (xclass == 0))
diff --git a/crypto/x509/asn1_gen.c b/crypto/x509/asn1_gen.c
index 9ffd937..7c77178 100644
--- a/crypto/x509/asn1_gen.c
+++ b/crypto/x509/asn1_gen.c
@@ -379,7 +379,7 @@
arg->format = ASN1_GEN_FORMAT_UTF8;
else if (!strncmp(vstart, "HEX", 3))
arg->format = ASN1_GEN_FORMAT_HEX;
- else if (!strncmp(vstart, "BITLIST", 3))
+ else if (!strncmp(vstart, "BITLIST", 7))
arg->format = ASN1_GEN_FORMAT_BITLIST;
else
{