| 404 | // Check OS version carefully and add prefix if we can add it |
| 405 | |
| 406 | bool prefix_kernel_object_name(char* name, size_t bufsize) |
| 407 | { |
| 408 | static bool bGlobalPrefix = false; |
| 409 | static bool bInitDone = false; |
| 410 | |
| 411 | if (!bInitDone) |
| 412 | { |
| 413 | bGlobalPrefix = isGlobalKernelPrefix(); |
| 414 | bInitDone = true; |
| 415 | } |
| 416 | |
| 417 | // Backwards compatibility feature with Firebird 2.0.3 and earlier. |
| 418 | // If the name already contains some prefix (specified by the user, as was |
| 419 | // recommended in firebird.conf) additional prefix is not added |
| 420 | if (bGlobalPrefix && !strchr(name, '\\')) |
| 421 | { |
| 422 | const char* prefix = "Global\\"; |
| 423 | const size_t len_prefix = strlen(prefix); |
| 424 | const size_t len_name = strlen(name) + 1; |
| 425 | |
| 426 | // if name and prefix can't fit in name's buffer than we must |
| 427 | // not overwrite end of name because it contains object type |
| 428 | const size_t move_prefix = (len_name + len_prefix > bufsize) ? |
| 429 | (bufsize - len_name) : len_prefix; |
| 430 | |
| 431 | memmove(name + move_prefix, name, len_name); |
| 432 | memcpy(name, prefix, move_prefix); |
| 433 | // CVC: Unfortunately, things like Glob instead of Global\\ do not achieve the objective |
| 434 | // of telling the NT kernel the object is global and hence I consider them failures. |
| 435 | //return move_prefix > 0; // Soft version of the check |
| 436 | return move_prefix == len_prefix; // Strict version of the check. |
| 437 | } |
| 438 | return true; |
| 439 | } |
| 440 | |
| 441 | |
| 442 | // Simply handle guardian. |
no test coverage detected