From: Jim Meyering <jim@meyering.net>
To: dash@vger.kernel.org
Cc: 548493@bugs.debian.org
Subject: [PATCH] don't read-uninitialized for \177 in a here-doc
Date: Mon, 28 Sep 2009 11:22:29 +0200 [thread overview]
Message-ID: <87r5trbezu.fsf@meyering.net> (raw)
It was indeed a bug in dash.
I tracked it down and wrote the patch below:
From 53924ce6da7fece91e57b7238e6aa81a4df636a5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Mon, 28 Sep 2009 11:00:05 +0200
Subject: [PATCH] don't read-uninitialized for \177 in a here-doc
A DEL (0177, dec 127) byte in a here-document would cause dash to
access uninitialized memory at the end of one of the syntax.c tables,
since those tables are sized to accommodate a maximum index of
BASESYNTAX + 126. Make the generated tables one byte larger.
printf ':<<\\E\n\200y\nE'|./dash
* src/mksyntax.c (filltable): Use 258, not 257 as the size,
so that BASESYNTAX(=130) + 127 is a valid index.
(print): Likewise.
Don't emit explicit array dimension in declaration.
---
ChangeLog | 13 +++++++++++++
src/mksyntax.c | 6 +++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d9dcb0c..fabb0e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-09-28 Jim Meyering <meyering@redhat.com>
+
+ don't read-uninitialized for \177 in a here-doc
+ A DEL (0177, dec 127) byte in a here-document would cause dash to
+ access uninitialized memory at the end of one of the syntax.c tables,
+ since those tables are sized to accommodate a maximum index of
+ BASESYNTAX + 126. Make the generated tables one byte larger.
+ printf ':<<\\E\n\200y\nE'|./dash
+ * src/mksyntax.c (filltable): Use 258, not 257 as the size,
+ so that BASESYNTAX(=130) + 127 is a valid index.
+ (print): Likewise.
+ Don't emit explicit array dimension in declaration.
+
2009-08-31 Eric Blake <ebb9@byu.net>
* Avoid compiler warnings on isdigit.
diff --git a/src/mksyntax.c b/src/mksyntax.c
index 7a8a9ae..a23c18c 100644
--- a/src/mksyntax.c
+++ b/src/mksyntax.c
@@ -223,7 +223,7 @@ filltable(char *dftval)
{
int i;
- for (i = 0 ; i < 257; i++)
+ for (i = 0 ; i < 258; i++)
syntax[i] = dftval;
}
@@ -269,9 +269,9 @@ print(char *name)
int col;
fprintf(hfile, "extern const char %s[];\n", name);
- fprintf(cfile, "const char %s[%d] = {\n", name, 257);
+ fprintf(cfile, "const char %s[] = {\n", name);
col = 0;
- for (i = 0 ; i < 257; i++) {
+ for (i = 0 ; i < 258; i++) {
if (i == 0) {
fputs(" ", cfile);
} else if ((i & 03) == 0) {
--
1.6.5.rc2.177.ga9dd6
next reply other threads:[~2009-09-28 9:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-28 9:22 Jim Meyering [this message]
2009-09-28 9:32 ` [PATCH] don't read-uninitialized for \177 in a here-doc Jim Meyering
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=87r5trbezu.fsf@meyering.net \
--to=jim@meyering.net \
--cc=548493@bugs.debian.org \
--cc=dash@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.