mirror of https://github.com/wolfSSL/wolfssh.git
add sanity check that pid file is not null
parent
c349510cc3
commit
827d901f52
|
@ -1452,15 +1452,17 @@ void wolfSSHD_ConfigSavePID(const WOLFSSHD_CONFIG* conf)
|
|||
FILE* f;
|
||||
char buf[12]; /* large enough to hold 'int' type with null terminator */
|
||||
|
||||
WMEMSET(buf, 0, sizeof(buf));
|
||||
if (WFOPEN(NULL, &f, conf->pidFile, "wb") == 0) {
|
||||
#ifndef WIN32
|
||||
WSNPRINTF(buf, sizeof(buf), "%d", getpid());
|
||||
#else
|
||||
WSNPRINTF(buf, sizeof(buf), "%d", _getpid());
|
||||
#endif
|
||||
WFWRITE(NULL, buf, 1, WSTRLEN(buf), f);
|
||||
WFCLOSE(NULL, f);
|
||||
if (conf->pidFile != NULL) {
|
||||
WMEMSET(buf, 0, sizeof(buf));
|
||||
if (WFOPEN(NULL, &f, conf->pidFile, "wb") == 0) {
|
||||
#ifndef WIN32
|
||||
WSNPRINTF(buf, sizeof(buf), "%d", getpid());
|
||||
#else
|
||||
WSNPRINTF(buf, sizeof(buf), "%d", _getpid());
|
||||
#endif
|
||||
WFWRITE(NULL, buf, 1, WSTRLEN(buf), f);
|
||||
WFCLOSE(NULL, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue