mstflint/0001-mstflint-crash-when-compiled-with-CXXFLAGS-Wp-D_GLIB.patch
Honggang Li 4d9bba1983 Fix mstflint segment fault issue for ConnectX-5 HCA
Resolves: 1679844

Signed-off-by: Honggang Li <honli@redhat.com>
2019-02-22 10:58:07 +08:00

27 lines
1.2 KiB
Diff

diff --git a/mlxfwops/lib/fs2_ops.cpp b/mlxfwops/lib/fs2_ops.cpp
index 775e242..4af0b9f 100644
--- a/mlxfwops/lib/fs2_ops.cpp
+++ b/mlxfwops/lib/fs2_ops.cpp
@@ -369,7 +369,7 @@ bool Fs2Operations::checkGen(u_int32_t beg, u_int32_t offs, u_int32_t& next, con
// CRC
Crc16 crc;
std::vector<u_int8_t> buffv(size);
- u_int32_t *buff = (u_int32_t*)(&(buffv[0]));
+ u_int32_t *buff = (u_int32_t*)(buffv.size() ? (&(buffv[0])) : NULL);
readBufAux((*_ioAccess), offs + sizeof(gph), buff, size, pr);
diff --git a/mlxfwops/lib/fs4_ops.cpp b/mlxfwops/lib/fs4_ops.cpp
index eb0ca29..4b10307 100644
--- a/mlxfwops/lib/fs4_ops.cpp
+++ b/mlxfwops/lib/fs4_ops.cpp
@@ -403,7 +403,7 @@ bool Fs4Operations::verifyTocEntries(u_int32_t tocAddr, bool show_itoc, bool isD
// Only when we have full verify or the info of this section should be collected for query
std::vector<u_int8_t> buffv(entrySizeInBytes);
- u_int8_t *buff = (u_int8_t *)(&(buffv[0]));
+ u_int8_t *buff = (u_int8_t *)(buffv.size() ? (&(buffv[0])) : NULL);
if (show_itoc) {
cx5fw_itoc_entry_dump(&tocEntry, stdout);