Set null-terminator after strncpy
Summary: When the length of `pkcs12.second.c_str()` is equal to `length`, strncpy won't write a null-terminator at the end of the destination string, making the destination unsafe to read and potentially cause an overflow. Reviewed By: lblasa Differential Revision: D46934320 fbshipit-source-id: 5e7acd49523b80105bcc47471facd9ff23b8a2b8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
54b7d8feea
commit
71751855df
@@ -92,6 +92,7 @@ void FlipperWebSocket::connect(FlipperConnectionManager* manager) {
|
|||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
strncpy(password, pkcs12.second.c_str(), length);
|
strncpy(password, pkcs12.second.c_str(), length);
|
||||||
|
password[length - 1] = '\0';
|
||||||
return pkcs12.first;
|
return pkcs12.first;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user