head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.3
	netbsd-11-0-RC3:1.1.1.3
	netbsd-11-0-RC2:1.1.1.3
	netbsd-11-0-RC1:1.1.1.3
	perseant-exfatfs-base-20250801:1.1.1.3
	netbsd-11:1.1.1.3.0.6
	netbsd-11-base:1.1.1.3
	netbsd-10-1-RELEASE:1.1.1.3
	perseant-exfatfs-base-20240630:1.1.1.3
	perseant-exfatfs:1.1.1.3.0.4
	perseant-exfatfs-base:1.1.1.3
	netbsd-10-0-RELEASE:1.1.1.3
	netbsd-10-0-RC6:1.1.1.3
	netbsd-10-0-RC5:1.1.1.3
	netbsd-10-0-RC4:1.1.1.3
	netbsd-10-0-RC3:1.1.1.3
	netbsd-10-0-RC2:1.1.1.3
	netbsd-10-0-RC1:1.1.1.3
	FILE5_45:1.1.1.3
	netbsd-10:1.1.1.3.0.2
	netbsd-10-base:1.1.1.3
	FILE5_43:1.1.1.3
	cjep_sun2x-base1:1.1.1.2
	cjep_sun2x:1.1.1.2.0.4
	cjep_sun2x-base:1.1.1.2
	cjep_staticlib_x-base1:1.1.1.2
	cjep_staticlib_x:1.1.1.2.0.2
	cjep_staticlib_x-base:1.1.1.2
	FILE5_40:1.1.1.2
	FILE5_39:1.1.1.1
	phil-wifi-20200421:1.1.1.1
	phil-wifi-20200411:1.1.1.1
	phil-wifi:1.1.1.1.0.4
	is-mlppp:1.1.1.1.0.2
	is-mlppp-base:1.1.1.1
	phil-wifi-20200406:1.1.1.1
	FILE5_38:1.1.1.1
	CHRISTOS:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2019.12.17.02.23.53;	author christos;	state Exp;
branches
	1.1.1.1;
next	;
commitid	vqYTz60fS9PNg0PB;

1.1.1.1
date	2019.12.17.02.23.53;	author christos;	state Exp;
branches
	1.1.1.1.4.1;
next	1.1.1.2;
commitid	vqYTz60fS9PNg0PB;

1.1.1.2
date	2021.04.09.18.58.02;	author christos;	state Exp;
branches;
next	1.1.1.3;
commitid	W9ddLLbSkHHinEOC;

1.1.1.3
date	2022.09.24.20.07.54;	author christos;	state Exp;
branches;
next	;
commitid	Nf6F9kcpc0EPC9VD;

1.1.1.1.4.1
date	2019.12.17.02.23.53;	author martin;	state dead;
branches;
next	1.1.1.1.4.2;
commitid	Qli2aW9E74UFuA3C;

1.1.1.1.4.2
date	2020.04.08.14.04.04;	author martin;	state Exp;
branches;
next	;
commitid	Qli2aW9E74UFuA3C;


desc
@@


1.1
log
@Initial revision
@
text
@
#------------------------------------------------------------------------------
# $File: forth,v 1.1 2019/06/06 19:14:20 christos Exp $
# forth:  file(1) magic for various Forth environments
# From: Lubomir Rintel <lkundrak@@v3.sk>
#

# Has a FORTH stack diagram and something that looks very much like a FORTH
# multi-line word definition. Probably a FORTH source.
0       regex   \[[:space:]]\\(([[:space:]].*)?\ --\ (.*[[:space:]])?\\)
>0      regex   \^:\[[:space:]]
>>0     regex   \^;$				FORTH program
!:mime  text/x-forth

# Inline word definition complete with a stack diagram
0       regex   \^:[[:space:]].*[[:space:]]\\(([[:space:]].*)?\ --\ (.*[[:space:]])?\\)[[:space:]].*[[:space:]];$	FORTH program
!:mime  text/x-forth

