]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Modulo operations are only occuring on unsigned integers.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 14 Jan 2012 22:34:10 +0000 (23:34 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 21 Jan 2012 00:05:59 +0000 (01:05 +0100)
14 files changed:
lib/gnutls_cipher.c
lib/gnutls_handshake.c
lib/gnutls_handshake.h
lib/gnutls_int.h
lib/gnutls_state.c
lib/gnutls_state.h
lib/gnutls_v2_compat.c
lib/gnutls_v2_compat.h
lib/opencdk/misc.c
lib/x509/common.c
lib/x509/crl.c
lib/x509/privkey_pkcs8.c
lib/x509/x509.c
lib/x509_b64.c

index a323defb21a7d7e8042bf3bd141200d56eef3605..6da32f42fedb09b240489a9ac4472628597978d2 100644 (file)
@@ -200,7 +200,8 @@ calc_enc_length (gnutls_session_t session, int data_size,
                  unsigned block_algo, unsigned auth_cipher, uint16_t blocksize)
 {
   uint8_t rnd;
-  int length, ret;
+  unsigned int length;
+  int ret;
 
   *pad = 0;
 
@@ -256,7 +257,7 @@ calc_enc_length (gnutls_session_t session, int data_size,
  * and are not to be sent). Returns their size.
  */
 static inline int
-make_preamble (opaque * uint64_data, opaque type, int length,
+make_preamble (opaque * uint64_data, opaque type, unsigned int length,
                opaque ver, opaque * preamble)
 {
   opaque minor = _gnutls_version_get_minor (ver);
index b00212211bee9b519960dce9bac13c104df10324..167bb3daf0f4a1ad357f2067fefb2998bb5c9aa1 100644 (file)
@@ -801,7 +801,7 @@ server_find_pk_algos_in_ciphersuites (const opaque *
  */
 int
 _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
-                             int datalen)
+                             unsigned int datalen)
 {
   int i, j, ret, cipher_suites_size;
   size_t pk_algos_size;
index 2366303597e58c29b4cfaeff7b4b047c3b9c0b7a..7cc227147f6b453954af7083bd0eea18aa4c715d 100644 (file)
@@ -45,7 +45,7 @@ int _gnutls_tls_create_random (opaque * dst);
 
 int _gnutls_find_pk_algos_in_ciphersuites (opaque * data, int datalen);
 int _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
-                                 int datalen);
+                                 unsigned int datalen);
 
 int _gnutls_negotiate_version (gnutls_session_t session,
                                gnutls_protocol_t adv_version);
index 72e5f58f00829871d804ad5f87ca9efe17dcd96a..08762612e35eb557b573064da0147309fa5f24f5 100644 (file)
@@ -455,7 +455,7 @@ typedef struct
  */
 typedef struct
 {
-  int entity; /* GNUTLS_SERVER or GNUTLS_CLIENT */
+  unsigned int entity; /* GNUTLS_SERVER or GNUTLS_CLIENT */
   gnutls_kx_algorithm_t kx_algorithm;
 
   /* The epoch used to read and write */
index 4f20465ebe47570ab290e5cb113ae922fb291c09..ef6cf5f3875e1c140ffe0456e1502cf8f7598dd1 100644 (file)
@@ -889,7 +889,7 @@ P_hash (gnutls_mac_algorithm_t algorithm,
  */
 int
 _gnutls_PRF (gnutls_session_t session,
-             const opaque * secret, int secret_size, const char *label,
+             const opaque * secret, unsigned int secret_size, const char *label,
              int label_size, const opaque * seed, int seed_size,
              int total_bytes, void *ret)
 {
index 7800fde26a6ef83cfc2bbfebbccc9f3d9e299d2f..491d71287c6fb5c6f7e170e04afa9956c3da7a51 100644 (file)
@@ -76,7 +76,7 @@ int _gnutls_session_is_psk (gnutls_session_t session);
 int _gnutls_openpgp_send_fingerprint (gnutls_session_t session);
 
 int _gnutls_PRF (gnutls_session_t session,
-                 const opaque * secret, int secret_size,
+                 const opaque * secret, unsigned int secret_size,
                  const char *label, int label_size,
                  const opaque * seed, int seed_size,
                  int total_bytes, void *ret);
index e394f295973671ed72f8beba9bb2dee20b5b845e..aada12bafd2604c6dcd00c211899d16dc981c5e0 100644 (file)
@@ -45,7 +45,7 @@
 /* This selects the best supported ciphersuite from the ones provided */
 static int
 _gnutls_handshake_select_v2_suite (gnutls_session_t session,
-                                   opaque * data, int datalen)
+                                   opaque * data, unsigned int datalen)
 {
   int i, j, ret;
   opaque *_data;
@@ -91,7 +91,7 @@ _gnutls_handshake_select_v2_suite (gnutls_session_t session,
  */
 int
 _gnutls_read_client_hello_v2 (gnutls_session_t session, opaque * data,
-                              int datalen)
+                              unsigned int datalen)
 {
   uint16_t session_id_len = 0;
   int pos = 0;
index ccaedf902422b724f82f84d97cd4f2b292c20447..613af139e3c61be2a7348877b0f26b71fe12b33d 100644 (file)
@@ -21,4 +21,4 @@
  */
 
 int _gnutls_read_client_hello_v2 (gnutls_session_t session, opaque * data,
-                                  int datalen);
+                                  unsigned int datalen);
index c10279d763f814244f24171ef5b9781dc1f49cae..dbfddfad12573f35f6d5b77a719301f990d9e4ca 100644 (file)
@@ -182,7 +182,7 @@ _cdk_tmpfile (void)
   /* Because the tmpfile() version of wine is not really useful,
      we implement our own version to avoid problems with 'make check'. */
   static const char *letters = "abcdefghijklmnopqrstuvwxyz";
-  char buf[512], rnd[24];
+  unsigned char buf[512], rnd[24];
   FILE *fp;
   int fd, i;
 
index 459fe9ef4128d1200f82154e4c88d5d72ddc825a..77772676745d2f927badb6dce9a3a462f1728fbf 100644 (file)
@@ -109,7 +109,7 @@ static const struct oid2string _oid2str[] = {
 int
 _gnutls_x509_oid_data_printable (const char *oid)
 {
-  int i = 0;
+  unsigned int i = 0;
 
   do
     {
@@ -139,7 +139,7 @@ _gnutls_x509_oid_data_printable (const char *oid)
 int
 gnutls_x509_dn_oid_known (const char *oid)
 {
-  int i = 0;
+  unsigned int i = 0;
 
   do
     {
@@ -158,7 +158,7 @@ gnutls_x509_dn_oid_known (const char *oid)
 int
 _gnutls_x509_oid_data_choice (const char *oid)
 {
-  int i = 0;
+  unsigned int i = 0;
 
   do
     {
@@ -188,7 +188,7 @@ _gnutls_x509_oid_data_choice (const char *oid)
 const char*
 gnutls_x509_dn_oid_name (const char *oid, unsigned int flags)
 {
-  int i = 0;
+  unsigned int i = 0;
 
   do
     {
@@ -205,7 +205,7 @@ gnutls_x509_dn_oid_name (const char *oid, unsigned int flags)
 const char *
 _gnutls_x509_oid2asn_string (const char *oid)
 {
-  int i = 0;
+  unsigned int i = 0;
 
   do
     {
@@ -455,7 +455,7 @@ static time_t
 mktime_utc (const struct fake_tm *tm)
 {
   time_t result = 0;
-  int i;
+  unsigned int i;
 
 /* We do allow some ill-formed dates, but we don't do anything special
  * with them and our callers really shouldn't pass them to us.  Do
@@ -1437,15 +1437,16 @@ int
 _gnutls_x509_get_signature (ASN1_TYPE src, const char *src_name,
                             gnutls_datum_t * signature)
 {
-  int bits, result, len;
+  int result, len;
+  unsigned int bits;
 
   signature->data = NULL;
   signature->size = 0;
 
   /* Read the signature 
    */
-  bits = 0;
-  result = asn1_read_value (src, src_name, NULL, &bits);
+  len = 0;
+  result = asn1_read_value (src, src_name, NULL, &len);
 
   if (result != ASN1_MEM_ERROR)
     {
@@ -1454,6 +1455,7 @@ _gnutls_x509_get_signature (ASN1_TYPE src, const char *src_name,
       goto cleanup;
     }
 
+  bits = len;
   if (bits % 8 != 0)
     {
       gnutls_assert ();
@@ -1474,7 +1476,7 @@ _gnutls_x509_get_signature (ASN1_TYPE src, const char *src_name,
   /* read the bit string of the signature
    */
   bits = len;
-  result = asn1_read_value (src, src_name, signature->data, &bits);
+  result = asn1_read_value (src, src_name, signature->data, (int*)&bits);
 
   if (result != ASN1_SUCCESS)
     {
index 916cfb24bb6fb3407ec4761f5257c982934e54d3..ef8a0b0891662d014a167e4a3ba9daa56a1a50d6 100644 (file)
@@ -326,7 +326,7 @@ gnutls_x509_crl_get_signature (gnutls_x509_crl_t crl,
                                char *sig, size_t * sizeof_sig)
 {
   int result;
-  int bits;
+  unsigned int bits;
   int len;
 
   if (crl == NULL)
@@ -335,14 +335,16 @@ gnutls_x509_crl_get_signature (gnutls_x509_crl_t crl,
       return GNUTLS_E_INVALID_REQUEST;
     }
 
-  bits = 0;
-  result = asn1_read_value (crl->crl, "signature", NULL, &bits);
+  len = 0;
+  result = asn1_read_value (crl->crl, "signature", NULL, &len);
+
   if (result != ASN1_MEM_ERROR)
     {
       gnutls_assert ();
       return _gnutls_asn2err (result);
     }
 
+  bits = len;
   if (bits % 8 != 0)
     {
       gnutls_assert ();
index 272ffe64fe3be90b2fba7d5e338ec548a47fedd4..1fa6b81bd8bd56173d5d131711ede3de08f4c62f 100644 (file)
@@ -1898,7 +1898,7 @@ generate_key (schema_id schema,
               struct pbkdf2_params *kdf_params,
               struct pbe_enc_params *enc_params, gnutls_datum_t * key)
 {
-  opaque rnd[2];
+  unsigned char rnd[2];
   int ret;
 
   ret = _gnutls_rnd (GNUTLS_RND_RANDOM, rnd, 2);
index d20e9f313fb653d61dd528f1f3f2c82fb49acf29..af45c86dcd82833e62dd97d6b848fd608de7dba8 100644 (file)
@@ -498,7 +498,8 @@ gnutls_x509_crt_get_signature (gnutls_x509_crt_t cert,
                                char *sig, size_t * sizeof_sig)
 {
   int result;
-  int bits, len;
+  unsigned int bits;
+  int len;
 
   if (cert == NULL)
     {
@@ -506,14 +507,15 @@ gnutls_x509_crt_get_signature (gnutls_x509_crt_t cert,
       return GNUTLS_E_INVALID_REQUEST;
     }
 
-  bits = 0;
-  result = asn1_read_value (cert->cert, "signature", NULL, &bits);
+  len = 0;
+  result = asn1_read_value (cert->cert, "signature", NULL, &len);
   if (result != ASN1_MEM_ERROR)
     {
       gnutls_assert ();
       return _gnutls_asn2err (result);
     }
 
+  bits = len;
   if (bits % 8 != 0)
     {
       gnutls_assert ();
@@ -524,7 +526,7 @@ gnutls_x509_crt_get_signature (gnutls_x509_crt_t cert,
 
   if (*sizeof_sig < (unsigned int) len)
     {
-      *sizeof_sig = bits / 8;
+      *sizeof_sig = len;
       return GNUTLS_E_SHORT_MEMORY_BUFFER;
     }
 
index 2ad8144df17ef709fc0a47f38c90576d8dcb9f4d..78918c365e587327ded6a0562012c62bd01f5b43 100644 (file)
@@ -153,7 +153,8 @@ int
 _gnutls_fbase64_encode (const char *msg, const uint8_t * data,
                         int data_size, uint8_t ** result)
 {
-  int i, ret, tmp, j;
+  int ret, tmp;
+  unsigned int i, j;
   char tmpres[4];
   uint8_t *ptr;
   uint8_t top[80];