]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Null, as the data value, is now an acceptable value in functions that may return...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 15 Feb 2003 17:13:07 +0000 (17:13 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 15 Feb 2003 17:13:07 +0000 (17:13 +0000)
lib/gnutls_ui.c
lib/x509/dn.c
lib/x509/pkcs7.c
lib/x509/pkcs7.h
lib/x509/x509.c

index 4515a6971a10ad32119f7e4dff4c7153e10004fa..8a36d11d70e9566d392111d8a507e5b44017b1a0 100644 (file)
@@ -269,7 +269,7 @@ int gnutls_certificate_client_get_request_status(gnutls_session session)
   * gnutls_fingerprint - This function calculates the fingerprint of the given data
   * @algo: is a digest algorithm
   * @data: is the data
-  * @result: is the place where the result will be copied. 
+  * @result: is the place where the result will be copied (may be null)
   * @result_size: should hold the size of the result. The actual size
   * of the returned result will also be copied there.
   *
@@ -297,13 +297,15 @@ int gnutls_fingerprint(gnutls_digest_algorithm algo, const gnutls_datum* data, c
                return GNUTLS_E_SHORT_MEMORY_BUFFER;
        }
        *result_size = hash_len;
+
+       if (result) {
+               td = _gnutls_hash_init( algo);
+               if (td==NULL) return GNUTLS_E_HASH_FAILED;
        
-       td = _gnutls_hash_init( algo);
-       if (td==NULL) return GNUTLS_E_HASH_FAILED;
-       
-       _gnutls_hash( td, data->data, data->size);
+               _gnutls_hash( td, data->data, data->size);
        
-       _gnutls_hash_deinit( td, result);
+               _gnutls_hash_deinit( td, result);
+       }
                
        return 0;
 }
index 47fbca4416f93c882bad1b903643b6cd05a435e2..a9ae049ea9d5fe9cfe94933fc0f00d199f507043 100644 (file)
@@ -455,8 +455,11 @@ int _gnutls_x509_parse_dn_oid(ASN1_TYPE asn1_struct,
                                                            GNUTLS_E_SHORT_MEMORY_BUFFER;
                                                }
                                                *sizeof_buf = size; /* -1 for the null +1 for the '#' */
-                                               strcpy(buf, "#");
-                                               strcat(buf, res);
+                                               
+                                               if (buf) {
+                                                       strcpy(buf, "#");
+                                                       strcat(buf, res);
+                                               }
 
                                                return 0;
                                        } else {
index 75df9d968763489117c40241d2fe2a8ef4f64b50..ccce9af5430928c3d04ba8b058014f33547f1605 100644 (file)
@@ -151,7 +151,7 @@ int gnutls_pkcs7_import(gnutls_pkcs7 pkcs7, const gnutls_datum * data,
   *
   **/
 int gnutls_pkcs7_get_certificate(gnutls_pkcs7 pkcs7, 
-       int indx, char* certificate, int* certificate_size)
+       int indx, unsigned char* certificate, int* certificate_size)
 {
        ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
        int result, len;
@@ -260,14 +260,15 @@ int gnutls_pkcs7_get_certificate(gnutls_pkcs7 pkcs7,
                        
                end = end-start+1;
                
-               if (certificate!=NULL && end <= *certificate_size)
-                       memcpy( certificate, &tmp[start], end);
-               else {
+               if ( end > *certificate_size) {
                        *certificate_size = end;
                        result = GNUTLS_E_SHORT_MEMORY_BUFFER;
                        goto cleanup;
                }
 
+               if (certificate)
+                       memcpy( certificate, &tmp[start], end);
+
                *certificate_size = end;
 
                result = 0;
index e3ad0b817f9a98b050d068159363effe45369427..2099cae8b87986a8411fb6d582412d65d97edbd1 100644 (file)
@@ -10,5 +10,5 @@ void gnutls_pkcs7_deinit(gnutls_pkcs7 pkcs7);
 int gnutls_pkcs7_import(gnutls_pkcs7 pkcs7, const gnutls_datum * data,
        gnutls_x509_crt_fmt format);
 int gnutls_pkcs7_get_certificate(gnutls_pkcs7 pkcs7, 
-       int indx, char* certificate, int* certificate_size);
+       int indx, unsigned char* certificate, int* certificate_size);
 int gnutls_pkcs7_get_certificate_count(gnutls_pkcs7 pkcs7);
index d4bdfb7e897e8712c0c505e31090d62f73d49dce..e208a02e9dca00b38505ecbaaf2da3d26837d405 100644 (file)
@@ -776,7 +776,9 @@ int gnutls_x509_crt_get_extension_by_oid(gnutls_x509_crt cert, const char* oid,
        }
 
        *sizeof_buf = output.size;
-       memcpy( buf, output.data, output.size);
+       
+       if (buf)
+               memcpy( buf, output.data, output.size);
 
        _gnutls_free_datum( &output);
        
@@ -999,5 +1001,6 @@ gnutls_datum tmp;
        
        tmp.data = cert_buf;
        tmp.size = cert_buf_size;
+
        return gnutls_fingerprint( algo, &tmp, buf, sizeof_buf);
 }