# Various dictionary images used by OpenFirware FORTH environent

0	lelong	0xe1a00000
>8	lelong	0xe1a00000	ARM OpenFirmware FORTH Dictionary,
>>24	lelong	x		Text length: %d bytes,
>>28	lelong	x		Data length: %d bytes,
>>32	lelong	x		Text Relocation Table length: %d bytes,
>>36	lelong	x		Data Relocation Table length: %d bytes,
>>40	lelong	x		Entry Point: 0x%08X,
>>44	lelong	x		BSS length: %d bytes

0	string	MP
>28	lelong	1		x86 OpenFirmware FORTH Dictionary,
>>4	leshort	x		%d blocks
>>2	leshort	x		+ %d bytes,
>>6	leshort	x		%d relocations,
>>8	leshort	x		Header length: %d paragraphs,
>>10	leshort	x		Data Size: %d
>>12	leshort	x		- %d 4K pages,
>>14	lelong	x		Initial Stack Pointer: 0x%08X,
>>20	lelong	x		Entry Point: 0x%08X,
>>24	lelong	x		First Relocation Item: %d,
>>26	lelong	x		Overlay Number: %d,
>>18	leshort	x		Checksum: 0x%08X

0	belong	0x48000020	PowerPC OpenFirmware FORTH Dictionary,
>4	belong	x		Text length: %d bytes,
>8	belong	x		Data length: %d bytes,
>12	belong	x		BSS length: %d bytes,
>16	belong	x		Symbol Table length: %d bytes,
>20	belong	x		Entry Point: 0x%08X,
>24	belong	x		Text Relocation Table length: %d bytes,
>28	belong	x		Data Relocation Table length: %d bytes

0	lelong	0x10000007	MIPS OpenFirmware FORTH Dictionary,
>4	lelong	x		Text length: %d bytes,
>8	lelong	x		Data length: %d bytes,
>12	lelong	x		BSS length: %d bytes,
>16	lelong	x		Symbol Table length: %d bytes,
>20	lelong	x		Entry Point: 0x%08X,
>24	lelong	x		Text Relocation Table length: %d bytes,
>28	lelong	x		Data Relocation Table length: %d bytes

# Dictionary images used by minimal C FORTH environments, any platform,
# using native byte order.

# Weak.
#0	short	0x5820		cForth 16-bit Dictionary,
#>2	short	x		Serial: 0x%08X,
#>4	short	x		Dictionary Start: 0x%08X,
#>6	short	x		Dictionary Size: %d bytes,
#>8	short	x		User Area Start: 0x%08X,
#>10	short	x		User Area Size: %d bytes,
#>12	short	x		Entry Point: 0x%08X

0	long	0x581120	cForth 32-bit Dictionary,
>4	long	x		Serial: 0x%08X,
>8	long	x		Dictionary Start: 0x%08X,
>12	long	x		Dictionary Size: %d bytes,
>16	long	x		User Area Start: 0x%08X,
>20	long	x		User Area Size: %d bytes,
>24	long	x		Entry Point: 0x%08X
@


1.1.1.1
log
@Import 5.38:
	- Always accept -S (no sandbox) even if we don't support sandboxing
	- More syscalls elided for sandboxiing
	- For ELF dynamic means having an interpreter not just PT_DYNAMIC
	- Check for large ELF session header offset
	- When saving and restoring a locale, keep the locale name in our
	  own storage.
	- Add a flag to disable CSV file detection.
	- Don't pass NULL/0 to memset to appease sanitizers.
	- Avoid spurious prints when looks for extensions or apple strings
	  in fsmagic.
	- Add builtin decompressors for xz and and bzip.
	- Add a limit for the number of CDF elements.
	- More checks for overflow in CDF.
@
text
@@


1.1.1.2
log
@2021-03-30  20:21  Christos Zoulas <christos@@zoulas.com>

	* release 5.40

2021-02-05  16:31  Christos Zoulas <christos@@zoulas.com>

	* PR/234: Add limit to the number of bytes to scan for encoding
	* PR/230: Fix /T (trim flag) for regex

