提交 244d7b28 编写于 作者: K Kurt Roeckx

Fix undefined behaviour when printing the X509 serial

Found by afl
Reviewed-by: NAndy Polyakov <appro@openssl.org>
GH: #2230
上级 a470f023
...@@ -93,12 +93,14 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, ...@@ -93,12 +93,14 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,
l = -1; l = -1;
} }
if (l != -1) { if (l != -1) {
unsigned long ul;
if (bs->type == V_ASN1_NEG_INTEGER) { if (bs->type == V_ASN1_NEG_INTEGER) {
l = -l; ul = 0 - (unsigned long)l;
neg = "-"; neg = "-";
} else } else
ul = l;
neg = ""; neg = "";
if (BIO_printf(bp, " %s%lu (%s0x%lx)\n", neg, l, neg, l) <= 0) if (BIO_printf(bp, " %s%lu (%s0x%lx)\n", neg, ul, neg, ul) <= 0)
goto err; goto err;
} else { } else {
neg = (bs->type == V_ASN1_NEG_INTEGER) ? " (Negative)" : ""; neg = (bs->type == V_ASN1_NEG_INTEGER) ? " (Negative)" : "";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册