From: Simon Josefsson Date: Mon, 26 May 2008 10:47:52 +0000 (+0200) Subject: (gnutls_x509_crl_set_version): Fix on platform where 'char' can be unsigned. X-Git-Tag: gnutls_2_3_12~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=513d06b388dcda5ae0200e607923dcd0f88f79f4;p=thirdparty%2Fgnutls.git (gnutls_x509_crl_set_version): Fix on platform where 'char' can be unsigned. Based on report from Laurence Withers , see: . --- diff --git a/lib/x509/crl_write.c b/lib/x509/crl_write.c index cbdbbbdcf6..5ab7c1cfb4 100644 --- a/lib/x509/crl_write.c +++ b/lib/x509/crl_write.c @@ -57,7 +57,7 @@ int gnutls_x509_crl_set_version (gnutls_x509_crl_t crl, unsigned int version) { int result; - char null = version; + uint8_t null = version & 0xFF; if (crl == NULL) { @@ -65,9 +65,8 @@ gnutls_x509_crl_set_version (gnutls_x509_crl_t crl, unsigned int version) return GNUTLS_E_INVALID_REQUEST; } - null -= 1; - if (null < 0) - null = 0; + if (null > 0) + null -= 1; result = asn1_write_value (crl->crl, "tbsCertList.version", &null, 1); if (result != ASN1_SUCCESS)