net: caif: fix the value of size argument of snprintf
authorswkhack <swkhack@gmail.com>
Fri, 17 May 2019 07:59:22 +0000 (15:59 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 17 May 2019 18:31:15 +0000 (11:31 -0700)
Because the function snprintf write at most size bytes(including the
null byte).So the value of the argument size need not to minus one.

Signed-off-by: swkhack <swkhack@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/caif/cfdbgl.c
net/caif/cfdgml.c
net/caif/cfutill.c
net/caif/cfveil.c
net/caif/cfvidl.c

index 7aae0b56829ebbd7e0da64c6465ef0d8621ec994..cce839bf49f717dcef5a716d1015db2c2345e991 100644 (file)
@@ -26,7 +26,7 @@ struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info)
        cfsrvl_init(dbg, channel_id, dev_info, false);
        dbg->layer.receive = cfdbgl_receive;
        dbg->layer.transmit = cfdbgl_transmit;
-       snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ - 1, "dbg%d", channel_id);
+       snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ, "dbg%d", channel_id);
        return &dbg->layer;
 }
 
index 3bdddb32d55a7a1ce6c37e7293dbc5461dc98aa4..58fdb99a390f09bb3e82e47901a4af788c0392e9 100644 (file)
@@ -33,8 +33,7 @@ struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info)
        cfsrvl_init(dgm, channel_id, dev_info, true);
        dgm->layer.receive = cfdgml_receive;
        dgm->layer.transmit = cfdgml_transmit;
-       snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ - 1, "dgm%d", channel_id);
-       dgm->layer.name[CAIF_LAYER_NAME_SZ - 1] = '\0';
+       snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ, "dgm%d", channel_id);
        return &dgm->layer;
 }
 
index 1728fa4471cfe6d712c6152a1393384fe2e9ce0a..be7c43a92ead1794db00c49a3316dcd347100c59 100644 (file)
@@ -33,7 +33,7 @@ struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info)
        cfsrvl_init(util, channel_id, dev_info, true);
        util->layer.receive = cfutill_receive;
        util->layer.transmit = cfutill_transmit;
-       snprintf(util->layer.name, CAIF_LAYER_NAME_SZ - 1, "util1");
+       snprintf(util->layer.name, CAIF_LAYER_NAME_SZ, "util1");
        return &util->layer;
 }
 
index 262224581efafd87ed89af723f1fa91046f1aa15..35dd3a600dd145e63084b465ab5d2b05005d911b 100644 (file)
@@ -32,7 +32,7 @@ struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info)
        cfsrvl_init(vei, channel_id, dev_info, true);
        vei->layer.receive = cfvei_receive;
        vei->layer.transmit = cfvei_transmit;
-       snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ - 1, "vei%d", channel_id);
+       snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ, "vei%d", channel_id);
        return &vei->layer;
 }
 
index b3b110e8a35045d58c5356735b36e94321b873fb..73615e3b3b58cbe4c1635ff76413c0807faa85ac 100644 (file)
@@ -29,7 +29,7 @@ struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info)
        cfsrvl_init(vid, channel_id, dev_info, false);
        vid->layer.receive = cfvidl_receive;
        vid->layer.transmit = cfvidl_transmit;
-       snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ - 1, "vid1");
+       snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ, "vid1");
        return &vid->layer;
 }