[media] atomisp: one char read beyond end of string
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 18 May 2017 13:50:19 +0000 (10:50 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 19 May 2017 09:57:29 +0000 (06:57 -0300)
We should verify that "ix < max_len" before we test whether we have
reached the NUL terminator.

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_include/string_support.h

index 568631698a3d458177ff55e71d6afb65295c4e79..74b5a1c7ac9a43b59cca9c5a61ae1d8fc34928b2 100644 (file)
@@ -72,9 +72,8 @@ static size_t strnlen_s(
                return 0;
        }
 
-       for (ix=0;
-               ((src_str[ix] != '\0') && (ix< max_len));
-               ++ix) /*Nothing else to do*/;
+       for (ix = 0; ix < max_len && src_str[ix] != '\0'; ix++)
+               ;
 
        /* On Error, it will return src_size == max_len*/
        return ix;