diff
--- a/libtiff/tif_ps.c
+++ b/libtiff/tif_ps.c
@@ -57,7 +57,9 @@
                                  case 1: c = *cp++; PUTHEX(c,fd);
                                  }
                                  cp += es;
-                                 }
+                                 if (cp > tf_buf + tf_bytesperrow) {
+                                    TIFFError(filename, "Color channel configuration error");
+                                }
 58                         }
 59                 }
 60         }

