]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
(gnutls_x509_crl_set_version): Fix on platform where 'char' can be unsigned.
authorSimon Josefsson <simon@josefsson.org>
Mon, 26 May 2008 10:47:52 +0000 (12:47 +0200)
committerSimon Josefsson <simon@josefsson.org>
Mon, 26 May 2008 10:47:52 +0000 (12:47 +0200)
Based on report from Laurence Withers <l@lwithers.me.uk>, see:
<http://permalink.gmane.org/gmane.comp.encryption.gpg.gnutls.devel/2825>.

lib/x509/crl_write.c

index cbdbbbdcf62577e4b3cac6a7dca58778769ee447..5ab7c1cfb4cdefb7a58c22baf74844459548ce52 100644 (file)
@@ -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)