fetch password from file
| 1004 | |
| 1005 | // fetch password from file |
| 1006 | FetchPassResult fetchPassword(const Firebird::PathName& name, const char*& password) |
| 1007 | { |
| 1008 | InputFile file(name); |
| 1009 | if (!file) |
| 1010 | { |
| 1011 | return FETCH_PASS_FILE_OPEN_ERROR; |
| 1012 | } |
| 1013 | |
| 1014 | Firebird::string pwd; |
| 1015 | if (! pwd.LoadFromFile(file.getStdioFile())) |
| 1016 | { |
| 1017 | return ferror(file.getStdioFile()) ? FETCH_PASS_FILE_READ_ERROR : FETCH_PASS_FILE_EMPTY; |
| 1018 | } |
| 1019 | |
| 1020 | // this is planned leak of a few bytes of memory in utilities |
| 1021 | char* pass = FB_NEW_POOL(*getDefaultMemoryPool()) char[pwd.length() + 1]; |
| 1022 | pwd.copyTo(pass, pwd.length() + 1); |
| 1023 | password = pass; |
| 1024 | return FETCH_PASS_OK; |
| 1025 | } |
| 1026 | |
| 1027 | |
| 1028 |
no test coverage detected