Fixed overflow in yyerror

Resolves: rhbz#1049167
This commit is contained in:
Jaroslav Škarvada 2014-01-07 11:29:26 +01:00
parent e860ef1e41
commit ba78633489
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,40 @@
diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l
index e2215d1..f41049d 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 */
@@ -192,13 +193,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); }

View File

@ -51,7 +51,7 @@
Name: graphviz Name: graphviz
Summary: Graph Visualization Tools Summary: Graph Visualization Tools
Version: 2.30.1 Version: 2.30.1
Release: 10%{?dist} Release: 11%{?dist}
Group: Applications/Multimedia Group: Applications/Multimedia
License: EPL License: EPL
URL: http://www.graphviz.org/ URL: http://www.graphviz.org/
@ -75,6 +75,8 @@ Patch9: graphviz-2.30.1-lefty-help.patch
Patch10: graphviz-2.30.1-prune-help.patch Patch10: graphviz-2.30.1-prune-help.patch
# Sent upstream, ticket #2307 # Sent upstream, ticket #2307
Patch11: graphviz-2.30.1-man-fix.patch Patch11: graphviz-2.30.1-man-fix.patch
# Fix yyerror overflow (#1049167)
Patch12: graphviz-2.30.1-yyerror-overflow-fix.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: zlib-devel, libpng-devel, libjpeg-devel, expat-devel, freetype-devel >= 2 BuildRequires: zlib-devel, libpng-devel, libjpeg-devel, expat-devel, freetype-devel >= 2
BuildRequires: ksh, bison, m4, flex, tk-devel, tcl-devel >= 8.3, swig BuildRequires: ksh, bison, m4, flex, tk-devel, tcl-devel >= 8.3, swig
@ -282,6 +284,7 @@ Various tcl packages (extensions) for the graphviz tools.
%patch9 -p1 -b .lefty-help %patch9 -p1 -b .lefty-help
%patch10 -p1 -b .prune-help %patch10 -p1 -b .prune-help
%patch11 -p1 -b .man-fix %patch11 -p1 -b .man-fix
%patch12 -p1 -b .yyerror-overflow-fix
# Attempt to fix rpmlint warnings about executable sources # Attempt to fix rpmlint warnings about executable sources
find -type f -regex '.*\.\(c\|h\)$' -exec chmod a-x {} ';' find -type f -regex '.*\.\(c\|h\)$' -exec chmod a-x {} ';'
@ -558,6 +561,10 @@ rm -rf %{buildroot}
%changelog %changelog
* Tue Jan 7 2014 Jaroslav Škarvada <jskarvad@redhat.com> - 2.30.1-11
- Fixed overflow in yyerror
Resolves: rhbz#1049167
* Fri Jul 12 2013 Jaroslav Škarvada <jskarvad@redhat.com> - 2.30.1-10 * Fri Jul 12 2013 Jaroslav Škarvada <jskarvad@redhat.com> - 2.30.1-10
- Various man and built-in help fixes - Various man and built-in help fixes