about summary refs log tree commit diff
path: root/converter/ppm
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-12-05 23:14:27 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-12-05 23:14:27 +0000
commit6683d5b2fb677b5c165035ac04ec84c8566745ba (patch)
treec64d5db5f8270480ab2f043fd3388a4b5904b950 /converter/ppm
parentacf1c3cd5f989ff0e2a3895f35875c918b4c3eb8 (diff)
downloadnetpbm-mirror-6683d5b2fb677b5c165035ac04ec84c8566745ba.tar.gz
netpbm-mirror-6683d5b2fb677b5c165035ac04ec84c8566745ba.tar.xz
netpbm-mirror-6683d5b2fb677b5c165035ac04ec84c8566745ba.zip
Release 10.47.71
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@3450 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/ppm')
-rw-r--r--converter/ppm/picttoppm.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/converter/ppm/picttoppm.c b/converter/ppm/picttoppm.c
index 9a7d8e7c..77efc6f2 100644
--- a/converter/ppm/picttoppm.c
+++ b/converter/ppm/picttoppm.c
@@ -790,19 +790,25 @@ dumpRect(const char * const label,
 static void
 read_rect(struct Rect * const r) {
 
-    r->top    = read_word();
-    r->left   = read_word();
-    r->bottom = read_word();
-    r->right  = read_word();
-
-    if (r->top > r->bottom || r->right < r->left)
-        dumpRect("Invalid rectangle", *r);
-
-    if (r->top > r->bottom)
-        pm_error("Invalid PICT: a rectangle has a top below its bottom");
-    if (r->right < r->left)
-        pm_error("Invalid PICT: a rectangle has a right edge "
-                 "left of its left edge");
+    /* We don't have a formal specification for the Pict format, but we have
+       seen samples that have the rectangle corners either in top left, bottom
+       right order or bottom right, top left.  top left, bottom right is the
+       only one Picttoppm handled until October 2018, when we saw several
+       images in the bottom right, top left order and other Pict processing
+       programs considered that fine.
+
+       So now we accept all 4 possibilities.
+    */
+
+    word const y1 = read_word();
+    word const x1 = read_word();
+    word const y2 = read_word();
+    word const x2 = read_word();
+
+    r->top    = MIN(y1, y2);
+    r->left   = MIN(x1, x2);
+    r->bottom = MAX(y1, y2);
+    r->right  = MAX(x1, x2);
 }