[krbdev.mit.edu #8740] Null pointer deference in function CLeashApp :: GetProfileFile in src/windows/leash/Leash.cpp
Yang Xiao via RT
rt-comment at KRBDEV-PROD-APP-1.mit.edu
Tue Sep 18 13:07:09 EDT 2018
Hi,
There is a null pointer deference in function
CLeashApp::GetProfileFile() in Leash.cpp.
1017 BOOL
1018 CLeashApp::GetProfileFile(
1019Â Â Â Â LPSTR confname,
1020Â Â Â Â UINT szConfname
1021Â Â Â Â )
1022 {
1023Â Â Â Â char **configFile = NULL;
1024Â Â Â Â if (!m_hKrb5DLL)
1025Â Â Â Â Â Â Â Â return NULL;
1026
1027Â Â Â Â if (pkrb5_get_default_config_files(&configFile))
1028Â Â Â Â {
1029Â Â Â Â Â Â Â Â GetWindowsDirectory(confname,szConfname);
1030Â Â Â Â Â Â Â Â confname[szConfname-1] = '\0';
1031 strncat(confname,"\\KRB5.INI",szConfname-strlen(confname));
1032Â Â Â Â Â Â Â Â confname[szConfname-1] = '\0';
1033Â Â Â Â Â Â Â Â return FALSE;
1034Â Â Â Â }
1035
1036Â Â Â Â *confname = 0;
1037
1038Â Â Â Â if (configFile)
1039Â Â Â Â {
1040Â Â Â Â Â Â Â Â strncpy(confname, *configFile, szConfname);
1041Â Â Â Â Â Â Â Â confname[szConfname-1] = '\0';
1042Â Â Â Â Â Â Â Â pkrb5_free_config_files(configFile);
1043Â Â Â Â }
1044
1045Â Â Â Â if (!*confname)
1046Â Â Â Â {
1047Â Â Â Â Â Â Â Â GetWindowsDirectory(confname,szConfname);
1048Â Â Â Â Â Â Â Â confname[szConfname-1] = '\0';
1049 strncat(confname,"\\KRB5.INI",szConfname-strlen(confname));
1050Â Â Â Â Â Â Â Â confname[szConfname-1] = '\0';
1051Â Â Â Â }
1052
1053Â Â Â Â return FALSE;
1054 }
if krb5_get_default_config_files() returns success and an empty list,
then GetProfileFile () will attempt to dereference a null pointer. check
for the empty list and treat it as failure.
Below is the proposal patch for function CLeashApp::GetProfileFile().
-Â Â Â Â Â Â Â if (pkrb5_get_default_config_files(&configFile))
+Â Â Â Â Â Â Â if (pkrb5_get_default_config_files(&configFile) || !configFile[0])
        {
            GetWindowsDirectory(confname,szConfname);
            confname[szConfname-1] = '\0';
Young
More information about the krb5-bugs
mailing list