about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
Diffstat (limited to 'converter')
-rw-r--r--converter/other/bmptopnm.c8
-rw-r--r--converter/other/jpeg2000/Makefile2
-rw-r--r--converter/other/pnmtojpeg.c4
3 files changed, 10 insertions, 4 deletions
diff --git a/converter/other/bmptopnm.c b/converter/other/bmptopnm.c
index 88f8ccce..3d108bf7 100644
--- a/converter/other/bmptopnm.c
+++ b/converter/other/bmptopnm.c
@@ -372,10 +372,16 @@ readWindowsBasic40ByteInfoHeader(FILE *                 const ifP,
 -----------------------------------------------------------------------------*/
     int colorsimportant;   /* ColorsImportant value from header */
     int colorsused;        /* ColorsUsed value from header */
+    long colsField;
 
     headerP->class = C_WIN;
 
-    headerP->cols = GetLong(ifP);
+    colsField = GetLong(ifP);
+
+    if (colsField <= 0)
+        pm_error("Invalid BMP file: says width is %ld", colsField);
+
+    headerP->cols = (unsigned long)colsField;
     {
         long const cy = GetLong(ifP);
         if (cy == 0)
diff --git a/converter/other/jpeg2000/Makefile b/converter/other/jpeg2000/Makefile
index f4fee87f..f2e3b4a1 100644
--- a/converter/other/jpeg2000/Makefile
+++ b/converter/other/jpeg2000/Makefile
@@ -57,7 +57,7 @@ all: $(BINARIES)
 
 include $(SRCDIR)/common.mk
 
-LIBOPTS = $(shell $(LIBOPT) $(NETPBMLIB) $(JASPERLIB_USE))
+LIBOPTS = $(shell $(LIBOPT) $(JASPERLIB_USE) $(NETPBMLIB))
 
 $(BINARIES): %: %.o $(JASPERLIB_DEP) $(NETPBMLIB) $(LIBOPT)
 	$(LD) -o $@ $< \
diff --git a/converter/other/pnmtojpeg.c b/converter/other/pnmtojpeg.c
index 198aa156..b33b36b3 100644
--- a/converter/other/pnmtojpeg.c
+++ b/converter/other/pnmtojpeg.c
@@ -230,7 +230,7 @@ parseCommandLine(const int argc, char ** argv,
     char ** argv_parse;
         /* argv, except we modify it as we parse */
 
-    MALLOCARRAY(argv_parse, argc);
+    MALLOCARRAY(argv_parse, argc + 1);  /* +1 for the terminating null ptr */
 
     option_def_index = 0;   /* incremented by OPTENTRY */
     OPTENT3(0, "verbose",     OPT_FLAG,   NULL, &cmdlineP->verbose,        0);
@@ -273,7 +273,7 @@ parseCommandLine(const int argc, char ** argv,
 
     /* Make private copy of arguments for optParseOptions to corrupt */
     argc_parse = argc;
-    for (i=0; i < argc; i++) argv_parse[i] = argv[i];
+    for (i=0; i < argc+1; i++) argv_parse[i] = argv[i];
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */