]> git.baikalelectronics.ru Git - kernel.git/commit
staging: dgrp: fix potential call to strncpy with a negative number
authorBill Pemberton <wfp5p@virginia.edu>
Mon, 24 Sep 2012 21:02:08 +0000 (17:02 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Sep 2012 22:42:38 +0000 (15:42 -0700)
commit173d2f9b70f42fde5c2e5c57ae507d4c5885d05b
treeefdf83f1ab62b3e4d82670a4920fa373b113d2a1
parentb7d66861eed099abce9fc297bff5cbce9b134d11
staging: dgrp: fix potential call to strncpy with a negative number

In dgrp_receive() there is:

   desclen = ((plen - 12) > MAX_DESC_LEN) ? MAX_DESC_LEN :
                     plen - 12;
   strncpy(nd->nd_ps_desc, b + 12, desclen);

However, it's possible for plen to be <= 12 here so we'd be passing a
negative number into the strncpy().  Fix this to not make the strncpy
call and report an error if desclen is <= 0

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/dgrp/dgrp_net_ops.c