lkml.org 
[lkml]   [2012]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 1/5] x86/cpu: Fix overrun check in arch_print_cpu_modalias()
    From
    Date
    snprintf() does not return a negative value when truncating.

    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    arch/x86/kernel/cpu/match.c | 2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)

    diff --git a/arch/x86/kernel/cpu/match.c b/arch/x86/kernel/cpu/match.c
    index 940e2d4..2dfa52b 100644
    --- a/arch/x86/kernel/cpu/match.c
    +++ b/arch/x86/kernel/cpu/match.c
    @@ -67,7 +67,7 @@ ssize_t arch_print_cpu_modalias(struct device *dev,
    for (i = 0; i < NCAPINTS*32; i++) {
    if (boot_cpu_has(i)) {
    n = snprintf(buf, size, ",%04X", i);
    - if (n < 0) {
    + if (n >= size) {
    WARN(1, "x86 features overflow page\n");
    break;
    }
    --
    1.7.9




    \
     
     \ /
      Last update: 2012-02-11 23:49    [W:4.395 / U:0.040 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site