Fixed overflow in yyerror

Resolves: rhbz#1049167
This commit is contained in:
Jaroslav Škarvada 2014-01-07 10:52:52 +01:00
parent afe4386caa
commit a2040cdc1f
2 changed files with 61 additions and 1 deletions

View File

@ -0,0 +1,53 @@
From 7aaddf52cd98589fb0c3ab72a393f8411838438a Mon Sep 17 00:00:00 2001
From: "Emden R. Gansner" <erg@alum.mit.edu>
Date: Fri, 4 Oct 2013 09:06:39 -0400
Subject: [PATCH] Fix buffer overflow problem when reporting a syntax error
with a very long input line
---
lib/cgraph/scan.l | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l
index 3cfde0f..2efd203 100644
--- a/lib/cgraph/scan.l
+++ b/lib/cgraph/scan.l
@@ -16,6 +16,7 @@
%{
#include <grammar.h>
#include <cghdr.h>
+#include <agxbuf.h>
#include <ctype.h>
#define GRAPH_EOF_TOKEN '@' /* lex class must be defined below */
/* this is a workaround for linux flex */
@@ -191,13 +192,21 @@ ID ({NAME}|{NUMBER})
%%
void yyerror(char *str)
{
+ unsigned char xbuf[BUFSIZ];
char buf[BUFSIZ];
- if (InputFile)
- sprintf(buf,"%s:%d: %s in line %d near '%s'\n",InputFile, line_num,
- str,line_num,yytext);
- else
- sprintf(buf," %s in line %d near '%s'\n", str,line_num,yytext);
- agerr(AGWARN,buf);
+ agxbuf xb;
+
+ agxbinit(&xb, BUFSIZ, xbuf);
+ if (InputFile) {
+ agxbput (&xb, InputFile);
+ agxbput (&xb, ": ");
+ }
+ sprintf(buf," %s in line %d near '", str,line_num);
+ agxbput (&xb, buf);
+ agxbput (&xb, yytext);
+ agxbput (&xb,"'\n");
+ agerr(AGWARN,agxbuse(&xb));
+ agxbfree(&xb);
}
/* must be here to see flex's macro defns */
void aglexeof() { unput(GRAPH_EOF_TOKEN); }
--
1.8.5.1

View File

@ -52,7 +52,7 @@
Name: graphviz
Summary: Graph Visualization Tools
Version: 2.34.0
Release: 6%{?dist}
Release: 7%{?dist}
Group: Applications/Multimedia
License: EPL
URL: http://www.graphviz.org/
@ -63,6 +63,8 @@ Patch1: graphviz-2.32.0-testsuite-sigsegv-fix.patch
Patch2: graphviz-2.32.0-rtest-errout-fix.patch
# Upstream bug 0002387
Patch3: graphviz-2.34.0-lefty-getaddrinfo.patch
# Fix yyerror overflow (#1049167)
Patch4: graphviz-2.34.0-yyerror-overflow-fix.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: zlib-devel, libpng-devel, libjpeg-devel, expat-devel, freetype-devel >= 2
BuildRequires: ksh, bison, m4, flex, tk-devel, tcl-devel >= 8.3, swig
@ -268,6 +270,7 @@ Various tcl packages (extensions) for the graphviz tools.
%patch1 -p1 -b .testsuite-sigsegv-fix
%patch2 -p1 -b .rtest-errout-fix
%patch3 -p1 -b .lefty-getaddrinfo
%patch4 -p1 -b .overflow-yyerror-fix
# Attempt to fix rpmlint warnings about executable sources
find -type f -regex '.*\.\(c\|h\)$' -exec chmod a-x {} ';'
@ -556,6 +559,10 @@ rm -rf %{buildroot}
%changelog
* Tue Jan 7 2014 Jaroslav Škarvada <jskarvad@redhat.com> - 2.34.0-7
- Fixed overflow in yyerror
Resolves: rhbz#1049167
* Sat Dec 28 2013 Peter Robinson <pbrobinson@fedoraproject.org> 2.34.0-6
- Disable R bindings on aarch64 for the moment