2021-02-01  12:31  Christos Zoulas <christos@@zoulas.com>
	* PR/77: Trim trailing separator.

2020-12-17  15:44  Christos Zoulas <christos@@zoulas.com>

	* PR/211: Convert system read errors from corrupt ELF
	  files into human readable error messages

2020-12-08  16:24  Christos Zoulas <christos@@zoulas.com>

	* fix multithreaded decompression file descriptor issue
	  by using close-on-exec (Denys Vlasenko)

2020-06-27  11:58  Christos Zoulas <christos@@zoulas.com>

	* Exclude surrogate pairs from utf-8 detection (Michael Liu)

2020-06-25  12:53  Christos Zoulas <christos@@zoulas.com>

	* Include # to the list of ignored format chars (Werner Fink)
@
text
@d3 1
a3 1
# $File: forth,v 1.3 2020/12/12 20:01:47 christos Exp $
d19 1
a19 1
# Various dictionary images used by OpenFirware FORTH environment
d22 7
a28 9
>8	lelong	0xe1a00000
# skip raspberry pi kernel image kernel7.img by checking for positive text length
>>24	lelong	>0		ARM OpenFirmware FORTH Dictionary,
>>>24	lelong	x		Text length: %d bytes,
>>>28	lelong	x		Data length: %d bytes,
>>>32	lelong	x		Text Relocation Table length: %d bytes,
>>>36	lelong	x		Data Relocation Table length: %d bytes,
>>>40	lelong	x		Entry Point: 0x%08X,
>>>44	lelong	x		BSS length: %d bytes
@


1.1.1.3
log
@Import file-5.43+; last was file-5.40

2022-09-20  17:12  Christos Zoulas <christos@@zoulas.com>

	* fixed various clustefuzz issues

2022-09-19  15:54  Christos Zoulas <christos@@zoulas.com>

	* Fix error detection for decompression code (Vincent Mihalkovic)

2022-09-15  13:50  Christos Zoulas <christos@@zoulas.com>

	* Add MAGIC_NO_COMPRESS_FORK and use it to produce a more
	  meaningful error message if we are sandboxing.

2022-09-15  10:45  Christos Zoulas <christos@@zoulas.com>

	* Add built-in lzip decompression support (Michal Gorny)

2022-09-14  10:35  Christos Zoulas <christos@@zoulas.com>

	* Add built-in zstd decompression support (Martin Rodriguez Reboredo)

2022-09-13  14:55  Christos Zoulas <christos@@zoulas.com>

	* release 5.43

2022-09-10   9:17  Christos Zoulas <christos@@zoulas.com>

	* Add octal indirect magic (Michal Gorny)

2022-08-17  11:43  Christos Zoulas <christos@@zoulas.com>

	* PR/374: avoid infinite loop in non-wide code (piru)
	* PR/373: Obey MAGIC_CONTINUE with multiple magic files (vismarli)

2022-07-26  11:10  Christos Zoulas <christos@@zoulas.com>

	* Fix bug with large flist (Florian Weimer)

2022-07-07  13:21  Christos Zoulas <christos@@zoulas.com>

        * PR/364: Detect non-nul-terminated core filenames from QEMU
	  (mam-ableton)

2022-07-04  15:45  Christos Zoulas <christos@@zoulas.com>

	* PR/359: Add support for http://ndjson.org/ (darose)
	* PR/362: Fix wide printing (ro-ee)
	* PR/358: Fix width for -f - (jpalus)
	* PR/356: Fix JSON constant parsing (davewhite)

2022-06-10   9:40  Christos Zoulas <christos@@zoulas.com>

	* release 5.42

2022-05-31  14:50   Christos Zoulas <christos@@zoulas.com>

	* PR/348: add missing cases to prevent file from aborting on
	  random magic files.

2022-05-27  21:05   Christos Zoulas <christos@@zoulas.com>

	* PR/351: octalify filenames when not raw before printing.

