client: strip whitespace when read GUI RPC passwd file

This commit is contained in:
David Anderson 2020-10-30 19:16:33 -07:00
parent 86d0e9fbd1
commit 1cca463736
1 changed files with 3 additions and 9 deletions

View File

@ -478,16 +478,10 @@ int read_gui_rpc_password(char* buf, string& msg) {
return ERR_FOPEN; return ERR_FOPEN;
#endif #endif
} }
char* p = fgets(buf, 256, f); buf[0] = 0;
if (p) { if (fgets(buf, 256, f)) {
// trim CR strip_whitespace(buf);
//
int n = (int)strlen(buf);
if (n && buf[n-1]=='\n') {
buf[n-1] = 0;
}
} }
fclose(f); fclose(f);
return 0; return 0;
} }