]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
rping: Replace sprintf with snprintf to protect from buffer overflow
authorDotan Barak <dotanb@dev.mellanox.co.il>
Tue, 24 Apr 2012 18:20:55 +0000 (11:20 -0700)
committerSean Hefty <sean.hefty@intel.com>
Tue, 24 Apr 2012 18:20:55 +0000 (11:20 -0700)
Signed-off-by: Dotan Barak <dotanb@dev.mellanox.co.il>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
examples/rping.c

index ee292eca60424509387021adc976168d9ebe6b04..785338e3b461f425a1b28eaffd1a03966a0cad72 100644 (file)
@@ -909,7 +909,7 @@ static int rping_test_client(struct rping_cb *cb)
                cb->state = RDMA_READ_ADV;
 
                /* Put some ascii text in the buffer. */
-               cc = sprintf(cb->start_buf, RPING_MSG_FMT, ping);
+               cc = snprintf(cb->start_buf, cb->size, RPING_MSG_FMT, ping);
                for (i = cc, c = start; i < cb->size; i++) {
                        cb->start_buf[i] = c;
                        c++;