Bug#357163: metamail: dumps core with -w option
tag 357163 confirmed patch
thanks
On Wed, Mar 15, 2006 at 06:37:41PM -0500, Norman Ramsey wrote:
> Package: metamail
> Version: 2.7-51
> Severity: normal
>
> Given a mail file with any sort of attachment, metamail -w dumps core.
> Without -w, many mail files are handled without a problem.
> Setting MMDEBUG produces a couple of dates, but nothing useful.
I've attached a crappy patch; it isn't clear to me how to fix it in a
clean yet not invasive way.
Justin
--- old/metamail.c 2006-03-15 18:54:10.000000000 -0500
+++ ./metamail.c 2006-03-15 19:24:24.000000000 -0500
@@ -381,17 +381,20 @@
char Fname[NAME_MAX], *suggestedname, SugBuf[NAME_MAX];
FILE *fp;
int ans = 0, octetstream, ecode=0;
+ int JustMadeTheFile=0;
Fname[0] = 0;
suggestedname = FindParam("name");
- if (strlen(suggestedname) > NAME_MAX - 50)
- suggestedname[NAME_MAX - 50] = '\0';
if (!suggestedname) {
MkTmpFileName(SugBuf);
+ JustMadeTheFile=1;
suggestedname = SugBuf;
- } else if (suggestedname[0] == '"') {
- suggestedname=UnquoteString(suggestedname);
+ } else if (strlen(suggestedname) > NAME_MAX - 50) {
+ suggestedname[NAME_MAX - 50] = '\0';
+ if (suggestedname[0] == '"') {
+ suggestedname=UnquoteString(suggestedname);
+ }
}
octetstream = ! lc2strcmp(ContentType, "application/octet-stream");
if (MightAskBeforeExecuting && !DefinitelyNotTty && !MustNotBeTty) {
@@ -450,7 +453,7 @@
if (DoDebug) fprintf(stderr, "pre access");
- if (access(Fname, F_OK) == 0) {
+ if (!JustMadeTheFile && access(Fname, F_OK) == 0) {
char *s, AnsBuf[50];
int overwriteans = -1;
do {
Reply to: