Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/mail Don't barf on malformed mime messages (missing ...
details: https://anonhg.NetBSD.org/src/rev/5bb0426f29b4
branches: trunk
changeset: 747029:5bb0426f29b4
user: christos <christos%NetBSD.org@localhost>
date: Fri Aug 28 14:26:50 2009 +0000
description:
Don't barf on malformed mime messages (missing mime version). From Anon Ymous
diffstat:
usr.bin/mail/mime_decode.c | 13 ++++++++++---
usr.bin/mail/mime_detach.c | 24 +++++++++++++++++-------
2 files changed, 27 insertions(+), 10 deletions(-)
diffs (104 lines):
diff -r 0ced429270ce -r 5bb0426f29b4 usr.bin/mail/mime_decode.c
--- a/usr.bin/mail/mime_decode.c Fri Aug 28 14:13:24 2009 +0000
+++ b/usr.bin/mail/mime_decode.c Fri Aug 28 14:26:50 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mime_decode.c,v 1.15 2009/04/10 13:08:25 christos Exp $ */
+/* $NetBSD: mime_decode.c,v 1.16 2009/08/28 14:26:50 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#ifndef __lint__
-__RCSID("$NetBSD: mime_decode.c,v 1.15 2009/04/10 13:08:25 christos Exp $");
+__RCSID("$NetBSD: mime_decode.c,v 1.16 2009/08/28 14:26:50 christos Exp $");
#endif /* not __lint__ */
#include <assert.h>
@@ -266,9 +266,16 @@
filename = savestr(filename); /* save it! */
}
mip->mi_filename = filename;
+
+ /*
+ * XXX: If we have a "Content-Type" in the header, then assume
+ * we also have a "MIME-Version: 1.0". This fixes some broken
+ * MIME headers that I have seen occasionally.
+ */
+ if (mip->mi_version == NULL && mip->mi_type != NULL)
+ mip->mi_version = MIME_VERSION;
}
-
static struct message *
salloc_message(int flag, long block, short offset)
{
diff -r 0ced429270ce -r 5bb0426f29b4 usr.bin/mail/mime_detach.c
--- a/usr.bin/mail/mime_detach.c Fri Aug 28 14:13:24 2009 +0000
+++ b/usr.bin/mail/mime_detach.c Fri Aug 28 14:26:50 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mime_detach.c,v 1.4 2009/04/10 13:08:25 christos Exp $ */
+/* $NetBSD: mime_detach.c,v 1.5 2009/08/28 14:26:50 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#ifndef __lint__
-__RCSID("$NetBSD: mime_detach.c,v 1.4 2009/04/10 13:08:25 christos Exp $");
+__RCSID("$NetBSD: mime_detach.c,v 1.5 2009/08/28 14:26:50 christos Exp $");
#endif /* not __lint__ */
#include <assert.h>
@@ -178,26 +178,36 @@
{
char *pathname;
char *prompt;
+ const char *partstr;
+ const char *subtype;
+
+ /*
+ * XXX: If partstr == NULL, we probably shouldn't be detaching
+ * anything, but let's be liberal and try to do something with
+ * the block anyway.
+ */
+ partstr = mip->mi_partstr && mip->mi_partstr[0] ? mip->mi_partstr : "0";
+ subtype = mip->mi_subtype ? mip->mi_subtype : "unknown";
/*
* Get the suggested target pathname.
*/
if (mip->mi_filename != NULL)
- (void)sasprintf(&pathname, "%s/%s", mip->mi_detachdir, mip->mi_filename);
+ (void)sasprintf(&pathname, "%s/%s", mip->mi_detachdir,
+ mip->mi_filename);
else {
if (mip->mi_detachall == 0)
return NULL;
(void)sasprintf(&pathname, "%s/msg-%s.part-%s.%s",
mip->mi_detachdir, mip->mi_msgstr,
- mip->mi_partstr[0] ? mip->mi_partstr : "0",
- mip->mi_subtype ? mip->mi_subtype : "unknown");
+ partstr, subtype);
}
/*
* Make up the prompt
*/
- (void)sasprintf(&prompt, "%-7s filename: ", mip->mi_partstr);
+ (void)sasprintf(&prompt, "%-7s filename: ", partstr);
/*
* The main loop.
@@ -218,7 +228,7 @@
return NULL;
continue;
}
- switch (detach_open_core(fname, mip->mi_partstr)) {
+ switch (detach_open_core(fname, partstr)) {
case DETACH_OPEN_OK:
return fname;
case DETACH_NEXT:
Home |
Main Index |
Thread Index |
Old Index