Skip to content

Commit

Permalink
Bug 1685880 - Fix for the gcc compiler version 7 to support setenv wi…
Browse files Browse the repository at this point in the history
…th nss build. r=rrelyea

Differential Revision: https://phabricator.services.mozilla.com/D104418

--HG--
extra : moz-landing-system : lando
  • Loading branch information
aashisharoradev committed Feb 24, 2021
1 parent 56ca2ee commit 49dd1c6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/util/secport.c
Expand Up @@ -740,22 +740,29 @@ NSS_PutEnv(const char *envVarName, const char *envValue)
SET_ERROR_CODE
return SECFailure;
}
#endif

#elif defined(__GNUC__) && __GNUC__ >= 7
int setEnvFailed;
setEnvFailed = setenv(envVarName, envValue, 1);
if (setEnvFailed) {
SET_ERROR_CODE
return SECFailure;
}
#else
encoded = (char *)PORT_ZAlloc(strlen(envVarName) + 2 + strlen(envValue));
if (!encoded) {
return SECFailure;
}
strcpy(encoded, envVarName);
strcat(encoded, "=");
strcat(encoded, envValue);

putEnvFailed = putenv(encoded); /* adopt. */

if (putEnvFailed) {
SET_ERROR_CODE
result = SECFailure;
PORT_Free(encoded);
}
#endif
return result;
}

Expand Down

0 comments on commit 49dd1c6

Please sign in to comment.