• Andrew Morton's avatar
    [PATCH] fix uts sysctl write size · b717e21c
    Andrew Morton authored
    From: Andy Whitcroft <apw@shadowen.org>
    
    The sysctl interfaces for updating the uts entries such as hostname and
    domainname are using the wrong length for these buffers; they are hard
    coded to 64.  Although safe, this artifically limits the size of these
    fields to one less than the true maximum.  This generates an inconsistency
    between the various methods of update for these fields.
    
    # hostname 12345678901234567890123456789012345678901234567890123456789012345
    hostname: name too long
    # hostname 1234567890123456789012345678901234567890123456789012345678901234
    # hostname
    1234567890123456789012345678901234567890123456789012345678901234
    
    # sysctl -w kernel.hostname=1234567890123456789012345678901234567890123456789012345678901234567890
    kernel.hostname = 1234567890123456789012345678901234567890123456789012345678901234567890
    # hostname
    123456789012345678901234567890123456789012345678901234567890123
    #
    
    The error originates from the fact the handler for strings (proc_dostring)
    already allows for the string terminator.  This patch corrects the limit,
    taking the oppotunity to convert to use of sizeof().
    Signed-off-by: default avatarAndy Whitcroft <apw@shadowen.org>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    b717e21c
sysctl.c 50 KB