Index: ps.c
===================================================================
RCS file: /home/kde/kdegraphics/kghostview/ps.c,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -5 -d -p -r1.11 -r1.11.2.1
--- ps.c        2001/05/04 09:37:49     1.11
+++ ps.c        2002/09/27 02:39:53     1.11.2.1
@@ -224,11 +224,12 @@ psscan(file)
       if (doc == NULL) {
           fprintf(stderr, "Fatal Error: Dynamic memory exhausted.\n");
           exit(-1);
       }
       memset(doc, 0, sizeof(struct document));
-       sscanf(line, "%*s %s", text);
+       sscanf(line, "%*s %256s", text);
+        text[256] = 0;
       doc->epsf = iscomment(text, "EPSF-");
       doc->beginheader = position;
       section_len = line_len;
    } else {
       return(NULL);
@@ -248,11 +249,12 @@ psscan(file)
       } else if (doc->title == NULL && iscomment(line+2, "Title:")) {
           doc->title = gettextline(line+length("%%Title:"));
       } else if (doc->date == NULL && iscomment(line+2, "CreationDate:")) {
           doc->date = gettextline(line+length("%%CreationDate:"));
       } else if (bb_set == NONE && iscomment(line+2, "BoundingBox:")) {
-           sscanf(line+length("%%BoundingBox:"), "%s", text);
+           sscanf(line+length("%%BoundingBox:"), "%256s", text);
+            text[256] = 0;
           if (strcmp(text, "(atend)") == 0) {
               bb_set = ATEND;
           } else {
               if (sscanf(line+length("%%BoundingBox:"), "%d %d %d %d",
                          &(doc->boundingbox[LLX]),
@@ -280,11 +282,12 @@ psscan(file)
                   }
               }
           }
       } else if (orientation_set == NONE &&
                  iscomment(line+2, "Orientation:")) {
-           sscanf(line+length("%%Orientation:"), "%s", text);
+           sscanf(line+length("%%Orientation:"), "%256s", text);
+            text[256] = 0;
           if (strcmp(text, "(atend)") == 0) {
               orientation_set = ATEND;
           } else if (strcmp(text, "Portrait") == 0) {
               doc->orientation = PORTRAIT;
               orientation_set = 1;
@@ -297,11 +300,12 @@ psscan(file)
           } else if (strcmp(text, "Seascape") == 0) {
               doc->orientation = SEASCAPE;
               orientation_set = 1;
           }
       } else if (page_order_set == NONE && iscomment(line+2, "PageOrder:")) {
-           sscanf(line+length("%%PageOrder:"), "%s", text);
+           sscanf(line+length("%%PageOrder:"), "%256s", text);
+            text[256] = 0;
           if (strcmp(text, "(atend)") == 0) {
               page_order_set = ATEND;
           } else if (strcmp(text, "Ascend") == 0) {
               doc->pageorder = ASCEND;
               page_order_set = 1;
@@ -311,11 +315,12 @@ psscan(file)
           } else if (strcmp(text, "Special") == 0) {
               doc->pageorder = SPECIAL;
               page_order_set = 1;
           }
       } else if (pages_set == NONE && iscomment(line+2, "Pages:")) {
-           sscanf(line+length("%%Pages:"), "%s", text);
+           sscanf(line+length("%%Pages:"), "%256s", text);
+            text[256] = 0;
           if (strcmp(text, "(atend)") == 0) {
               pages_set = ATEND;
           } else {
               switch (sscanf(line+length("%%Pages:"), "%d %d",
                              &maxpages, &i)) {
@@ -560,11 +565,12 @@ psscan(file)
           section_len += line_len;
           if (!DSCcomment(line)) {
               /* Do nothing */
           } else if (doc->default_page_orientation == NONE &&
               iscomment(line+2, "PageOrientation:")) {
-               sscanf(line+length("%%PageOrientation:"), "%s", text);
+               sscanf(line+length("%%PageOrientation:"), "%256s", text);
+                text[256] = 0;
               if (strcmp(text, "Portrait") == 0) {
                   doc->default_page_orientation = PORTRAIT;
               } else if (strcmp(text, "Landscape") == 0) {
                   doc->default_page_orientation = LANDSCAPE;
               } else if (strcmp(text, "UpsideDown") == 0) {
@@ -688,11 +694,12 @@ psscan(file)
           preread = 0;
           if (!DSCcomment(line)) {
               /* Do nothing */
           } else if (doc->default_page_orientation == NONE &&
               iscomment(line+2, "PageOrientation:")) {
-               sscanf(line+length("%%PageOrientation:"), "%s", text);
+               sscanf(line+length("%%PageOrientation:"), "%256s", text);
+                text[256] = 0;
               if (strcmp(text, "Portrait") == 0) {
                   doc->default_page_orientation = PORTRAIT;
               } else if (strcmp(text, "Landscape") == 0) {
                   doc->default_page_orientation = LANDSCAPE;
               } else if (strcmp(text, "UpsideDown") == 0) {
@@ -814,11 +821,12 @@ continuepage:
           section_len += line_len;
           if (!DSCcomment(line)) {
               /* Do nothing */
           } else if (doc->pages[doc->numpages].orientation == NONE &&
               iscomment(line+2, "PageOrientation:")) {
-               sscanf(line+length("%%PageOrientation:"), "%s", text);
+               sscanf(line+length("%%PageOrientation:"), "%256s", text);
+                text[256] = 0;
               if (strcmp(text, "Portrait") == 0) {
                   doc->pages[doc->numpages].orientation = PORTRAIT;
               } else if (strcmp(text, "Landscape") == 0) {
                   doc->pages[doc->numpages].orientation = LANDSCAPE;
               } else if (strcmp(text, "UpsideDown") == 0) {
@@ -850,11 +858,12 @@ continuepage:
                   }
               }
               free(cp);
           } else if ((page_bb_set == NONE || page_bb_set == ATEND) &&
                      iscomment(line+2, "PageBoundingBox:")) {
-               sscanf(line+length("%%PageBoundingBox:"), "%s", text);
+               sscanf(line+length("%%PageBoundingBox:"), "%256s", text);
+                text[256] = 0;
               if (strcmp(text, "(atend)") == 0) {
                   page_bb_set = ATEND;
               } else {
                   if (sscanf(line+length("%%PageBoundingBox:"), "%d %d %d %d",
                           &(doc->pages[doc->numpages].boundingbox[LLX]),
@@ -954,22 +963,24 @@ continuepage:
                       doc->boundingbox[URY]++;
               }
           }
       } else if (orientation_set == ATEND &&
                  iscomment(line+2, "Orientation:")) {
-           sscanf(line+length("%%Orientation:"), "%s", text);
+           sscanf(line+length("%%Orientation:"), "%256s", text);
+            text[256] = 0;
           if (strcmp(text, "Portrait") == 0) {
               doc->orientation = PORTRAIT;
           } else if (strcmp(text, "Landscape") == 0) {
               doc->orientation = LANDSCAPE;
           } else if (strcmp(text, "UpsideDown") == 0) {
               doc->orientation = UPSIDEDOWN;
           } else if (strcmp(text, "Seascape") == 0) {
               doc->orientation = SEASCAPE;
           }
       } else if (page_order_set == ATEND && iscomment(line+2, "PageOrder:")) {
-           sscanf(line+length("%%PageOrder:"), "%s", text);
+           sscanf(line+length("%%PageOrder:"), "%256s", text);
+            text[256] = 0;
           if (strcmp(text, "Ascend") == 0) {
               doc->pageorder = ASCEND;
           } else if (strcmp(text, "Descend") == 0) {
               doc->pageorder = DESCEND;
           } else if (strcmp(text, "Special") == 0) {
@@ -1248,13 +1259,16 @@ readline(line, size, fp, position, line_
           *line_len += nbytes;
       }
       *line_len += nbytes;
       strcpy(line, save);
    } else if (iscomment(line+7, "Data:")) {
+        int rc = 0;
       text[0] = '\0';
       strcpy(save, line+7);
-       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++) {
                   cp = fgets(line, size, fp);
                   *line_len += cp ? strlen(line) : 0;
               }
@@ -1323,13 +1337,15 @@ pscopy(from, to, begin, end)
       fputs(line, to);

       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);
                       fputs(line, to);
                   }
@@ -1403,13 +1419,15 @@ pscopyuntil(from, to, begin, end, commen
       }
       fputs(line, to);
       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);
                       fputs(line, to);
                   }
Index: kgv_miniwidget.cpp
===================================================================
RCS file: /home/kde/kdegraphics/kghostview/kgv_miniwidget.cpp,v
retrieving revision 1.100.2.2
retrieving revision 1.100.2.3
diff -u -5 -d -p -u -r1.100.2.2 -r1.100.2.3
--- kgv_miniwidget.cpp  2001/11/08 00:35:51     1.100.2.2
+++ kgv_miniwidget.cpp  2002/09/27 02:39:53     1.100.2.3
@@ -527,11 +527,12 @@ bool KGVMiniWidget::psCopyDoc( const QSt
       here = ftell( from );
       if( pages_written || pages_atend ) {
           free( comment );
           continue;
       }
-       sscanf( comment + length("%%Pages:" ), "%s", text );
+       sscanf( comment + length("%%Pages:" ), "%256s", text );
+        text[256] = 0;
       if( strcmp( text, "(atend)" ) == 0 ) {
           fputs( comment, to );
           pages_atend = true;
       }
       else {