• Niklas Cassel's avatar
    soc: qcom: apr: Avoid string overflow · 4fadb265
    Niklas Cassel authored
    'adev->name' is used as a NUL-terminated string, but using strncpy() with the
    length equal to the buffer size may result in lack of the termination:
    
    In function 'apr_add_device',
        inlined from 'of_register_apr_devices' at drivers//soc/qcom/apr.c:264:7,
        inlined from 'apr_probe' at drivers//soc/qcom/apr.c:290:2:
    drivers//soc/qcom/apr.c:222:3: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
       strncpy(adev->name, np->name, APR_NAME_SIZE);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    This changes it to use the safer strscpy() instead.
    Signed-off-by: default avatarNiklas Cassel <niklas.cassel@linaro.org>
    Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: default avatarAndy Gross <andy.gross@linaro.org>
    4fadb265
apr.c 8.46 KB