Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Feb 2022 17:27:00 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 50cf1cf36898 - stable/13 - Fix too small hostname buffer in bootparamd
Message-ID:  <202202091727.219HR0ps018876@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=50cf1cf36898f8697c32c79e8e7fd279deeee514

commit 50cf1cf36898f8697c32c79e8e7fd279deeee514
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-02-06 14:25:22 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-02-09 17:26:18 +0000

    Fix too small hostname buffer in bootparamd
    
    This fixes the following warning from clang 14:
    
    usr.sbin/bootparamd/bootparamd/bootparamd.c:204:32: error: 'fscanf' may
    overflow; destination buffer in argument 3 has size 255, but the
    corresponding specifier may require size 256 [-Werror,-Wfortify-source]
    
    The MAX_MACHINE_NAME macro indicates the maximum number of bytes in a
    machine name, but it does not include the NUL terminator required for
    scanf.
    
    MFC after:       3 days
    
    (cherry picked from commit d310bf3867b4168e57365196c3a31797c0538097)
---
 usr.sbin/bootparamd/bootparamd/bootparamd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.sbin/bootparamd/bootparamd/bootparamd.c b/usr.sbin/bootparamd/bootparamd/bootparamd.c
index be885de62f55..5bbd5b4becef 100644
--- a/usr.sbin/bootparamd/bootparamd/bootparamd.c
+++ b/usr.sbin/bootparamd/bootparamd/bootparamd.c
@@ -34,7 +34,7 @@ extern const char *bootpfile;
 
 static struct hostent *he;
 static char buffer[MAXLEN];
-static char hostname[MAX_MACHINE_NAME];
+static char hostname[MAX_MACHINE_NAME + 1];
 static char askname[MAX_MACHINE_NAME];
 static char path[MAX_PATH_LEN];
 static char domain_name[MAX_MACHINE_NAME];



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202202091727.219HR0ps018876>