* nsscommon.cxx (add_client_cert): Check PORT_Alloc() return value.
* stap-serverd.cxx (get_stap_locale): Check getenv() return value
and localization key=value parsability.
* util.cxx (assert_regexp_match, regexp_match): Assert regcomp
success.
SECItem certDER;
certDER.len = info.st_size;
certDER.data = (unsigned char *)PORT_Alloc (certDER.len);
+ if (certDER.data == NULL)
+ {
+ nsscommon_error (_F("Could not allocate certDER\n%s",
+ strerror (errno)));
+ fclose (inFile);
+ return SECFailure;
+ }
size_t read = fread (certDER.data, 1, certDER.len, inFile);
fclose (inFile);
if (read != certDER.len)
for (unsigned i=0; environ[i]; i++)
{
vector<string> environTok;
+ const char *value = getenv(environTok[0].c_str());
+ if (!value) continue;
tokenize(environ[i], environTok, "=");
- envMap[environTok[0]] = (string)getenv(environTok[0].c_str());
+ envMap[environTok[0]] = string(value);
}
/* Create regular expression objects to verify lines read from file. Should not allow
string value;
size_t pos;
pos = line.find("=");
+ if (pos == string::npos)
+ {
+ client_error(_F("Localization key=value line '%s' cannot be parsed", line.c_str()));
+ continue;
+ }
key = line.substr(0, pos);
pos++;
value = line.substr(pos);
{
r = new regex_t;
int rc = regcomp (r, re.c_str(), REG_ICASE|REG_NOSUB|REG_EXTENDED);
- if (rc) {
- cerr << _F("regcomp %s (%s) error rc= %d", re.c_str(), name.c_str(), rc) << endl;
- exit(1);
- }
+ assert (rc == 0);
compiled[re] = r;
}
else
{
r = new regex_t;
int rc = regcomp (r, re.c_str(), REG_EXTENDED); /* REG_ICASE? */
- if (rc) {
- cerr << _F("regcomp %s error rc=%d", re.c_str(), rc) << endl;
- return rc;
- }
+ assert (rc == 0);
compiled[re] = r;
}
else