snprintf() retrns value which can exceed provided buffer size. The check
is needed.

Signed-off-by: Sasha Khapyorsky <[EMAIL PROTECTED]>
---
 libibumad/src/umad.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/libibumad/src/umad.c b/libibumad/src/umad.c
index 6bcfee6..dcc7275 100644
--- a/libibumad/src/umad.c
+++ b/libibumad/src/umad.c
@@ -134,6 +134,8 @@ get_port(char *ca_name, char *dir, int portnum, umad_port_t 
*port)
        port->pkeys = NULL;
 
        len = snprintf(port_dir, sizeof(port_dir), "%s/%d", dir, portnum);
+       if (len < 0 || len > sizeof(port_dir))
+               goto clean;
 
        if (sys_read_uint(port_dir, SYS_PORT_LMC, &port->lmc) < 0)
                goto clean;
-- 
1.5.5.1.178.g1f811

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to