OSDN Git Service

input: touchscreen: synaptics_dsx: Fix buffer overflow
authorVenkata Prahlad Valluru <vvalluru@codeaurora.org>
Tue, 1 May 2018 05:53:32 +0000 (11:23 +0530)
committerGerrit - the friendly Code Review server <code-review@localhost>
Tue, 1 May 2018 08:38:15 +0000 (01:38 -0700)
Limit the index to buffer length while copying from
'strptr' to 'firmware_id'.

Change-Id: I1d7cb7a3d9593ca213c7f7341776632e635eb0df
Signed-off-by: Venkata Prahlad Valluru <vvalluru@codeaurora.org>
drivers/input/touchscreen/synaptics_dsx/synaptics_dsx_fw_update.c

index 4787f2b..1368013 100644 (file)
@@ -681,10 +681,12 @@ static enum flash_area fwu_go_nogo(struct image_header_data *header)
                        goto exit;
                }
 
-               while (strptr[index] >= '0' && strptr[index] <= '9') {
+               while ((index < MAX_FIRMWARE_ID_LEN - 1) && strptr[index] >= '0'
+                                               && strptr[index] <= '9') {
                        firmware_id[index] = strptr[index];
                        index++;
                }
+               firmware_id[index] = '\0';
 
                retval = sstrtoul(firmware_id, 10, &image_fw_id);
                kfree(firmware_id);