From: Ricky Zhou <ricky@rzhou.org>
To: zsh-workers@zsh.org
Subject: [PATCH] Fix buffer overflow in mindist.
Date: Mon, 27 Dec 2010 07:00:23 -0500 [thread overview]
Message-ID: <20101227120023.GA27174@alpha.rzhou.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 926 bytes --]
(reported at https://bugzilla.redhat.com/show_bug.cgi?id=591377)
---
Src/utils.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Src/utils.c b/Src/utils.c
index b64530b..513bc7e 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3665,14 +3665,21 @@ static int
mindist(char *dir, char *mindistguess, char *mindistbest)
{
int mindistd, nd;
+ int len;
DIR *dd;
char *fn;
- char buf[PATH_MAX];
+ char buf[PATH_MAX + 1];
if (dir[0] == '\0')
dir = ".";
mindistd = 100;
- sprintf(buf, "%s/%s", dir, mindistguess);
+
+ /* input was too long and result got truncated */
+ len = snprintf(buf, sizeof(buf), "%s/%s", dir, mindistguess);
+ if (len >= sizeof(buf) || len < 0) {
+ return mindistd;
+ }
+
if (access(unmeta(buf), F_OK) == 0) {
strcpy(mindistbest, mindistguess);
return 0;
--
1.7.3.4
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next reply other threads:[~2010-12-27 12:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-27 12:00 Ricky Zhou [this message]
2011-01-05 17:20 ` Peter Stephenson
2011-01-05 18:33 ` Ricky Zhou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101227120023.GA27174@alpha.rzhou.org \
--to=ricky@rzhou.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).