Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/external/bsd/heimdal/dist/lib/krb5 Do not reference b...



details:   https://anonhg.NetBSD.org/src/rev/cfdf9955aa23
branches:  trunk
changeset: 362595:cfdf9955aa23
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Jun 16 18:51:36 2018 +0000

description:
Do not reference buffer after the code scope {}

rk_getpwuid_r() returns a pointer pwd->pw_dir to a buffer pwbuf[].

It's not safe to store another a copy of pwd->pw_dir in outter scope and
use it out of the scope where there exists pwbuf[].

This fixes a problem reported by ASan under MKSANITIZER.

diffstat:

 crypto/external/bsd/heimdal/dist/lib/krb5/config_file.c |  7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diffs (28 lines):

diff -r bb24a516161d -r cfdf9955aa23 crypto/external/bsd/heimdal/dist/lib/krb5/config_file.c
--- a/crypto/external/bsd/heimdal/dist/lib/krb5/config_file.c   Sat Jun 16 17:44:53 2018 +0000
+++ b/crypto/external/bsd/heimdal/dist/lib/krb5/config_file.c   Sat Jun 16 18:51:36 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: config_file.c,v 1.3 2017/09/08 15:29:43 christos Exp $ */
+/*     $NetBSD: config_file.c,v 1.4 2018/06/16 18:51:36 kamil Exp $    */
 
 /*
  * Copyright (c) 1997 - 2004 Kungliga Tekniska Högskolan
@@ -430,6 +430,8 @@
     if (ISTILDE(fname[0]) && ISPATHSEP(fname[1])) {
 #ifndef KRB5_USE_PATH_TOKENS
        const char *home = NULL;
+       struct passwd pw, *pwd = NULL;
+       char pwbuf[2048];
 
        if (!_krb5_homedir_access(context)) {
            krb5_set_error_message(context, EPERM,
@@ -441,9 +443,6 @@
            home = getenv("HOME");
 
        if (home == NULL) {
-           struct passwd pw, *pwd = NULL;
-           char pwbuf[2048];
-
            if (rk_getpwuid_r(getuid(), &pw, pwbuf, sizeof(pwbuf), &pwd) == 0)
                home = pwd->pw_dir;
        }



Home | Main Index | Thread Index | Old Index