2022-04-18  17:51   Christos Zoulas <christos@@zoulas.com>

	* fix regex cacheing bug (Dirk Mueller)
	* merge file_regcomp and file_regerror() to simplify the code
	  and reduce memory requirements for storing regexes (Dirk Mueller)

2022-03-19  12:56   Christos Zoulas <christos@@zoulas.com>

	* cache regex (Dirk Mueller)
	* detect filesystem full by flushing output (Dirk Mueller)

2021-11-19  12:36   Christos Zoulas <christos@@zoulas.com>

	* implement running decompressor programs using
	  posix_spawnp(2) instead of vfork(2)

2021-10-24  11:51   Christos Zoulas <christos@@zoulas.com>

	* Add support for msdos dates and times

2021-10-20   9:55   Christos Zoulas <christos@@zoulas.com>

	* use the system byte swapping functions if available (Werner Fink)

2021-10-18  11:57  Christos Zoulas <christos@@zoulas.com>

	* release 5.41

2021-09-23  03:51  Christos Zoulas <christos@@zoulas.com>

	* Avinash Sonawane: Fix tzname detection

2021-09-03  09:17  Christos Zoulas <christos@@zoulas.com>

	* Fix relationship tests with "search" magic, don't short circuit
	  logic

2021-07-13  01:06  Christos Zoulas <christos@@zoulas.com>

	* Fix memory leak in compile mode

2021-07-01  03:51  Christos Zoulas <christos@@zoulas.com>

	* PR/272: kiefermat: Only set returnval = 1 when we printed something
	  (in all cases print or !print). This simplifies the logic and fixes
	  the issue in the PR with -k and --mime-type there was no continuation
	  printed before the default case.

2021-06-30  13:07  Christos Zoulas <christos@@zoulas.com>

	* PR/270: Don't translate unprintable characters in %s magic formats
	  when -r
	* PR/269: Avoid undefined behavior with clang (adding offset to NULL)

2021-05-09  18:38  Christos Zoulas <christos@@zoulas.com>

	* Add a new flag (f) that requires that the match is a full word,
	   not a partial word match.
	* Add varint types (unused)

2021-04-19  17:17  Christos Zoulas <christos@@zoulas.com>

	* PR/256: mutableVoid: If the file is less than 3 bytes, use the file
	  length to determine type
	* PR/259: aleksandr.v.novichkov: mime printing through indirect magic
	  is not taken into account, use match directly so that it does.

2021-04-04  17:02  Christos Zoulas <christos@@zoulas.com>

	* count the total bytes found not the total byte positions
	  in order to determine encoding (Anatol Belski)
@
text
@d3 1
a3 1
# $File: forth,v 1.4 2021/04/26 15:56:00 christos Exp $
d29 1
a29 1
>>>40	lelong	x		Entry Point: %#08X,
d40 2
a41 2
>>14	lelong	x		Initial Stack Pointer: %#08X,
>>20	lelong	x		Entry Point: %#08X,
d44 1
a44 1
>>18	leshort	x		Checksum: %#08X
d51 1
a51 1
>20	belong	x		Entry Point: %#08X,
d60 1
a60 1
>20	lelong	x		Entry Point: %#08X,
d69 2
a70 2
#>2	short	x		Serial: %#08X,
#>4	short	x		Dictionary Start: %#08X,
d72 1
a72 1
#>8	short	x		User Area Start: %#08X,
d74 1
a74 1
#>12	short	x		Entry Point: %#08X
d77 2
a78 2
>4	long	x		Serial: %#08X,
>8	long	x		Dictionary Start: %#08X,
d80 1
a80 1
>16	long	x		User Area Start: %#08X,
d82 1
a82 1
>24	long	x		Entry Point: %#08X
@


1.1.1.1.4.1
log
@file forth was added on branch phil-wifi on 2020-04-08 14:04:04 +0000
@
text
@d1 80
@


