fix buffer overflow issue with kghostview.

--
Patch from: Dirk Mueller <mueller@kde.org> via espie@
This commit is contained in:
brad 2002-09-28 22:50:29 +00:00
parent 79968cbb18
commit 1f734883ac
4 changed files with 65 additions and 4 deletions

View File

@ -1,13 +1,11 @@
# $OpenBSD: Makefile,v 1.9 2002/09/01 08:25:25 espie Exp $
# $OpenBSD: Makefile,v 1.10 2002/09/28 22:50:29 brad Exp $
COMMENT= "X11 toolkit, graphic applications"
CATEGORIES= x11 x11/kde
VERSION= 3.0.3
DISTNAME= kdegraphics-${VERSION}
PKGNAME= ${DISTNAME}p1
#LIB_DEPENDS= kdecore.4,DCOP,artskde,kdeui,khtml,kio,kparts::x11/kde/libs3 \
# kateinterfaces,konq,konqsidebarplugin::x11/kde/base3 \
# kmedia2_idl,qtmcop,soundserver_idl::x11/kde/arts3
LIB_DEPENDS=Imlib::graphics/imlib \
ungif::graphics/libungif \
kdecore.4,DCOP,kdefx,kdeprint,kdesu,kdeui,kio,kparts::x11/kde/libs3

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-kghostview_dscparse_cpp,v 1.1 2002/09/28 22:50:30 brad Exp $
--- kghostview/dscparse.cpp.orig Sun Feb 17 12:38:24 2002
+++ kghostview/dscparse.cpp Sat Sep 28 18:15:56 2002
@@ -973,9 +973,13 @@ dsc_read_line(CDSC *dsc)
*/
char begindata[MAXSTR+1];
int cnt;
+ unsigned int num;
const char *numberof, *bytesorlines;
- memcpy(begindata, dsc->line, dsc->line_length);
- begindata[dsc->line_length] = '\0';
+ if ((num = dsc->line_length) >= sizeof(begindata)-1)
+ num = sizeof(begindata)-1;
+
+ memcpy(begindata, dsc->line, num);
+ begindata[num] = '\0';
numberof = strtok(begindata+12, " \r\n");
strtok(NULL, " \r\n"); /* dump type */
bytesorlines = strtok(NULL, " \r\n");

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-kghostview_kgv_miniwidget_cpp,v 1.1 2002/09/28 22:50:30 brad Exp $
--- kghostview/kgv_miniwidget.cpp.orig Mon Mar 18 07:42:36 2002
+++ kghostview/kgv_miniwidget.cpp Sat Sep 28 18:12:33 2002
@@ -1146,7 +1146,8 @@ bool KGVMiniWidget::psCopyDoc( const QSt
free( comment );
continue;
}
- sscanf( comment + length("%%Pages:" ), "%s", text );
+ sscanf( comment + length("%%Pages:" ), "%256s", text );
+ text[256] = 0; // Just in case of an overflow
if( strcmp( text, "(atend)" ) == 0 ) {
fputs( comment, to );
pages_atend = true;

View File

@ -0,0 +1,31 @@
$OpenBSD: patch-kghostview_ps_c,v 1.1 2002/09/28 22:50:30 brad Exp $
--- kghostview/ps.c.orig Mon Jan 28 16:05:43 2002
+++ kghostview/ps.c Sat Sep 28 18:12:33 2002
@@ -71,9 +71,11 @@ pscopy(from, to, begin, end)
if (!(DSCcomment(line) && iscomment(line+2, "Begin"))) {
/* Do nothing */
} else if (iscomment(line+7, "Data:")) {
+ int rc = 0;
text[0] = '\0';
- if (sscanf(line+length("%%BeginData:"),
- "%d %*s %s", &num, text) >= 1) {
+ rc = sscanf(line+length("%%BeginData:"), "%d %*s %256s", &num,text);
+ text[256] = '\0';
+ if (rc >= 1) {
if (strcmp(text, "Lines") == 0) {
for (i=0; i < num; i++) {
fgets(line, sizeof line, from);
@@ -148,9 +150,11 @@ pscopyuntil(from, to, begin, end, commen
if (!(DSCcomment(line) && iscomment(line+2, "Begin"))) {
/* Do nothing */
} else if (iscomment(line+7, "Data:")) {
+ int rc = 0;
text[0] = '\0';
- if (sscanf(line+length("%%BeginData:"),
- "%d %*s %s", &num, text) >= 1) {
+ rc = sscanf(line+length("%%BeginData:"), "%d %*s %256s", &num,text);
+ text[256] = '\0';
+ if (rc >= 1) {
if (strcmp(text, "Lines") == 0) {
for (i=0; i < num; i++) {
fgets(line, sizeof line, from);