[packages/mpack] Rel 6. Fix build with GCC 14+, wrong Content-MD5 and file names

arekm arekm at pld-linux.org
Tue Dec 1 15:15:25 CET 2026


commit 866b5cc1f39745c1503b82cb7adf69a7ab96b413
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Dec 1 15:14:53 2026 +0100

    Rel 6. Fix build with GCC 14+, wrong Content-MD5 and file names
    
    Fixes CVE-2011-4919.
    
    The gentoo patch is dropped: its mkstemp() pre-created the temporary
    file that os_createnewfile() opens with O_EXCL, so mpack failed with
    "File exists" whenever it mailed a message.

 mpack-disposition-filename.patch |  18 +++
 mpack-gentoo.patch               |  36 -----
 mpack-md5-uint32.patch           |  26 ++++
 mpack-perms.patch                |  19 +++
 mpack-prototypes.patch           | 294 +++++++++++++++++++++++++++++++++++++++
 mpack.spec                       |  16 ++-
 6 files changed, 369 insertions(+), 40 deletions(-)
---
diff --git a/mpack.spec b/mpack.spec
index cf5145e..71c49e7 100644
--- a/mpack.spec
+++ b/mpack.spec
@@ -2,13 +2,16 @@ Summary:	mpack and munpack MIME e-mail utilities
 Summary(pl.UTF-8):	mpack i munpack - narzędzia MIME do poczty elektronicznej
 Name:		mpack
 Version:	1.6
-Release:	5
+Release:	6
 License:	distributable
 Group:		Applications/Mail
-Source0:	ftp://ftp.andrew.cmu.edu/pub/mpack/%{name}-%{version}.tar.gz
+Source0:	https://ftp.debian.org/debian/pool/main/m/mpack/%{name}_%{version}.orig.tar.gz
 # Source0-md5:	a70fa5afa76539a9afb70b9d81568fe8
 Patch0:		%{name}-tmp.patch
-Patch1:		%{name}-gentoo.patch
+Patch1:		%{name}-prototypes.patch
+Patch2:		%{name}-perms.patch
+Patch3:		%{name}-md5-uint32.patch
+Patch4:		%{name}-disposition-filename.patch
 BuildRequires:	autoconf
 BuildRequires:	automake
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -34,12 +37,17 @@ poleceń) wysyłać pliki pocztą.
 %setup -q
 %patch -P0 -p1
 %patch -P1 -p1
+%patch -P2 -p1
+%patch -P3 -p1
+%patch -P4 -p1
 
 %build
 %{__aclocal} -I cmulocal
 %{__autoconf}
 %{__automake}
-%configure
+# md5.h declares K&R-style () prototypes unless PROTOTYPES is set; C23 reads them as (void)
+%configure \
+	CPPFLAGS="%{rpmcppflags} -DPROTOTYPES=1"
 %{__make}
 
 %install