1.1.1.1.4.2
log
@Merge changes from current as of 20200406
@
text
@a0 80

#------------------------------------------------------------------------------
# $File: forth,v 1.1 2019/06/06 19:14:20 christos Exp $
# forth:  file(1) magic for various Forth environments
# From: Lubomir Rintel <lkundrak@@v3.sk>
#

# Has a FORTH stack diagram and something that looks very much like a FORTH
# multi-line word definition. Probably a FORTH source.
0       regex   \[[:space:]]\\(([[:space:]].*)?\ --\ (.*[[:space:]])?\\)
>0      regex   \^:\[[:space:]]
>>0     regex   \^;$				FORTH program
!:mime  text/x-forth

# Inline word definition complete with a stack diagram
0       regex   \^:[[:space:]].*[[:space:]]\\(([[:space:]].*)?\ --\ (.*[[:space:]])?\\)[[:space:]].*[[:space:]];$	FORTH program
!:mime  text/x-forth

# Various dictionary images used by OpenFirware FORTH environent

0	lelong	0xe1a00000
>8	lelong	0xe1a00000	ARM OpenFirmware FORTH Dictionary,
>>24	lelong	x		Text length: %d bytes,
>>28	lelong	x		Data length: %d bytes,
>>32	lelong	x		Text Relocation Table length: %d bytes,
>>36	lelong	x		Data Relocation Table length: %d bytes,
>>40	lelong	x		Entry Point: 0x%08X,
>>44	lelong	x		BSS length: %d bytes

0	string	MP
>28	lelong	1		x86 OpenFirmware FORTH Dictionary,
>>4	leshort	x		%d blocks
>>2	leshort	x		+ %d bytes,
>>6	leshort	x		%d relocations,
>>8	leshort	x		Header length: %d paragraphs,
>>10	leshort	x		Data Size: %d
>>12	leshort	x		- %d 4K pages,
>>14	lelong	x		Initial Stack Pointer: 0x%08X,
>>20	lelong	x		Entry Point: 0x%08X,
>>24	lelong	x		First Relocation Item: %d,
>>26	lelong	x		Overlay Number: %d,
>>18	leshort	x		Checksum: 0x%08X

0	belong	0x48000020	PowerPC OpenFirmware FORTH Dictionary,
>4	belong	x		Text length: %d bytes,
>8	belong	x		Data length: %d bytes,
>12	belong	x		BSS length: %d bytes,
>16	belong	x		Symbol Table length: %d bytes,
>20	belong	x		Entry Point: 0x%08X,
>24	belong	x		Text Relocation Table length: %d bytes,
>28	belong	x		Data Relocation Table length: %d bytes

0	lelong	0x10000007	MIPS OpenFirmware FORTH Dictionary,
>4	lelong	x		Text length: %d bytes,
>8	lelong	x		Data length: %d bytes,
>12	lelong	x		BSS length: %d bytes,
>16	lelong	x		Symbol Table length: %d bytes,
>20	lelong	x		Entry Point: 0x%08X,
>24	lelong	x		Text Relocation Table length: %d bytes,
>28	lelong	x		Data Relocation Table length: %d bytes

# Dictionary images used by minimal C FORTH environments, any platform,
# using native byte order.

# Weak.
#0	short	0x5820		cForth 16-bit Dictionary,
#>2	short	x		Serial: 0x%08X,
#>4	short	x		Dictionary Start: 0x%08X,
#>6	short	x		Dictionary Size: %d bytes,
#>8	short	x		User Area Start: 0x%08X,
#>10	short	x		User Area Size: %d bytes,
#>12	short	x		Entry Point: 0x%08X

0	long	0x581120	cForth 32-bit Dictionary,
>4	long	x		Serial: 0x%08X,
>8	long	x		Dictionary Start: 0x%08X,
>12	long	x		Dictionary Size: %d bytes,
>16	long	x		User Area Start: 0x%08X,
>20	long	x		User Area Size: %d bytes,
>24	long	x		Entry Point: 0x%08X
@


