[PATCH rdma-core] srp_daemon: Increase buffer size to avoid snprintf overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The latest gcc in tumbleweed reports:

../srp_daemon/srp_daemon.c: In function 'get_shared_pkeys':
../srp_daemon/srp_daemon.c:1080:50: warning: '__builtin___snprintf_chk' output may be truncated before the last format character [-Wformat-truncation=]
  snprintf(pkey_file, sizeof(pkey_file), "pkeys/%d", pkey_index);

The given format string requires 18 bytes to handle all expansions of %d

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
---
 srp_daemon/srp_daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srp_daemon/srp_daemon.c b/srp_daemon/srp_daemon.c
index fa452b4c537e9f..f3af6517499e71 100644
--- a/srp_daemon/srp_daemon.c
+++ b/srp_daemon/srp_daemon.c
@@ -1074,7 +1074,7 @@ static int get_port_info(struct umad_resources *umad_res, uint16_t dlid,
 int pkey_index_to_pkey(struct umad_resources *umad_res, int pkey_index,
 		       uint16_t *pkey)
 {
-	char pkey_file[16], pkey_str[16];
+	char pkey_file[18], pkey_str[16];
 
 	/* Read pkey */
 	snprintf(pkey_file, sizeof(pkey_file), "pkeys/%d", pkey_index);
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux