mirror of
https://github.com/wownero/wownero.git
synced 2026-10-17 15:41:44 +02:00
easylogging++: avoid buffer underflow
This commit is contained in:
+3
-2
@@ -1016,8 +1016,9 @@ const std::string OS::getBashOutput(const char* command) {
|
|||||||
char hBuff[4096];
|
char hBuff[4096];
|
||||||
if (fgets(hBuff, sizeof(hBuff), proc) != nullptr) {
|
if (fgets(hBuff, sizeof(hBuff), proc) != nullptr) {
|
||||||
pclose(proc);
|
pclose(proc);
|
||||||
if (hBuff[strlen(hBuff) - 1] == '\n') {
|
const size_t len = strlen(hBuff);
|
||||||
hBuff[strlen(hBuff) - 1] = '\0';
|
if (len > 0 && hBuff[len - 1] == '\n') {
|
||||||
|
hBuff[len- 1] = '\0';
|
||||||
}
|
}
|
||||||
return std::string(hBuff);
|
return std::string(hBuff);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user