Compare commits

...

2 Commits
rawhide ... f20

Author SHA1 Message Date
Jan Chaloupka 92e8377e5e Change build dependency on bison, fix make check
- resolves: #1176993
- resolves: #1177001
2015-01-02 15:40:57 +01:00
jchaloup 32de6f0301 eval fixed, caused invalid free 2014-05-13 10:16:45 +02:00
2 changed files with 127 additions and 3 deletions

View File

@ -0,0 +1,113 @@
From d2ea8575a493954c2bb6a7a7a1b87d7fdfe7574a Mon Sep 17 00:00:00 2001
From: jchaloup <jchaloup@redhat.com>
Date: Mon, 12 May 2014 12:35:10 +0200
Subject: [PATCH] eval invalid free
---
awk.h | 1 +
awkgram.c | 9 +++++++++
awkgram.y | 9 +++++++++
debug.c | 21 +++++++++++++++++----
4 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/awk.h b/awk.h
index 989f451..e46b881 100644
--- a/awk.h
+++ b/awk.h
@@ -1368,6 +1368,7 @@ extern NODE *stopme(int nargs);
extern void shadow_funcs(void);
extern int check_special(const char *name);
extern SRCFILE *add_srcfile(int stype, char *src, SRCFILE *curr, bool *already_included, int *errcode);
+extern void free_srcfile(SRCFILE *thisfile);
extern void register_deferred_variable(const char *name, NODE *(*load_func)(void));
extern int files_are_same(char *path, SRCFILE *src);
extern void valinfo(NODE *n, Func_print print_func, FILE *fp);
diff --git a/awkgram.c b/awkgram.c
index 10fd421..b7eaf86 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -4857,6 +4857,15 @@ parse_program(INSTRUCTION **pcode)
return (ret || errcount);
}
+/* free_srcfile --- free a SRCFILE struct */
+
+void
+free_srcfile(SRCFILE *thisfile)
+{
+ efree(thisfile->src);
+ efree(thisfile);
+}
+
/* do_add_srcfile --- add one item to srcfiles */
static SRCFILE *
diff --git a/awkgram.y b/awkgram.y
index 6864722..f67547d 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2309,6 +2309,15 @@ parse_program(INSTRUCTION **pcode)
return (ret || errcount);
}
+/* free_srcfile --- free a SRCFILE struct */
+
+void
+free_srcfile(SRCFILE *thisfile)
+{
+ efree(thisfile->src);
+ efree(thisfile);
+}
+
/* do_add_srcfile --- add one item to srcfiles */
static SRCFILE *
diff --git a/debug.c b/debug.c
index d60164a..e7b3261 100644
--- a/debug.c
+++ b/debug.c
@@ -5433,7 +5433,8 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
int ecount = 0, pcount = 0;
int ret;
int save_flags = do_flags;
-
+ SRCFILE *the_source;
+
if (prog_running) {
this_frame = find_frame(0);
this_func = this_frame->func_node;
@@ -5443,7 +5444,7 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
ctxt = new_context();
ctxt->install_func = append_symbol; /* keep track of newly installed globals */
push_context(ctxt);
- (void) add_srcfile(SRC_CMDLINE, arg->a_string, srcfiles, NULL, NULL);
+ the_source = add_srcfile(SRC_CMDLINE, arg->a_string, srcfiles, NULL, NULL);
do_flags = false;
ret = parse_program(&code);
do_flags = save_flags;
@@ -5550,8 +5551,20 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
pop_context(); /* switch to prev context */
free_context(ctxt, (ret_val != NULL)); /* free all instructions and optionally symbols */
- if (ret_val != NULL)
- destroy_symbol(f); /* destroy "@eval" */
+
+ if (ret_val != NULL) {
+ /*
+ * Remove @eval from FUNCTAB, so that above code
+ * will work the next time around.
+ */
+ NODE *s = make_string("@eval", 5);
+
+ (void) assoc_remove(func_table, s);
+ unref(s);
+ }
+
+ free_srcfile(the_source);
+
return false;
}
--
1.9.0

View File

@ -1,7 +1,7 @@
Summary: The GNU version of the awk text processing utility
Name: gawk
Version: 4.1.0
Release: 2%{?dist}
Release: 4%{?dist}
# Most of source files are licensed under GPLv3+,
# several files are GPL or LGPLv2.1+ licensed,
# gettext.h is LGPL and random.c is BSD licensed
@ -9,12 +9,13 @@ License: GPLv3+ and GPL and LGPLv3+ and LGPL and BSD
Group: Applications/Text
URL: http://www.gnu.org/software/gawk/gawk.html
Source0: http://ftp.gnu.org/gnu/gawk/gawk-%{version}.tar.gz
Patch0: gawk-4.1.0-eval_invalid_free.patch
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
Conflicts: filesystem < 3
Provides: /bin/awk
Provides: /bin/gawk
BuildRequires: byacc
BuildRequires: bison
%description
The gawk package contains the GNU version of awk, a text processing
@ -26,13 +27,14 @@ considered to be a standard Linux tool for processing text.
%prep
%setup -q
%patch0 -p1 -b eval_invalid_free
%build
%configure --with-libsigsegv-prefix=no
make %{?_smp_mflags}
%check
make check diffout
make check
%install
rm -rf $RPM_BUILD_ROOT
@ -74,6 +76,15 @@ fi
%{_libdir}/gawk/*
%changelog
* Fri Jan 02 2015 jchaloup <jchaloup@redhat.com> - 4.1.0-4
- Change build dependency to bison, fix make check
resolves: #1176993
resolves: #1177001
* Tue May 13 2014 jchaloup <jchaloup@redhat.com> - 4.1.0-3
- resolves: #1089073
eval invalid free
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild