staging: wlags49_h2: strncpy, need checking the memory length
authorChen Gang <gang.chen@asianux.com>
Fri, 26 Apr 2013 10:31:58 +0000 (18:31 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 May 2013 22:08:16 +0000 (18:08 -0400)
HCF_MAX_NAME_LEN is 32, which may less than ''probe_rsp->rawData[1]'',
so need check the length when copy to ssid.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wlags49_h2/wl_main.c

index f28f15baea96460b11631004a57f22a46e94c5c5..35d617d0792d457309db36bb684d0d988d57e845 100644 (file)
@@ -3171,7 +3171,8 @@ void wl_process_mailbox( struct wl_private *lp )
 
                                        memset( ssid, 0, sizeof( ssid ));
                                        strncpy( ssid, &probe_rsp->rawData[2],
-                                                        probe_rsp->rawData[1] );
+                                                min(probe_rsp->rawData[1],
+                                                       HCF_MAX_NAME_LEN - 1));
 
                                        DBG_TRACE( DbgInfo, "(%s) SSID        : %s\n",
                                                           lp->dev->name, ssid );