Sync with upstream on i2d_X509_AUX. Upstream decided to reset *pp on error and to later fix up the other i2d functions to behave similarly. See upstream's c5e603ee182b40ede7713c6e229c15a8f3fdb58a. Change-Id: I01f82b578464060d0f2be5460fe4c1b969124c8e Reviewed-on: https://boringssl-review.googlesource.com/7844 Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/x509/x_x509.c b/crypto/x509/x_x509.c index f12140f..15af177 100644 --- a/crypto/x509/x_x509.c +++ b/crypto/x509/x_x509.c
@@ -207,6 +207,7 @@ int i2d_X509_AUX(X509 *a, unsigned char **pp) { int length, tmplen; + unsigned char *start = pp != NULL ? *pp : NULL; length = i2d_X509(a, pp); if (length < 0 || a == NULL) { return length; @@ -214,6 +215,8 @@ tmplen = i2d_X509_CERT_AUX(a->aux, pp); if (tmplen < 0) { + if (start != NULL) + *pp = start; return tmplen; } length += tmplen;