Commit 4909f7c7 authored by Kamil Dudka's avatar Kamil Dudka
Browse files

nss: do not skip Curl_nss_seed() if data is NULL

In that case, we only skip writing the error message for failed NSS
initialization (while still returning the correct error code).
parent 7a1538d9
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -1034,6 +1034,7 @@ static PRStatus nspr_io_close(PRFileDesc *fd)
  return close_fn(fd);
}

/* data might be NULL */
static CURLcode nss_init_core(struct SessionHandle *data, const char *cert_dir)
{
  NSSInitParameters initparams;
@@ -1071,6 +1072,7 @@ static CURLcode nss_init_core(struct SessionHandle *data, const char *cert_dir)
  return CURLE_SSL_CACERT_BADFILE;
}

/* data might be NULL */
static CURLcode nss_init(struct SessionHandle *data)
{
  char *cert_dir;
@@ -1149,10 +1151,12 @@ int Curl_nss_init(void)
  return 1;
}

/* data might be NULL */
CURLcode Curl_nss_force_init(struct SessionHandle *data)
{
  CURLcode result;
  if(!nss_initlock) {
    if(data)
      failf(data, "unable to initialize NSS, curl_global_init() should have "
                  "been called with CURL_GLOBAL_SSL or CURL_GLOBAL_ALL");
    return CURLE_FAILED_INIT;
@@ -1904,6 +1908,7 @@ size_t Curl_nss_version(char *buffer, size_t size)
  return snprintf(buffer, size, "NSS/%s", NSS_VERSION);
}

/* data might be NULL */
int Curl_nss_seed(struct SessionHandle *data)
{
  /* make sure that NSS is initialized */
@@ -1915,7 +1920,6 @@ int Curl_nss_random(struct SessionHandle *data,
                    unsigned char *entropy,
                    size_t length)
{
  if(data)
  Curl_nss_seed(data);  /* Initiate the seed if not already done */

  if(SECSuccess != PK11_GenerateRandom(entropy, curlx_uztosi(length)))