From: tb Date: Sat, 23 Oct 2021 08:13:48 +0000 (+0000) Subject: Add a length check before NUL-terminating target. From Jonas Termansen. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3b269dc8e50b40cf1975d35094377edefa8a41b1;p=openbsd Add a length check before NUL-terminating target. From Jonas Termansen. ok jsing --- diff --git a/usr.bin/openssl/certhash.c b/usr.bin/openssl/certhash.c index 31c4899fae6..a4417a2b267 100644 --- a/usr.bin/openssl/certhash.c +++ b/usr.bin/openssl/certhash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: certhash.c,v 1.18 2021/08/28 08:16:39 tb Exp $ */ +/* $OpenBSD: certhash.c,v 1.19 2021/10/23 08:13:48 tb Exp $ */ /* * Copyright (c) 2014, 2015 Joel Sing * @@ -490,6 +490,10 @@ certhash_link(struct dirent *dep, struct hashinfo **links) fprintf(stderr, "failed to readlink %s\n", dep->d_name); return (-1); } + if (n >= sizeof(target) - 1) { + fprintf(stderr, "symbolic link is too long %s\n", dep->d_name); + return (-1); + } target[n] = '\0'; hi = hashinfo_from_linkname(dep->d_name, target);