lib/gssapi/ntlm: from_file do not leak 'f' on error

Change-Id: Ica774bc3c156c384a2cf7084259d31f445d24a7d
This commit is contained in:
Jeffrey Altman
2022-01-16 23:10:33 -05:00
parent 6e8ab0c204
commit ff18c32ae4

View File

@@ -61,17 +61,20 @@ from_file(const char *fn, const char *target_domain,
if (d && target_domain != NULL && strcasecmp(target_domain, d) != 0)
continue;
*domainp = strdup(d);
if (*domainp == NULL)
if (*domainp == NULL) {
fclose(f);
return ENOMEM;
}
u = strtok_r(NULL, ":", &str);
p = strtok_r(NULL, ":", &str);
if (u == NULL || p == NULL)
continue;
*usernamep = strdup(u);
if (*usernamep == NULL)
if (*usernamep == NULL) {
fclose(f);
return ENOMEM;
}
heim_ntlm_nt_key(p, key);
memset_s(buf, sizeof(buf), 0, sizeof(buf));