diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 7570cf7198..399bad99ac 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -220,7 +220,8 @@ int name_length(const TEXT* const name) * **************************************/ const TEXT* q = name - 1; - for (const TEXT* p = name; *p; p++) { + for (const TEXT* p = name; *p; p++) + { if (*p != ' ') { q = p; } @@ -428,7 +429,8 @@ bool isGlobalKernelPrefix() DynLibHandle hmodAdvApi(LoadLibrary("advapi32.dll")); - if (!hmodAdvApi) { + if (!hmodAdvApi) + { gds__log("LoadLibrary failed for advapi32.dll. Error code: %lu", GetLastError()); return false; } @@ -444,7 +446,8 @@ bool isGlobalKernelPrefix() PFnPrivilegeCheck pfnPrivilegeCheck = (PFnPrivilegeCheck) GetProcAddress(hmodAdvApi, "PrivilegeCheck"); - if (!pfnOpenProcessToken || !pfnLookupPrivilegeValue || !pfnPrivilegeCheck) { + if (!pfnOpenProcessToken || !pfnLookupPrivilegeValue || !pfnPrivilegeCheck) + { // Should never happen, really gds__log("Cannot access privilege management API"); return false; @@ -452,7 +455,8 @@ bool isGlobalKernelPrefix() HANDLE hProcess = GetCurrentProcess(); HANDLE hToken; - if (pfnOpenProcessToken(hProcess, TOKEN_QUERY, &hToken) == 0) { + if (pfnOpenProcessToken(hProcess, TOKEN_QUERY, &hToken) == 0) + { gds__log("OpenProcessToken failed. Error code: %lu", GetLastError()); return false; } @@ -461,7 +465,8 @@ bool isGlobalKernelPrefix() memset(&ps, 0, sizeof(ps)); ps.Control = PRIVILEGE_SET_ALL_NECESSARY; ps.PrivilegeCount = 1; - if (pfnLookupPrivilegeValue(NULL, TEXT("SeCreateGlobalPrivilege"), &ps.Privilege[0].Luid) == 0) { + if (pfnLookupPrivilegeValue(NULL, TEXT("SeCreateGlobalPrivilege"), &ps.Privilege[0].Luid) == 0) + { // Failure here means we're running on old version of Windows 2000 or XP // which always allow creating global handles CloseHandle(hToken); @@ -469,7 +474,8 @@ bool isGlobalKernelPrefix() } BOOL checkResult; - if (pfnPrivilegeCheck(hToken, &ps, &checkResult) == 0) { + if (pfnPrivilegeCheck(hToken, &ps, &checkResult) == 0) + { gds__log("PrivilegeCheck failed. Error code: %lu", GetLastError()); CloseHandle(hToken); return false; @@ -702,7 +708,8 @@ namespace { else { f = fopen(name.c_str(), "rt"); } - if (f && isatty(fileno(f))) { + if (f && isatty(fileno(f))) + { fprintf(stderr, "Enter password: "); fflush(stderr); #ifdef HAVE_TERMIOS_H diff --git a/src/qli/command.cpp b/src/qli/command.cpp index a11efd1dbe..c53d3e9ab8 100644 --- a/src/qli/command.cpp +++ b/src/qli/command.cpp @@ -349,17 +349,20 @@ void CMD_set( qli_syntax* node) case set_matching_language: if (QLI_matching_language) ALLQ_release((qli_frb*) QLI_matching_language); - if (!(string = (qli_const*) value)) - { + string = (qli_const*) value; + if (!string) QLI_matching_language = NULL; - break; + else + { + const USHORT len = string->con_desc.dsc_length; + QLI_matching_language = (qli_const*) ALLOCPV(type_con, len); + fb_utils::copy_terminate((char*) QLI_matching_language->con_data, + (char*) string->con_data, len + 1); + dsc& lang = QLI_matching_language->con_desc; + lang.dsc_dtype = dtype_text; + lang.dsc_address = QLI_matching_language->con_data; + lang.dsc_length = len; } - QLI_matching_language = (qli_const*) ALLOCPV(type_con, string->con_desc.dsc_length); - fb_utils::copy_terminate((char*) QLI_matching_language->con_data, (char*) string->con_data, - string->con_desc.dsc_length + 1); - QLI_matching_language->con_desc.dsc_dtype = dtype_text; - QLI_matching_language->con_desc.dsc_address = QLI_matching_language->con_data; - QLI_matching_language->con_desc.dsc_length = string->con_desc.dsc_length; break; case set_user: diff --git a/src/qli/show.epp b/src/qli/show.epp index 9754933007..9dd0c478c4 100644 --- a/src/qli/show.epp +++ b/src/qli/show.epp @@ -1954,11 +1954,8 @@ static void show_matching() return; if (QLI_matching_language) { - buf_type buffer; - strncpy(buffer, (char*) QLI_matching_language->con_data, - QLI_matching_language->con_desc.dsc_length); - buffer[QLI_matching_language->con_desc.dsc_length] = 0; - printf("\n\t%s\n", buffer); + printf("\n\t%.*s\n", + int(QLI_matching_language->con_desc.dsc_length), QLI_matching_language->con_data); } } @@ -2185,34 +2182,30 @@ static void show_rels( qli_dbb* dbb, enum show_t sw, SSHORT width) switch (sw) { case show_relations: + show_dbb(dbb); + buffer[0] = 0; + for (const qli_rel* relation = dbb->dbb_relations; relation; + relation = relation->rel_next) { - show_dbb(dbb); - buffer[0] = 0; - for (const qli_rel* relation = dbb->dbb_relations; relation; - relation = relation->rel_next) - { - if (!(relation->rel_flags & REL_system)) - show_names(relation->rel_symbol->sym_string, width, buffer); - } - if (buffer[0]) - printf("%s\n", buffer); - printf("\n"); - break; + if (!(relation->rel_flags & REL_system)) + show_names(relation->rel_symbol->sym_string, width, buffer); } + if (buffer[0]) + printf("%s\n", buffer); + printf("\n"); + break; case show_system_relations: + show_dbb(dbb); + buffer[0] = 0; + for (const qli_rel* relation = dbb->dbb_relations; relation; + relation = relation->rel_next) { - show_dbb(dbb); - buffer[0] = 0; - for (const qli_rel* relation = dbb->dbb_relations; relation; - relation = relation->rel_next) - { - if (relation->rel_flags & REL_system) - show_names(relation->rel_symbol->sym_string, width, buffer); - } - if (buffer[0]) - printf("%s\n", buffer); - printf("\n"); + if (relation->rel_flags & REL_system) + show_names(relation->rel_symbol->sym_string, width, buffer); } + if (buffer[0]) + printf("%s\n", buffer); + printf("\n"); } }