lkml.org 
[lkml]   [2018]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH 6/7] nfs: use fmtcheck() in root_nfs_data
    Date
    tmp is initially the string "/tftpboot/%s", but it may be changed from
    the calls to root_nfs_parse_options. While an nfsroot= command line
    option can probably be trusted (or the user gets to keep both pieces),
    it's also possible for contents to come via a BOOTP option.

    Do a sanity check of fmt to ensure it doesn't contain odd printf
    specifiers that would make snprintf go off into the weeds. The lack of
    the FMTCHECK_NO_EXTRA_ARGS flag (i.e., the last 0 argument) means we
    allow either no specifiers or precisely one occurrence of %s in tmp.

    Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
    ---
    fs/nfs/nfsroot.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
    index effaa4247b91..71db0149eb49 100644
    --- a/fs/nfs/nfsroot.c
    +++ b/fs/nfs/nfsroot.c
    @@ -261,7 +261,7 @@ static int __init root_nfs_data(char *cmdline)
    * mess into nfs_root_device.
    */
    len = snprintf(nfs_export_path, sizeof(nfs_export_path),
    - tmp, utsname()->nodename);
    + fmtcheck(tmp, "%s", 0), utsname()->nodename);
    if (len >= (int)sizeof(nfs_export_path))
    goto out_devnametoolong;
    len = snprintf(nfs_root_device, sizeof(nfs_root_device),
    --
    2.19.1.6.gbde171bbf5
    \
     
     \ /
      Last update: 2018-10-27 01:24    [W:3.502 / U:0.724 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site