[PATCHv2 opensm] osm_sm_mad_ctrl.c: Reduce path buffer sizes to avoid format truncation in log_rcv_cb_error

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

 



make[2]: Entering directory '/home/honli/upstream-repos/opensm/opensm'
depbase=`echo osm_sm_mad_ctrl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -DHAVE_CONFIG_H -I. -I../include -I../include/opensm  -I./../include -I./../../libibumad/include -I/usr/local/include   -Werror -Wall -Wwrite-strings -g -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE=1 -g -O2 -MT osm_sm_mad_ctrl.o -MD -MP -MF $depbase.Tpo -c -o osm_sm_mad_ctrl.o osm_sm_mad_ctrl.c &&\
mv -f $depbase.Tpo $depbase.Po
osm_sm_mad_ctrl.c: In function ‘log_rcv_cb_error’:
osm_sm_mad_ctrl.c:571:28: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4078 [-Werror=format-truncation=]
     "\n\t\t\tInitial path: %s Return path: %s",
                            ^~
     ipath, rpath);
     ~~~~~
osm_sm_mad_ctrl.c:570:3: note: ‘snprintf’ output between 33 and 8223 bytes into a destination of size 4096
   snprintf(buf, sizeof(buf),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~
     "\n\t\t\tInitial path: %s Return path: %s",
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     ipath, rpath);
     ~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Honggang Li <honli@xxxxxxxxxx>
Signed-off-by: Hal Rosenstock <hal@xxxxxxxxxxxx>
---
 opensm/osm_sm_mad_ctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/opensm/osm_sm_mad_ctrl.c b/opensm/osm_sm_mad_ctrl.c
index ebac558..5d1323f 100644
--- a/opensm/osm_sm_mad_ctrl.c
+++ b/opensm/osm_sm_mad_ctrl.c
@@ -560,7 +560,7 @@ static void log_rcv_cb_error(osm_log_t *p_log, ib_smp_t *p_smp, ib_net16_t statu
 	uint32_t i;
 
 	if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) {
-		char ipath[BUF_SIZE], rpath[BUF_SIZE];
+		char ipath[256], rpath[256];
 		int ni = sprintf(ipath, "%d", p_smp->initial_path[0]);
 		int nr = sprintf(rpath, "%d", p_smp->return_path[0]);
 		for (i = 1; i <= p_smp->hop_count; i++) {
-- 
2.8.4

--
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