diff --git a/mpack-disposition-filename.patch b/mpack-disposition-filename.patch
new file mode 100644
index 0000000..10d0108
--- /dev/null
+++ b/mpack-disposition-filename.patch
@@ -0,0 +1,18 @@
+getDispositionFilename() looked for ";" after "filename", so the name in
+Content-Disposition was never used and parts were saved as partN. From
+Debian 01_legacy.patch.
+
+diff -urNp mpack-1.6.orig/decode.c mpack-1.6/decode.c
+--- mpack-1.6.orig/decode.c	2026-12-01 15:07:09.857916875 +0100
++++ mpack-1.6/decode.c	2026-12-01 15:07:59.687369221 +0100
+@@ -571,8 +571,8 @@ getDispositionFilename(char *disposition
+ 	SkipWhitespace(&disposition);
+ 	if (!disposition) return 0;
+ 
+-	/* If we're looking at a ";", we found what we're looking for */
+-	if (*disposition++ == ';') break;
++	/* If we're looking at a "=", we found what we're looking for */
++	if (*disposition++ == '=') break;
+     }
+ 
+     SkipWhitespace(&disposition);
diff --git a/mpack-gentoo.patch b/mpack-gentoo.patch
deleted file mode 100644
index 04de782..0000000
--- a/mpack-gentoo.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff -bur mpack-1.6-orig/unixos.c mpack-1.6/unixos.c
---- mpack-1.6-orig/unixos.c	2007-03-11 02:02:02.000000000 +0100
-+++ mpack-1.6/unixos.c	2007-03-11 02:04:48.000000000 +0100
-@@ -39,7 +39,7 @@
- #endif
- 
- extern int errno;
--extern char *malloc();
-+extern void *malloc();
- extern char *getenv();
- 
- int overwrite_files = 0;
-diff -bur mpack-1.6-orig/unixpk.c mpack-1.6/unixpk.c
---- mpack-1.6-orig/unixpk.c	2007-03-11 02:02:02.000000000 +0100
-+++ mpack-1.6/unixpk.c	2007-03-11 02:14:02.000000000 +0100
-@@ -167,7 +167,7 @@
- 	    strcpy(fnamebuf, "/usr/tmp");
- 	}
- 	strcat(fnamebuf, "/mpackXXXXXX");
--	mktemp(fnamebuf);
-+	mkstemp(fnamebuf);
- 	outfname = strsave(fnamebuf);
-     }
- 
-diff -bur mpack-1.6-orig/xmalloc.c mpack-1.6/xmalloc.c
---- mpack-1.6-orig/xmalloc.c	2007-03-11 02:02:02.000000000 +0100
-+++ mpack-1.6/xmalloc.c	2007-03-11 02:04:29.000000000 +0100
-@@ -24,7 +24,7 @@
-  */
- #include <stdio.h>
- #include <string.h>
--extern char *malloc(), *realloc();
-+extern void *malloc(), *realloc();
- 
- char *xmalloc (int size)
- {
diff --git a/mpack-md5-uint32.patch b/mpack-md5-uint32.patch
new file mode 100644
index 0000000..8715c6b
--- /dev/null
+++ b/mpack-md5-uint32.patch
@@ -0,0 +1,26 @@
+UINT4 is unsigned long, 64 bits on LP64: the MD5 rotations then carry high
+bits and every Content-MD5 mpack writes or munpack checks is wrong. From
+Debian 01_legacy.patch.
+
+diff -urNp mpack-1.6.orig/md5.h mpack-1.6/md5.h
+--- mpack-1.6.orig/md5.h	2003-07-21 22:35:31.000000000 +0200
++++ mpack-1.6/md5.h	2026-12-01 15:07:59.570986397 +0100
+@@ -34,14 +34,16 @@ The following makes PROTOTYPES default t
+ #define PROTOTYPES 0
+ #endif
+ 
++#include <stdint.h>
++
+ /* POINTER defines a generic pointer type */
+ typedef unsigned char *POINTER;
+ 
+ /* UINT2 defines a two byte word */
+-typedef unsigned short int UINT2;
++typedef uint16_t UINT2;
+ 
+ /* UINT4 defines a four byte word */
+-typedef unsigned long int UINT4;
++typedef uint32_t UINT4;
+ 
+ /* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
+ If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
diff --git a/mpack-perms.patch b/mpack-perms.patch
new file mode 100644
index 0000000..c4db15b
--- /dev/null
+++ b/mpack-perms.patch
@@ -0,0 +1,19 @@
+CVE-2011-4919: files created by mpack/munpack, including the message mpack
+spools in $TMPDIR before mailing it, were world-readable. From Debian:
+https://sources.debian.org/src/mpack/1.6-19/debian/patches/02_fix-permissions.patch/
+
+diff -urNp mpack-1.6.orig/unixos.c mpack-1.6/unixos.c
+--- mpack-1.6.orig/unixos.c	2026-12-01 15:07:09.865916392 +0100
++++ mpack-1.6/unixos.c	2026-12-01 15:07:59.453979601 +0100
+@@ -143,9 +143,9 @@ FILE *os_createnewfile(char *fname)
+     FILE *ret;
+      
+ #ifdef O_EXCL
+-    fd=open(fname, O_RDWR|O_CREAT|O_EXCL, 0644);
++    fd=open(fname, O_RDWR|O_CREAT|O_EXCL, 0600);
+ #else
+-    fd=open(fname, O_RDWR|O_CREAT|O_TRUNC, 0644);
++    fd=open(fname, O_RDWR|O_CREAT|O_TRUNC, 0600);
+ #endif
+ 
+     if (fd == -1)
diff --git a/mpack-prototypes.patch b/mpack-prototypes.patch
new file mode 100644
index 0000000..defe8f4
--- /dev/null
+++ b/mpack-prototypes.patch
@@ -0,0 +1,294 @@
+Missing includes and prototypes; GCC 14+ rejects the implicit declarations
+and C23 the K&R-style externs. Prototype hunks from Debian 01_legacy.patch:
+https://sources.debian.org/src/mpack/1.6-19/debian/patches/01_legacy.patch/
+
+diff -urNp mpack-1.6.orig/decode.c mpack-1.6/decode.c
+--- mpack-1.6.orig/decode.c	2003-07-21 22:47:54.000000000 +0200
++++ mpack-1.6/decode.c	2026-12-01 15:07:09.857916875 +0100
+@@ -26,8 +26,10 @@
+  * SOFTWARE.  */
+ 
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
++#include <unistd.h>
+ #include "xmalloc.h"
+ #include "common.h"
+ #include "part.h"
+@@ -37,6 +39,19 @@ extern char *os_idtodir(char *id);
+ extern FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentParams);
+ extern FILE *os_createnewfile(char *fname);
+ extern char *md5contextTo64(MD5_CTX *context);
++extern void warn(char *s);
++extern void os_perror(char *str);
++extern void chat(char *s);
++extern void os_donewithdir(char *dir);
++extern void os_warnMD5mismatch(void);
++extern void os_closetypedfile(FILE *outfile);
++
++extern int part_depth(struct part *part);
++extern void part_ungets(char *s, struct part *part);
++extern void part_close(struct part *part);
++extern int part_fill(struct part *part);
++extern void part_addboundary(struct part *part, char *boundary);
++extern int part_readboundary(struct part *part);
+ 
+ /* The possible content transfer encodings */
+ enum encoding { enc_none, enc_qp, enc_base64 };
+@@ -49,6 +64,17 @@ char *getDispositionFilename(char *dispo
+ void from64(struct part *inpart, FILE *outfile, char **digestp, int suppressCR);
+ void fromqp(struct part *inpart, FILE *outfile, char **digestp);
+ void fromnone(struct part *inpart, FILE *outfile, char **digestp);
++int handlePartial(struct part *inpart, char *headers, params contentParams,
++		  int extractText);
++int ignoreMessage(struct part *inpart);
++int handleMultipart(struct part *inpart, char *contentType,
++		    params contentParams, int extractText);
++int handleUuencode(struct part *inpart, char *subject, int extractText);
++int handleText(struct part *inpart, enum encoding contentEncoding);
++int saveToFile(struct part *inpart, int inAppleDouble, char *contentType,
++	       params contentParams, enum encoding contentEncoding,
++	       char *contentDisposition, char *contentMD5);
++
+ /*
+  * Read and handle an RFC 822 message from the body-part 'inpart'.
+  */
+diff -urNp mpack-1.6.orig/encode.c mpack-1.6/encode.c
+--- mpack-1.6.orig/encode.c	2003-07-21 22:35:31.000000000 +0200
++++ mpack-1.6/encode.c	2026-12-01 15:07:09.867005006 +0100
+@@ -23,12 +23,15 @@
+  * SOFTWARE.
+  */
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <string.h>
+ 
+ extern char *magic_look(FILE *infile);
+ extern char *os_genid(void);
+ extern FILE *os_createnewfile(char *fname);
+ extern char *md5digest(FILE *infile, long int *len);
++extern void os_perror(char *str);
++extern int to64(FILE *infile, FILE *outfile, long int limit);
+ 
+ #define NUMREFERENCES 4
+ 
+diff -urNp mpack-1.6.orig/magic.c mpack-1.6/magic.c
+--- mpack-1.6.orig/magic.c	2003-07-21 22:35:31.000000000 +0200
++++ mpack-1.6/magic.c	2026-12-01 15:06:52.139909022 +0100
+@@ -23,6 +23,7 @@
+  * SOFTWARE.
+  */
+ #include <stdio.h>
++#include <string.h>
+ 
+ /* Description of the various file formats and their magic numbers */
+ struct magic {
+diff -urNp mpack-1.6.orig/part.c mpack-1.6/part.c
+--- mpack-1.6.orig/part.c	2003-07-21 22:35:31.000000000 +0200
++++ mpack-1.6/part.c	2026-12-01 15:06:52.139455302 +0100
+@@ -27,6 +27,7 @@
+  */
+ 
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <string.h>
+ 
+ #include "part.h"
+@@ -58,7 +59,7 @@ struct part *part_init(FILE *infile)
+ /*
+  * Close and free 'part'.
+  */
+-int part_close(struct part *part)
++void part_close(struct part *part)
+ {
+     fclose(part->infile);
+     if (part->buf) free(part->buf);
+@@ -77,8 +78,7 @@ part_depth(struct part *part)
+ /*
+  * Add to 'part' the multipart boundary 'boundary'.
+  */
+-int
+-part_addboundary(struct part *part, char *boundary)
++void part_addboundary(struct part *part, char *boundary)
+ {
+     /* Grow boundary array if necessary */
+     if (part->boundary_num == part->boundary_alloc) {
+@@ -165,8 +165,7 @@ part_gets(char *s, int n, struct part *p
+  * Leaves room in the input buffer to push back an additional single
+  * character using the prot_ungetc() macro.
+  */
+-int
+-part_ungets(char *s, struct part *part)
++void part_ungets(char *s, struct part *part)
+ {
+     int len = strlen(s);
+     int i;
+diff -urNp mpack-1.6.orig/unixos.c mpack-1.6/unixos.c
+--- mpack-1.6.orig/unixos.c	2026-12-01 15:06:45.617165388 +0100
++++ mpack-1.6/unixos.c	2026-12-01 15:07:09.865916392 +0100
+@@ -23,24 +23,30 @@
+  * SOFTWARE.
+  */
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <ctype.h>
+ #include <string.h>
+ #include <errno.h>
+ #include <sys/types.h>
++#include <sys/stat.h>
+ #include <sys/param.h>
++#include <time.h>
+ #include <netdb.h>
+ #include <fcntl.h>
++#include <unistd.h>
+ #include "xmalloc.h"
+ #include "common.h"
+ #include "part.h"
+ 
++extern void warn(char *s);
++
+ #ifndef MAXHOSTNAMELEN
+ #define MAXHOSTNAMELEN 64
+ #endif
+ 
++#ifndef errno
+ extern int errno;
+-extern char *malloc();
+-extern char *getenv();
++#endif
+ 
+ int overwrite_files = 0;
+ int didchat;
+diff -urNp mpack-1.6.orig/unixpk.c mpack-1.6/unixpk.c
+--- mpack-1.6.orig/unixpk.c	2026-12-01 15:06:45.617747842 +0100
++++ mpack-1.6/unixpk.c	2026-12-01 15:07:09.866570967 +0100
+@@ -23,23 +23,26 @@
+  * SOFTWARE.
+  */
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <string.h>
+ #include <errno.h>
++#include <getopt.h>
++#include <sys/types.h>
++#include <sys/wait.h>
++#include <unistd.h>
+ #include "common.h"
+ #include "version.h"
+ #include "xmalloc.h"
+ 
+ #define MAXADDRESS 100
+ 
+-extern char *getenv();
+-
+-extern int errno;
+-extern int optind;
+-extern char *optarg;
+-
+ void usage(void);
+ void sendmail(FILE *infile, char **addr, int start);
+ void inews(FILE *infile);
++void os_perror(char *str);
++int encode(FILE *infile, FILE *applefile, char *fname, FILE *descfile,
++	   char *subject, char *headers, long int maxsize,
++	   char *typeoverride, char *outfname);
+ 
+ int main(int argc, char **argv)
+ {
+diff -urNp mpack-1.6.orig/unixunpk.c mpack-1.6/unixunpk.c
+--- mpack-1.6.orig/unixunpk.c	2003-07-21 22:51:55.000000000 +0200
++++ mpack-1.6/unixunpk.c	2026-12-01 15:06:52.149989004 +0100
+@@ -23,17 +23,19 @@
+  * SOFTWARE.
+  */
+ #include <stdio.h>
++#include <stdlib.h>
++#include <getopt.h>
++#include <unistd.h>
+ #include "version.h"
+ #include "part.h"
+ 
+-extern int optind;
+-extern char *optarg;
+-
+ extern int overwrite_files;
+ extern int didchat;
+ int quiet;
+ 
+ void usage(void);
++int handleMessage(struct part *inpart, char *defaultContentType,
++		  int inAppleDouble, int extractText);
+ 
+ int main(int argc, char **argv)
+ {
+diff -urNp mpack-1.6.orig/uudecode.c mpack-1.6/uudecode.c
+--- mpack-1.6.orig/uudecode.c	2003-07-21 22:46:37.000000000 +0200
++++ mpack-1.6/uudecode.c	2026-12-01 15:06:52.147065577 +0100
+@@ -23,8 +23,10 @@
+  * SOFTWARE.
+  */
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <ctype.h>
+ #include <string.h>
++#include <unistd.h>
+ #include "xmalloc.h"
+ #include "common.h"
+ #include "part.h"
+@@ -32,9 +34,25 @@
+ extern char *os_idtodir(char *id);
+ extern FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentParams);
+ extern FILE *os_createnewfile(char *fname);
++extern int os_binhex(struct part *inpart, int part, int nparts);
++extern void os_closetypedfile(FILE *outfile);
++extern void os_donewithdir(char *dir);
++extern void os_perror(char *str);
++extern void chat(char *s);
++
++extern void part_ungets(char *s, struct part *part);
++extern void part_close(struct part *part);
++extern int handleMessage(struct part *inpart, char *defaultContentType,
++			 int inAppleDouble, int extractText);
+ 
+ static FILE *startDescFile(char *fname);
++static void uudecodeline(char *line, FILE *outfile);
+ 
++int parseSubject(char *subject, char **fnamep, int *partp, int *npartsp);
++int saveUuFile(struct part *inpart, char *fname, int part, int nparts,
++	       char *firstline);
++int descEnd(char *line);
++int uudecodefiles(char *dir, int nparts);
+ 
+ /* Length of a normal uuencoded line, including newline */
+ #define UULENGTH 62
+@@ -826,7 +844,7 @@ uudecodefiles(char *dir, int nparts)
+ /*
+  * Decode a uuencoded line to 'outfile'
+  */
+-int uudecodeline(char *line, FILE *outfile)
++static void uudecodeline(char *line, FILE *outfile)
+ {
+     int c, len;
+ 
+@@ -845,7 +863,6 @@ int uudecodeline(char *line, FILE *outfi
+ 	}
+ 	line += 4;
+     }
+-    return;
+ }
+ 
+     
+diff -urNp mpack-1.6.orig/xmalloc.c mpack-1.6/xmalloc.c
+--- mpack-1.6.orig/xmalloc.c	2003-07-21 22:35:31.000000000 +0200
++++ mpack-1.6/xmalloc.c	2026-12-01 15:06:52.144751141 +0100
+@@ -23,8 +23,8 @@
+  * SOFTWARE.
+  */
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <string.h>
+-extern char *malloc(), *realloc();
+ 
+ char *xmalloc (int size)
+ {
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/mpack.git/commitdiff/866b5cc1f39745c1503b82cb7adf69a7ab96b413



More information about the pld-cvs-commit mailing list