summary refs log tree commit diff
path: root/pkgs/development/libraries/libspectre
diff options
context:
space:
mode:
authorYury G. Kudryashov <urkud.urkud@gmail.com>2012-08-08 13:44:04 +0400
committerYury G. Kudryashov <urkud.urkud@gmail.com>2012-08-26 22:06:45 +0400
commit1e3c42eb696815f644127fe4e88e0473879da7ae (patch)
tree8b1cd86ac1b90bdc7d02630ed2f9ffb94fbc79d5 /pkgs/development/libraries/libspectre
parentc03efbd8f9201c6c852b5f60016700ebdacea976 (diff)
downloadnixpkgs-1e3c42eb696815f644127fe4e88e0473879da7ae.tar
nixpkgs-1e3c42eb696815f644127fe4e88e0473879da7ae.tar.gz
nixpkgs-1e3c42eb696815f644127fe4e88e0473879da7ae.tar.bz2
nixpkgs-1e3c42eb696815f644127fe4e88e0473879da7ae.tar.lz
nixpkgs-1e3c42eb696815f644127fe4e88e0473879da7ae.tar.xz
nixpkgs-1e3c42eb696815f644127fe4e88e0473879da7ae.tar.zst
nixpkgs-1e3c42eb696815f644127fe4e88e0473879da7ae.zip
Libspectre: a couple of upstream patches (fix 2 crashes)
Diffstat (limited to 'pkgs/development/libraries/libspectre')
-rw-r--r--pkgs/development/libraries/libspectre/0001-Fix-a-crash-with-documents-containing-an-invalid-Pag.patch29
-rw-r--r--pkgs/development/libraries/libspectre/0002-Allocate-at-least-1-page-in-doc-pages.patch38
-rw-r--r--pkgs/development/libraries/libspectre/default.nix2
3 files changed, 69 insertions, 0 deletions
diff --git a/pkgs/development/libraries/libspectre/0001-Fix-a-crash-with-documents-containing-an-invalid-Pag.patch b/pkgs/development/libraries/libspectre/0001-Fix-a-crash-with-documents-containing-an-invalid-Pag.patch
new file mode 100644
index 00000000000..3e232ee5ac5
--- /dev/null
+++ b/pkgs/development/libraries/libspectre/0001-Fix-a-crash-with-documents-containing-an-invalid-Pag.patch
@@ -0,0 +1,29 @@
+From 7500e4d1ae85ecf9f61b1446e07ebb887118757c Mon Sep 17 00:00:00 2001
+From: Carlos Garcia Campos <carlosgc@gnome.org>
+Date: Sat, 30 Oct 2010 15:55:18 +0200
+Subject: [PATCH 1/2] Fix a crash with documents containing an invalid
+ %%Pages: comment
+
+When failed to allocate memory for pages because of invalid %%Pages:
+comment, set maxpages to 0 to ignore the comment. Problem spotted
+by Marek Kasik. Fixes bug #30867.
+---
+ libspectre/ps.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/libspectre/ps.c b/libspectre/ps.c
+index 6c7cfce..4578cec 100644
+--- a/libspectre/ps.c
++++ b/libspectre/ps.c
+@@ -597,6 +597,8 @@ psscan(const char *filename, int scanstyle)
+ 			if (maxpages > 0) {
+ 			    doc->pages = (struct page *) PS_calloc(maxpages,
+ 							   sizeof(struct page));
++                            if (!doc->pages)
++                                maxpages = 0;
+                             CHECK_MALLOCED(doc->pages);
+ 			}
+ 		}
+-- 
+1.7.11
+
diff --git a/pkgs/development/libraries/libspectre/0002-Allocate-at-least-1-page-in-doc-pages.patch b/pkgs/development/libraries/libspectre/0002-Allocate-at-least-1-page-in-doc-pages.patch
new file mode 100644
index 00000000000..09ab9e11c16
--- /dev/null
+++ b/pkgs/development/libraries/libspectre/0002-Allocate-at-least-1-page-in-doc-pages.patch
@@ -0,0 +1,38 @@
+From 8ffd9185f81cb8337cece4c8e3672d0e6a97e935 Mon Sep 17 00:00:00 2001
+From: Marek Kasik <mkasik@redhat.com>
+Date: Wed, 24 Nov 2010 15:54:14 +0100
+Subject: [PATCH 2/2] Allocate at least 1 page in doc->pages
+
+Allocate at least 1 page if there are no %%Pages: or %%Page: comments
+in the PS file (#31512).
+---
+ libspectre/ps.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/libspectre/ps.c b/libspectre/ps.c
+index 4578cec..0130fb4 100644
+--- a/libspectre/ps.c
++++ b/libspectre/ps.c
+@@ -1004,14 +1004,14 @@ psscan(const char *filename, int scanstyle)
+ 	section_len += line_len;
+     }
+ 
++    if (maxpages == 0) {
++	maxpages = 1;
++	doc->pages = (struct page *) PS_calloc(maxpages, sizeof(struct page));
++	CHECK_MALLOCED(doc->pages);
++    }
+ 
+ newpage:
+     while (DSCcomment(line) && iscomment(line+2, "Page:")) {
+-	if (maxpages == 0) {
+-	    maxpages = 1;
+-	    doc->pages = (struct page *) PS_calloc(maxpages, sizeof(struct page));
+-            CHECK_MALLOCED(doc->pages);
+-	}
+ 	label = ps_gettext(line+length("%%Page:"), &next_char);
+ 	if (sscanf(next_char, "%u", &thispage) != 1) thispage = 0;
+ 	if (nextpage == 1) {
+-- 
+1.7.11
+
diff --git a/pkgs/development/libraries/libspectre/default.nix b/pkgs/development/libraries/libspectre/default.nix
index 0be6ac5f4ef..379727aec5c 100644
--- a/pkgs/development/libraries/libspectre/default.nix
+++ b/pkgs/development/libraries/libspectre/default.nix
@@ -13,6 +13,8 @@ stdenv.mkDerivation rec {
     ghostscript
   ];
 
+  patches = [ ./0001-Fix-a-crash-with-documents-containing-an-invalid-Pag.patch ./0002-Allocate-at-least-1-page-in-doc-pages.patch ];
+
   doCheck = true;
 
   meta = {