- magic fix for short files

- knf
from Anon Ymous
This commit is contained in:
christos 2009-04-11 14:22:32 +00:00
parent 5f950b1010
commit 27b54bd918
7 changed files with 35 additions and 27 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.31 2009/04/10 13:08:24 christos Exp $
# $NetBSD: Makefile,v 1.32 2009/04/11 14:22:32 christos Exp $
# @(#)Makefile 8.3 (Berkeley) 4/20/95
.include <bsd.own.mk>
@ -15,6 +15,7 @@ THREAD_SUPPORT?=yes # EXPERIMENTAL
#
CPPFLAGS+= -DBROKEN_EXEC_TTY_RESTORE # broken since 4.99.10
CPPFLAGS+= -DBROKEN_CLONE_STAT # see PRs 37878 and 37550
CPPFLAGS+= -DBROKEN_MAGIC # bad MIME type on short files
# Debugging options (most should go away - please leave for now).
#

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmd3.c,v 1.40 2009/04/10 13:08:24 christos Exp $ */
/* $NetBSD: cmd3.c,v 1.41 2009/04/11 14:22:32 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95";
#else
__RCSID("$NetBSD: cmd3.c,v 1.40 2009/04/10 13:08:24 christos Exp $");
__RCSID("$NetBSD: cmd3.c,v 1.41 2009/04/11 14:22:32 christos Exp $");
#endif
#endif /* not lint */
@ -477,7 +477,7 @@ forward(void *v)
(void)printf("address missing!\n");
return 1;
}
for ( ip = msgvec; *ip; ip++) {
for (ip = msgvec; *ip; ip++) {
int e;
if ((e = forward_one(*ip, hdr.h_to)) != 0)
return e;
@ -578,7 +578,7 @@ bounce(void *v)
return 1;
smargs = unpack(hdr.h_to);
for ( ip = msgvec; *ip; ip++) {
for (ip = msgvec; *ip; ip++) {
int e;
if ((e = bounce_one(*ip, smargs, hdr.h_to)) != 0)
return e;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmd4.c,v 1.5 2009/04/10 13:08:24 christos Exp $ */
/* $NetBSD: cmd4.c,v 1.6 2009/04/11 14:22:32 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
#if 0
static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95";
#else
__RCSID("$NetBSD: cmd4.c,v 1.5 2009/04/10 13:08:24 christos Exp $");
__RCSID("$NetBSD: cmd4.c,v 1.6 2009/04/11 14:22:32 christos Exp $");
#endif
#endif /* not lint */
@ -137,13 +137,13 @@ printsmoptstbl(void)
int cnt;
cnt = 1;
for (h = 0; h < (int)__arraycount(smoptstbl); h++ )
for (h = 0; h < (int)__arraycount(smoptstbl); h++)
for (sp = smoptstbl[h]; sp && sp->s_name != NULL; sp = sp->s_link)
cnt++;
argv = salloc(cnt * sizeof(*argv));
ap = argv;
for (h = 0; h < (int)__arraycount(smoptstbl); h++ )
for (h = 0; h < (int)__arraycount(smoptstbl); h++)
for (sp = smoptstbl[h]; sp && sp->s_name != NULL; sp = sp->s_link)
*ap++ = sp->s_name;
*ap = NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: fio.c,v 1.32 2009/04/10 13:08:24 christos Exp $ */
/* $NetBSD: fio.c,v 1.33 2009/04/11 14:22:32 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95";
#else
__RCSID("$NetBSD: fio.c,v 1.32 2009/04/10 13:08:24 christos Exp $");
__RCSID("$NetBSD: fio.c,v 1.33 2009/04/11 14:22:32 christos Exp $");
#endif
#endif /* not lint */
@ -235,7 +235,7 @@ setptr(FILE *ibuf, off_t offset)
(void)fwrite(linebuf, sizeof(*linebuf), len, otf);
if (ferror(otf))
err(EXIT_FAILURE, "/tmp");
if(len)
if (len)
linebuf[len - 1] = 0;
if (maybe && linebuf[0] == 'F' && ishead(linebuf)) {
nmsgCount++;

View File

@ -1,4 +1,4 @@
/* $NetBSD: format.c,v 1.14 2009/04/10 13:08:24 christos Exp $ */
/* $NetBSD: format.c,v 1.15 2009/04/11 14:22:32 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef __lint__
__RCSID("$NetBSD: format.c,v 1.14 2009/04/10 13:08:24 christos Exp $");
__RCSID("$NetBSD: format.c,v 1.15 2009/04/11 14:22:32 christos Exp $");
#endif /* not __lint__ */
#include <time.h>
@ -912,7 +912,7 @@ get_display_name(char *name)
if (!quoted && q < qend) {
*q++ = *p;
if (!is_WSP(*p)
/* && !is_specials((unsigned char)*p) */ )
/* && !is_specials((unsigned char)*p) */)
lastq = q;
}
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mime_attach.c,v 1.12 2009/04/10 13:08:25 christos Exp $ */
/* $NetBSD: mime_attach.c,v 1.13 2009/04/11 14:22:32 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef __lint__
__RCSID("$NetBSD: mime_attach.c,v 1.12 2009/04/10 13:08:25 christos Exp $");
__RCSID("$NetBSD: mime_attach.c,v 1.13 2009/04/11 14:22:32 christos Exp $");
#endif /* not __lint__ */
#include <assert.h>
@ -337,10 +337,11 @@ content_type_by_name(char *filename)
magic_t magic;
struct stat sb;
#ifdef BROKEN_MAGIC
/*
* libmagic produces annoying results on very short files.
* The common case is with mime-encode-message defined and an
* empty message body.
* libmagic(3) produces annoying results on very short files.
* The common case is MIME encoding an empty message body.
* XXX - it would be better to fix libmagic(3)!
*
* Note: a 1-byte message body always consists of a newline,
* so size determines all there. However, 1-byte attachments
@ -351,6 +352,7 @@ content_type_by_name(char *filename)
if (sb.st_size < 2 && S_ISREG(sb.st_mode)) {
FILE *fp;
int ch;
if (sb.st_size == 0 || filename == NULL ||
(fp = Fopen(filename, "r")) == NULL)
return "text/plain";
@ -362,6 +364,7 @@ content_type_by_name(char *filename)
"text/plain" : "application/octet-stream";
}
}
#endif
magic = magic_open(MAGIC_MIME);
if (magic == NULL) {
warnx("magic_open: %s", magic_error(magic));

View File

@ -1,4 +1,4 @@
/* $NetBSD: thread.c,v 1.8 2009/04/10 13:08:25 christos Exp $ */
/* $NetBSD: thread.c,v 1.9 2009/04/11 14:22:32 christos Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef __lint__
__RCSID("$NetBSD: thread.c,v 1.8 2009/04/10 13:08:25 christos Exp $");
__RCSID("$NetBSD: thread.c,v 1.9 2009/04/11 14:22:32 christos Exp $");
#endif /* not __lint__ */
#include <assert.h>
@ -450,7 +450,11 @@ thread_fix_old_links(struct message *nmessage, struct message *message, int omsg
message_array.t_head = nmessage; /* for assert check in thread_fix_new_links */
#endif
# define FIX_LINK(p) do { if (p) p = nmessage + (p - message); } while(/*CONSTCOND*/0)
# define FIX_LINK(p) do {\
if (p)\
p = nmessage + (p - message);\
} while (/*CONSTCOND*/0)
FIX_LINK(current_thread.t_head);
for (i = 0; i < omsgCount; i++) {
FIX_LINK(nmessage[i].m_blink);
@ -458,7 +462,7 @@ thread_fix_old_links(struct message *nmessage, struct message *message, int omsg
FIX_LINK(nmessage[i].m_clink);
FIX_LINK(nmessage[i].m_plink);
}
for (i = 0; i < current_thread.t_msgCount; i++ )
for (i = 0; i < current_thread.t_msgCount; i++)
FIX_LINK(current_thread.t_msgtbl[i]);
# undef FIX_LINK
@ -1095,7 +1099,7 @@ tagbelowcmd(void *v)
if (mp) {
depth = mp->m_depth;
for (mp = first_message(current_thread.t_head); mp; mp = next_message(mp))
if (mp->m_depth > depth ) {
if (mp->m_depth > depth) {
mp->m_flag |= MTAGGED;
touch(mp);
}
@ -1449,7 +1453,7 @@ subj_load(struct key_sort_s *marray, size_t mcount, struct message *mp,
#endif
for (i = 0; i < mcount; i++) {
char *subj = hfield(key, mp);
while( strncasecmp(subj, "Re:", 3) == 0 )
while (strncasecmp(subj, "Re:", 3) == 0)
subj = skip_WSP(subj + 3);
marray[i].mp = mp;
marray[i].key.str = subj;
@ -1716,7 +1720,7 @@ deldupscmd(void *v __unused)
redepth(&current_thread);
depth = current_thread.t_head->m_depth;
for (mp = first_message(current_thread.t_head); mp; mp = next_message(mp)) {
if (mp->m_depth > depth ) {
if (mp->m_depth > depth) {
mp->m_flag &= ~(MPRESERVE | MSAVED | MBOX);
mp->m_flag |= MDELETED | MTOUCH;
touch(mp);