issues.
+2015-09-11 13:25 Christos Zoulas <christos@zoulas.com>
+
+ * add a limit to the length of regex searches
+
2015-09-08 9:50 Christos Zoulas <christos@zoulas.com>
* fix problems with --parameter (Christoph Biedl)
-.\" $File: file.man,v 1.117 2015/06/03 19:51:27 christos Exp $
-.Dd June 3, 2015
+.\" $File: file.man,v 1.118 2015/09/11 17:24:09 christos Exp $
+.Dd September 11, 2015
.Dt FILE __CSECTION__
.Os
.Sh NAME
.It Li elf_notes Ta 256 Ta max ELF notes processed
.It Li elf_phnum Ta 128 Ta max ELF program sections processed
.It Li elf_shnum Ta 32768 Ta max ELF sections processed
+.It Li regex Ta 8192 Ta length limit for regex searches
.El
.It Fl r , Fl Fl raw
Don't translate unprintable characters to \eooo.
-.\" $File: libmagic.man,v 1.37 2015/06/03 18:21:24 christos Exp $
+.\" $File: libmagic.man,v 1.38 2015/09/11 17:24:09 christos Exp $
.\"
.\" Copyright (c) Christos Zoulas 2003.
.\" All Rights Reserved.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 3, 2015
+.Dd September 11, 2015
.Dt LIBMAGIC 3
.Os
.Sh NAME
.It Li MAGIC_PARAM_ELF_NOTES_MAX Ta size_t Ta 256
.It Li MAGIC_PARAM_ELF_PHNUM_MAX Ta size_t Ta 128
.It Li MAGIC_PARAM_ELF_SHNUM_MAX Ta size_t Ta 32768
+.It Li MAGIC_PARAM_REGEX_MAX Ta size_t Ta 8192
.El
.Pp
The
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.236 2015/09/10 14:39:55 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.237 2015/09/11 17:24:09 christos Exp $")
#endif /* lint */
#include "magic.h"
ms->elf_shnum_max = FILE_ELF_SHNUM_MAX;
ms->elf_phnum_max = FILE_ELF_PHNUM_MAX;
ms->elf_notes_max = FILE_ELF_NOTES_MAX;
+ ms->regex_max = FILE_REGEX_MAX;
return ms;
free:
free(ms);
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: file.c,v 1.166 2015/09/08 13:46:49 christos Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.167 2015/09/11 17:24:09 christos Exp $")
#endif /* lint */
#include "magic.h"
{ "elf_phnum", MAGIC_PARAM_ELF_PHNUM_MAX, 0 },
{ "elf_shnum", MAGIC_PARAM_ELF_SHNUM_MAX, 0 },
{ "elf_notes", MAGIC_PARAM_ELF_NOTES_MAX, 0 },
+ { "regex", MAGIC_PARAM_REGEX_MAX, 0 },
};
private char *progname; /* used throughout */
*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.171 2015/08/30 14:16:33 christos Exp $
+ * @(#)$File: file.h,v 1.172 2015/09/11 17:24:09 christos Exp $
*/
#ifndef __file_h__
uint16_t elf_shnum_max;
uint16_t elf_phnum_max;
uint16_t elf_notes_max;
+ uint16_t regex_max;
#define FILE_INDIR_MAX 15
#define FILE_NAME_MAX 30
#define FILE_ELF_SHNUM_MAX 32768
#define FILE_ELF_PHNUM_MAX 2048
#define FILE_ELF_NOTES_MAX 256
+#define FILE_REGEX_MAX 8192
};
/* Type for Unicode characters */
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: magic.c,v 1.94 2015/07/11 14:41:37 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.95 2015/09/11 17:24:09 christos Exp $")
#endif /* lint */
#include "magic.h"
case MAGIC_PARAM_ELF_NOTES_MAX:
ms->elf_notes_max = (uint16_t)*(const size_t *)val;
return 0;
+ case MAGIC_PARAM_REGEX_MAX:
+ ms->elf_notes_max = (uint16_t)*(const size_t *)val;
+ return 0;
default:
errno = EINVAL;
return -1;
case MAGIC_PARAM_ELF_NOTES_MAX:
*(size_t *)val = ms->elf_notes_max;
return 0;
+ case MAGIC_PARAM_REGEX_MAX:
+ *(size_t *)val = ms->regex_max;
+ return 0;
default:
errno = EINVAL;
return -1;
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.217 2015/07/27 09:08:10 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.218 2015/09/11 17:24:09 christos Exp $")
#endif /* lint */
#include "magic.h"
if (bytecnt == 0 || bytecnt > nbytes - offset)
bytecnt = nbytes - offset;
+ if (bytecnt > ms->regex_max)
+ bytecnt = ms->regex_max;
buf = RCAST(const char *, s) + offset;
end = last = RCAST(const char *, s) + bytecnt + offset;