printed, and to return correct code if MIME type is
printed (1, not 0) or if there's an error (-1 not 1).
+ * Fix output of charset for MIME type (precede with semi-colon;
+ fixes Debian bug #501460).
+
+ * Fix potential attacks via conversion specifications in magic
+ strings.
+
2008-10-18 16:45 Christos Zoulas <christos@astron.com>
* Added APPLE file creator/type
-.\" $File: file.man,v 1.75 2008/10/09 17:25:01 christos Exp $
+.\" $File: file.man,v 1.76 2008/10/18 20:47:47 christos Exp $
.Dd October 9, 2008
.Dt FILE __CSECTION__
.Os
.It Fl i , -mime
Causes the file command to output mime type strings rather than the more
traditional human readable ones. Thus it may say
-.Dq text/plain charset=us-ascii
+.Dq text/plain; charset=us-ascii
rather than
.Dq ASCII text .
In order for this option to work, file changes the way
#include "names.h"
#ifndef lint
-FILE_RCSID("@(#)$File: ascmagic.c,v 1.66 2008/10/16 16:31:16 christos Exp $")
+FILE_RCSID("@(#)$File: ascmagic.c,v 1.67 2008/10/18 20:47:48 christos Exp $")
#endif /* lint */
#define MAXLINELEN 300 /* longest sane line length */
if (mime) {
if (mime & MAGIC_MIME_TYPE) {
if (subtype_mime) {
- if (file_printf(ms, subtype_mime) == -1)
+ if (file_printf(ms, "%s", subtype_mime) == -1)
goto done;
} else {
if (file_printf(ms, "text/plain") == -1)
if ((mime == 0 || mime == MAGIC_MIME) && code_mime) {
if ((mime & MAGIC_MIME_TYPE) &&
- file_printf(ms, " charset=") == -1)
+ file_printf(ms, "; charset=") == -1)
goto done;
- if (file_printf(ms, code_mime) == -1)
+ if (file_printf(ms, "%s", code_mime) == -1)
goto done;
}
if (file_printf(ms, "%s", encoding) == -1)
goto done;
} else {
- if (file_printf(ms, code) == -1)
+ if (file_printf(ms, "%s", code) == -1)
goto done;
if (subtype) {
if (file_printf(ms, " ") == -1)
goto done;
- if (file_printf(ms, subtype) == -1)
+ if (file_printf(ms, "%s", subtype) == -1)
goto done;
}
if (file_printf(ms, " ") == -1)
goto done;
- if (file_printf(ms, type) == -1)
+ if (file_printf(ms, "%s", type) == -1)
goto done;
if (has_long_lines)