From: Tobias Stoeckmann <tobias@stoeckmann.org>
To: util-linux@vger.kernel.org
Subject: [PATCH] rev: Avoid out of boundary read
Date: Mon, 3 Oct 2016 22:06:23 +0200 [thread overview]
Message-ID: <20161003200623.GC2287@localhost> (raw)
Check if the length of the parsed string is at least 1,
otherwise an out of boundary read would occur.
---
text-utils/rev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/text-utils/rev.c b/text-utils/rev.c
index ace2cd6..735aaef 100644
--- a/text-utils/rev.c
+++ b/text-utils/rev.c
@@ -149,6 +149,9 @@ int main(int argc, char *argv[])
while (fgetws(buf, bufsiz, fp)) {
len = wcslen(buf);
+ if (len == 0)
+ continue;
+
/* This is my hack from setpwnam.c -janl */
while (buf[len-1] != '\n' && !feof(fp)) {
/* Extend input buffer if it failed getting the whole line */
--
2.10.0
next reply other threads:[~2016-10-03 20:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-03 20:06 Tobias Stoeckmann [this message]
2016-10-06 12:59 ` [PATCH] rev: Avoid out of boundary read Karel Zak
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=20161003200623.GC2287@localhost \
--to=tobias@stoeckmann.org \
--cc=util-linux@vger.kernel.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox