]> granicus.if.org Git - file/log
file
12 years agoinclude the offset
Christos Zoulas [Wed, 23 Jan 2013 17:45:51 +0000 (17:45 +0000)]
include the offset

12 years agoPR/233: Magic contains embedded space.
Christos Zoulas [Tue, 22 Jan 2013 18:52:02 +0000 (18:52 +0000)]
PR/233: Magic contains embedded space.

12 years agoPR/232: Jan Kaluza: JPEG files are detected as Minix filesystems
Christos Zoulas [Tue, 22 Jan 2013 18:29:58 +0000 (18:29 +0000)]
PR/232: Jan Kaluza: JPEG files are detected as Minix filesystems

12 years agore-factor gnome.
Christos Zoulas [Wed, 16 Jan 2013 13:53:10 +0000 (13:53 +0000)]
re-factor gnome.

12 years agomore fixes from Guy Harris
Christos Zoulas [Sat, 12 Jan 2013 03:09:51 +0000 (03:09 +0000)]
more fixes from Guy Harris

12 years agomention fsmagic fix.
Christos Zoulas [Fri, 11 Jan 2013 19:50:03 +0000 (19:50 +0000)]
mention fsmagic fix.

12 years agoAdd a space if we printed some magic.
Christos Zoulas [Fri, 11 Jan 2013 19:46:55 +0000 (19:46 +0000)]
Add a space if we printed some magic.

12 years agoupdate source list
Christos Zoulas [Fri, 11 Jan 2013 16:51:01 +0000 (16:51 +0000)]
update source list

12 years ago- Warn about continuation levels which are not contiguous when increasing.
Christos Zoulas [Fri, 11 Jan 2013 16:45:23 +0000 (16:45 +0000)]
- Warn about continuation levels which are not contiguous when increasing.
- Fix broken magic files discovered by that test.

12 years agoMore fixes
Christos Zoulas [Thu, 10 Jan 2013 23:09:51 +0000 (23:09 +0000)]
More fixes

12 years agoadd "public" because this is needed outside libmagic (in file)
Christos Zoulas [Thu, 10 Jan 2013 23:06:04 +0000 (23:06 +0000)]
add "public" because this is needed outside libmagic (in file)

12 years agouse BUILT_SOURCES
Christos Zoulas [Thu, 10 Jan 2013 00:50:33 +0000 (00:50 +0000)]
use BUILT_SOURCES

12 years agonew a.out file
Christos Zoulas [Wed, 9 Jan 2013 22:37:38 +0000 (22:37 +0000)]
new a.out file

12 years agoFrom Guy Harris:
Christos Zoulas [Wed, 9 Jan 2013 22:37:23 +0000 (22:37 +0000)]
From Guy Harris:

There are several entries in the magic database for files that begin
with a 4-byte big-endian or little-endian octal 407, 410, and 413,
because several different flavors of UN*X used, at least in their
earliest days, the 32-bit a.out format with the standard magic numbers.

I've removed them and placed entries in a new "aout" file, and just
labeled them as "little-endian 32-bit" and "big-endian 32-bit"
executables, so that, for example, UNIX/32V VAX binaries aren't
misidentified as 386 binaries, or *vice versa*; unless we look at the
actual code, or find some other way of distinguishing between them,
there's no way to identify those as anything other than little-endian
32-bit binaries.  I also commented out some entries in "unknown" that
would have matched the same files that other entries would also have
matched.

I've also added "a.out" to the description strings for several a.out
file formats.

As "mips" contained some of those entries, as a result of being a bit of
a mix between MIPS stuff and SGI stuff, I also moved all the stuff that
has nothing to do with the MIPS architecture into "sgi".  (Yes, SGI did
own MIPS Technologies for a while, but it didn't do so originally and
doesn't do so now, and the stuff that got moved has nothing to do with
the MIPS architecture.)

In addition, I cleaned up the "ar" archive file entries, removing some
duplicates, fixing some "random" archive checks (they were using an
offset of 8 for older archive formats, but in those older archive
formats the archive entries start at an earlier offset, so the name of
the first entry is at an offset of 2 or 4), and adding an entry for the
entry Apple's ranlib adds (it has a longer name, and OS X uses the BSD
flavor of the "portable" archive format, so the name is at an offset of
68 rather than 8).  I also added a comment to indicate what I suspect
"thin" archives are (a type of archive produced by GNU ar).

12 years agoAdd 5.2 from Steven Kreuzer
Christos Zoulas [Wed, 9 Jan 2013 16:23:17 +0000 (16:23 +0000)]
Add 5.2 from Steven Kreuzer

12 years agomerge assignments
Christos Zoulas [Wed, 9 Jan 2013 15:36:55 +0000 (15:36 +0000)]
merge assignments

12 years agoDocument {d,u}Q (Guy Harris)
Christos Zoulas [Wed, 9 Jan 2013 13:04:30 +0000 (13:04 +0000)]
Document {d,u}Q (Guy Harris)

12 years agoonly allow one digit chars, but allow any other character except a digit
Christos Zoulas [Wed, 9 Jan 2013 13:03:41 +0000 (13:03 +0000)]
only allow one digit chars, but allow any other character except a digit
after them. (Guy Harris)

12 years agoadd fulldump bit (Lorinczy Zsigmond)
Christos Zoulas [Tue, 8 Jan 2013 20:13:01 +0000 (20:13 +0000)]
add fulldump bit (Lorinczy Zsigmond)

12 years agomerge duplicate entries
Christos Zoulas [Tue, 8 Jan 2013 17:02:50 +0000 (17:02 +0000)]
merge duplicate entries

12 years agoadd raw, from Alfredo Ortega
Christos Zoulas [Tue, 8 Jan 2013 03:06:50 +0000 (03:06 +0000)]
add raw, from Alfredo Ortega

12 years agoadd: International Color Consortium profile file magic
Christos Zoulas [Tue, 8 Jan 2013 01:43:18 +0000 (01:43 +0000)]
add: International Color Consortium profile file magic

12 years agoImplement [du]{1,2,4,8} (Guy Harris)
Christos Zoulas [Tue, 8 Jan 2013 01:37:01 +0000 (01:37 +0000)]
Implement [du]{1,2,4,8} (Guy Harris)

12 years agofix bitcode data (Guy Harris)
Christos Zoulas [Tue, 8 Jan 2013 01:34:38 +0000 (01:34 +0000)]
fix bitcode data (Guy Harris)

12 years agocheck for the right magic_version()
Christos Zoulas [Mon, 7 Jan 2013 18:20:19 +0000 (18:20 +0000)]
check for the right magic_version()

12 years ago- always initialize ml->map
Christos Zoulas [Mon, 7 Jan 2013 18:15:15 +0000 (18:15 +0000)]
- always initialize ml->map
- free map

12 years agore-do the map and allocation of magic entries to simplify things
Christos Zoulas [Mon, 7 Jan 2013 18:06:40 +0000 (18:06 +0000)]
re-do the map and allocation of magic entries to simplify things

12 years agoPR/228: Fix magic deallocation when the magic file is not mmapped. This is the
Christos Zoulas [Mon, 7 Jan 2013 02:11:22 +0000 (02:11 +0000)]
PR/228: Fix magic deallocation when the magic file is not mmapped. This is the
case for windows.

12 years agoPR/225: beat x86 boot sector
Christos Zoulas [Sun, 6 Jan 2013 21:26:48 +0000 (21:26 +0000)]
PR/225: beat x86 boot sector

12 years ago$> does not work all the time
Christos Zoulas [Sun, 6 Jan 2013 21:14:17 +0000 (21:14 +0000)]
$> does not work all the time

12 years agoimplement magic_version
Christos Zoulas [Sun, 6 Jan 2013 21:10:39 +0000 (21:10 +0000)]
implement magic_version

12 years agodocument magic_version
Christos Zoulas [Sun, 6 Jan 2013 20:56:52 +0000 (20:56 +0000)]
document magic_version

12 years agothe continuation error is a magic error.
Christos Zoulas [Sun, 6 Jan 2013 20:36:18 +0000 (20:36 +0000)]
the continuation error is a magic error.

12 years agoPR/229: Fix not portable pointer comparison code.
Christos Zoulas [Sun, 6 Jan 2013 20:22:16 +0000 (20:22 +0000)]
PR/229: Fix not portable pointer comparison code.

12 years agoUse "name" and "use" so that we have only one set of entries for pcap
Christos Zoulas [Sun, 6 Jan 2013 01:11:04 +0000 (01:11 +0000)]
Use "name" and "use" so that we have only one set of entries for pcap
files, and add a bunch of additional link-layer header types. (Guy Harris)

12 years agoadd more link layer types (Guy Harris)
Christos Zoulas [Sun, 6 Jan 2013 01:09:42 +0000 (01:09 +0000)]
add more link layer types (Guy Harris)

12 years agofix processor offsets (Guy Harris)
Christos Zoulas [Fri, 4 Jan 2013 23:35:53 +0000 (23:35 +0000)]
fix processor offsets (Guy Harris)

12 years agoAdd llvm bitcode objects; from Guy Harris
Christos Zoulas [Fri, 4 Jan 2013 23:31:59 +0000 (23:31 +0000)]
Add llvm bitcode objects; from Guy Harris

12 years agoremove ?
Christos Zoulas [Fri, 4 Jan 2013 23:31:11 +0000 (23:31 +0000)]
remove ?

12 years agouse "universal binary". From Guy Harris
Christos Zoulas [Fri, 4 Jan 2013 23:27:55 +0000 (23:27 +0000)]
use "universal binary". From Guy Harris

12 years agoPatch from Guy Harris, fixing a typo in the name, masks, and unhandled archs
Christos Zoulas [Fri, 4 Jan 2013 21:46:59 +0000 (21:46 +0000)]
Patch from Guy Harris, fixing a typo in the name, masks, and unhandled archs

12 years agoescape the period in the keywords
Christos Zoulas [Fri, 4 Jan 2013 17:23:28 +0000 (17:23 +0000)]
escape the period in the keywords

12 years agoNeed to pass the returnval that the child match determined in the use case.
Christos Zoulas [Fri, 4 Jan 2013 16:37:54 +0000 (16:37 +0000)]
Need to pass the returnval that the child match determined in the use case.
This broke the elf mime printing, where softmagic returned a non-match although
the child match() actually printed something.

12 years agonew sentence, new line
Christos Zoulas [Fri, 4 Jan 2013 15:39:22 +0000 (15:39 +0000)]
new sentence, new line

12 years agouse case insensitive match
Christos Zoulas [Fri, 4 Jan 2013 14:22:07 +0000 (14:22 +0000)]
use case insensitive match

12 years agofix bogus magic FILE5_12
Christos Zoulas [Fri, 4 Jan 2013 00:47:02 +0000 (00:47 +0000)]
fix bogus magic

12 years agolint fixes
Christos Zoulas [Thu, 3 Jan 2013 23:11:38 +0000 (23:11 +0000)]
lint fixes

12 years agowelcome to 5.12
Christos Zoulas [Thu, 3 Jan 2013 16:05:24 +0000 (16:05 +0000)]
welcome to 5.12

12 years agomissing backslash
Christos Zoulas [Thu, 3 Jan 2013 16:00:42 +0000 (16:00 +0000)]
missing backslash

12 years agoPR/224: Add geospatial designs recognition. Guess on little endian.
Christos Zoulas [Wed, 2 Jan 2013 15:27:53 +0000 (15:27 +0000)]
PR/224: Add geospatial designs recognition. Guess on little endian.

12 years agoadd .DS_Store files
Christos Zoulas [Thu, 27 Dec 2012 15:43:23 +0000 (15:43 +0000)]
add .DS_Store files

12 years agoadded keepass
Christos Zoulas [Mon, 24 Dec 2012 22:14:56 +0000 (22:14 +0000)]
added keepass

12 years agoPR/220: Add MacOS alias files
Christos Zoulas [Fri, 21 Dec 2012 16:41:07 +0000 (16:41 +0000)]
PR/220: Add MacOS alias files

12 years agoadd uterus
Christos Zoulas [Tue, 18 Dec 2012 18:54:09 +0000 (18:54 +0000)]
add uterus

12 years agoPR/200: Add uterus magic
Christos Zoulas [Tue, 18 Dec 2012 18:53:32 +0000 (18:53 +0000)]
PR/200: Add uterus magic

12 years agoPR/216: Reduce strength of x86 boot sector, bump pbm files adding width and
Christos Zoulas [Tue, 18 Dec 2012 17:28:43 +0000 (17:28 +0000)]
PR/216: Reduce strength of x86 boot sector, bump pbm files adding width and
height printing (Jan Kaluza)

12 years agoPR/216: P2 files are not binary.
Christos Zoulas [Tue, 18 Dec 2012 17:25:54 +0000 (17:25 +0000)]
PR/216: P2 files are not binary.

12 years agoelf capabilities fix (Jan Kaluza)
Christos Zoulas [Thu, 13 Dec 2012 13:48:31 +0000 (13:48 +0000)]
elf capabilities fix (Jan Kaluza)

12 years agoRecognize more mbr types from Joerg Jenderek
Christos Zoulas [Sun, 9 Dec 2012 17:49:00 +0000 (17:49 +0000)]
Recognize more mbr types from Joerg Jenderek

12 years agofix typo; add mariadb
Christos Zoulas [Sun, 9 Dec 2012 17:11:08 +0000 (17:11 +0000)]
fix typo; add mariadb

12 years agofix typo
Christos Zoulas [Sun, 9 Dec 2012 17:10:03 +0000 (17:10 +0000)]
fix typo

12 years agoadd lfs
Christos Zoulas [Sat, 1 Dec 2012 19:14:28 +0000 (19:14 +0000)]
add lfs

12 years agomove minix after ext<n> because ext gets misadentified as minix, for specific
Christos Zoulas [Fri, 30 Nov 2012 18:11:54 +0000 (18:11 +0000)]
move minix after ext<n> because ext gets misadentified as minix, for specific
values of free inodes (from Werner Fink):

http://www.debacher.de/ublog/2010/06/
http://sourceforge.net/apps/mediawiki/bootinfoscript/index.php?title=Boot_Problems:minix
https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/518582
http://www.mail-archive.com/ubuntu-bugs@lists.ubuntu.com/msg2057379.html
https://lkml.org/lkml/1996/4/18/38

12 years agoPR/214: Form the help for nv options dynamically instead of keeping a stale
Christos Zoulas [Wed, 21 Nov 2012 16:27:39 +0000 (16:27 +0000)]
PR/214: Form the help for nv options dynamically instead of keeping a stale
copy.

12 years agoFix uninitialized variable.
Christos Zoulas [Wed, 21 Nov 2012 16:27:07 +0000 (16:27 +0000)]
Fix uninitialized variable.

12 years agoadd armv7 from Francis Dupont
Christos Zoulas [Tue, 13 Nov 2012 14:55:44 +0000 (14:55 +0000)]
add armv7 from Francis Dupont

12 years agoAdd thin archive support.
Christos Zoulas [Fri, 9 Nov 2012 22:59:30 +0000 (22:59 +0000)]
Add thin archive support.

12 years agonew patch from Joerg Jenderek
Christos Zoulas [Thu, 8 Nov 2012 21:42:46 +0000 (21:42 +0000)]
new patch from Joerg Jenderek

12 years agodocument ^name in use
Christos Zoulas [Wed, 7 Nov 2012 20:29:27 +0000 (20:29 +0000)]
document ^name in use

12 years agocheck the return value of dup(2)
Christos Zoulas [Wed, 7 Nov 2012 17:54:48 +0000 (17:54 +0000)]
check the return value of dup(2)

12 years agoadd aarch64
Christos Zoulas [Tue, 6 Nov 2012 20:43:52 +0000 (20:43 +0000)]
add aarch64

12 years agomerge more little/big endian entries
Christos Zoulas [Fri, 2 Nov 2012 21:50:29 +0000 (21:50 +0000)]
merge more little/big endian entries

12 years agoremove dup le/be
Christos Zoulas [Fri, 2 Nov 2012 21:06:27 +0000 (21:06 +0000)]
remove dup le/be

12 years agomention a few todo's
Christos Zoulas [Thu, 1 Nov 2012 04:31:53 +0000 (04:31 +0000)]
mention a few todo's

12 years agouse name+use to eliminate bi-endian copies.
Christos Zoulas [Thu, 1 Nov 2012 04:26:40 +0000 (04:26 +0000)]
use name+use to eliminate bi-endian copies.

12 years agoif the use string starts with ^, then flip the endianness of the entry.
Christos Zoulas [Thu, 1 Nov 2012 04:21:27 +0000 (04:21 +0000)]
if the use string starts with ^, then flip the endianness of the entry.

12 years agoPR/199: accept whitespace before keywords, add a couple of more
Christos Zoulas [Wed, 31 Oct 2012 18:41:42 +0000 (18:41 +0000)]
PR/199: accept whitespace before keywords, add a couple of more

12 years agocheck for NULL ms
Christos Zoulas [Wed, 31 Oct 2012 17:20:06 +0000 (17:20 +0000)]
check for NULL ms

12 years agoremove c99
Christos Zoulas [Wed, 31 Oct 2012 17:19:32 +0000 (17:19 +0000)]
remove c99

12 years agoPR/208: Fix buildid format
Christos Zoulas [Wed, 31 Oct 2012 17:03:41 +0000 (17:03 +0000)]
PR/208: Fix buildid format

12 years agoadd empty zip
Christos Zoulas [Wed, 31 Oct 2012 16:55:49 +0000 (16:55 +0000)]
add empty zip

12 years agomore details
Christos Zoulas [Wed, 31 Oct 2012 16:48:13 +0000 (16:48 +0000)]
more details

12 years agobetter printout for mach-o, avoid dup.
Christos Zoulas [Wed, 31 Oct 2012 16:32:01 +0000 (16:32 +0000)]
better printout for mach-o, avoid dup.

12 years agoremove prototype for main, add protected for file_mbswidth(), could be private
Christos Zoulas [Wed, 31 Oct 2012 14:01:28 +0000 (14:01 +0000)]
remove prototype for main, add protected for file_mbswidth(), could be private

12 years agoadd mime epankala@gmail.com
Christos Zoulas [Wed, 31 Oct 2012 13:39:42 +0000 (13:39 +0000)]
add mime epankala@gmail.com

12 years agoadd mime from epankala@gmail.com
Christos Zoulas [Wed, 31 Oct 2012 13:38:40 +0000 (13:38 +0000)]
add mime from epankala@gmail.com

12 years agoremove debugging.
Christos Zoulas [Wed, 31 Oct 2012 00:48:40 +0000 (00:48 +0000)]
remove debugging.

12 years agomention new "name" and "use" file types
Christos Zoulas [Tue, 30 Oct 2012 23:23:50 +0000 (23:23 +0000)]
mention new "name" and "use" file types

12 years agodocument "name" and "use"
Christos Zoulas [Tue, 30 Oct 2012 23:22:57 +0000 (23:22 +0000)]
document "name" and "use"

12 years agolook inside fat mach-o binaries
Christos Zoulas [Tue, 30 Oct 2012 23:14:18 +0000 (23:14 +0000)]
look inside fat mach-o binaries

12 years agoadd name and use keywords. Welcome to version 9.
Christos Zoulas [Tue, 30 Oct 2012 23:11:51 +0000 (23:11 +0000)]
add name and use keywords. Welcome to version 9.

12 years agolinux magic for SYSLINUX boot logos+ msdos & wordprocessors for .hlp files
Christos Zoulas [Mon, 29 Oct 2012 17:36:49 +0000 (17:36 +0000)]
linux magic for SYSLINUX boot logos+ msdos & wordprocessors for .hlp files
From Joerg Jenderek

12 years ago-k and -l improvements from Joerg Jenderek
Christos Zoulas [Thu, 25 Oct 2012 15:34:02 +0000 (15:34 +0000)]
-k and -l improvements from Joerg Jenderek

12 years agoadd pwsafe
Christos Zoulas [Thu, 25 Oct 2012 00:12:19 +0000 (00:12 +0000)]
add pwsafe

12 years agopatch from Joerg Jenderek
Christos Zoulas [Thu, 25 Oct 2012 00:11:49 +0000 (00:11 +0000)]
patch from Joerg Jenderek

12 years agoBIOS logo support (Joerg Jenderek)
Christos Zoulas [Sun, 14 Oct 2012 22:53:42 +0000 (22:53 +0000)]
BIOS logo support (Joerg Jenderek)

12 years agofrom Joerg Jenderek
Christos Zoulas [Fri, 12 Oct 2012 16:10:39 +0000 (16:10 +0000)]
from Joerg Jenderek
Hi,
2 files (TDSK-5120x32b.img and TDSK-5120x64b.img ) in directory bootsector
are characterized wrong ( see output bootsector-5.11.txt) .
In reality they are dos images with a sector size smaller than 512. Because
smallest DOS sector size is 32 new test a level 0 searches for boot
signature 0xAA55 in the range from 32 to 512:
30              search/481      \x55\xAA
This test succeed also for some zip files. But if next test for 0xAA55 at
offset 0x1FE succeeds
        >0x1FE          leshort         0xAA55
i got the old examples and print "x86 boot sector".
Alternative test for boot sector sizes smaller 512 at offset 11
>11             uleshort        <512
>>(11.s-2)      uleshort        0xAA55          x86 boot sector
and look for boot signature at end of sector. If these tests succeeds
display also the "x86 boot sector" text.
Because i found bootloader and mbr information only in case of bootsector
sizes greater or equal 512, i keep the the old test sequences and only
replaced "x86 boot sector" string by an empty one because displaying this
text is now done by new additional test.
Some steps has to be done to get the old look like "x86 boot sector, YY
Bootloader, code offset 0xnn, OEM-ID ..."
To display that text before old one,SYSLINUX MBR and DOS BPB
information like in previous file version a  strength of 72 has to be
added.

In the current version first search for the end of sector marker 0xAA55 is
done. If succeeds additional information like DOS BPB and MBR type
is printed. So some boot sector templates without boot signature
are identified as "data". Therefore i separate from "x86 boot sector" the
tests for DOS sector.

Furthermore i has done some minor bug fixes and cosmetic changes.
The jump assembler instruction use relative addresses. So one has to add 2
to
get the real code offset inside the file . The value is ubyte for 0xEB
instruction, but uleshort for 0xE9.
The values for "reserved1" til "reserved3" for DOS boot sectors are wrong,
because the start at offset 52 and not at 54 according to web page
http://thestarman.pcministry.com/asm/mbr/MSWIN41.htm#FSINFO .
This mistake was long time not seen, because this values are normally zero
except for some files like hda9data.bin.
I also display the information about " sectors/track" at offset 24.
For "physical drive" value 0xFF that  words are displayed twice and one
with a wrong value ( See in sub directory physical_drive_2 for files
hda1fd95.bin,sdb2-xp.bin,...)
If the DOS bootsector is followed by the Media descriptor byte 0xFn and
some 0xFFs ( (11.s)     ulelong&0x00ffffF0      0x00ffffF0) this is
characteristic
for a DOS File Allocation Table (FAT). The whole thing is the start of an
DOS disk image. So mime type "application/x-ima" is printed for floppy
images (no fixed disk with FAT12).
NTFS and DOS share the beginning parts of the BIOS parameter block (BPB)
according to http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/
bios-parameter-block.html .
For some x86 boot sectors (files in directory sample/ntfs/) some
information like Media descriptor or heads is correct displayed ( see
output ntfs-5.11.txt ). But the interesting facts of NTFS file system are
not displayed.
By information of http://thestarman.pcministry.com/asm/mbr/NTFSBR.htm
i began to patch the filesystems magic file. If a file looks like a DOS
boot sector and has zero values for the 4 fields FATs,root entries,
 DOS sectors and sectors/FAT it is a NTFS bootsector and the following
bytes contain information like $MFT of the NTFS filesystem ( see output
ntfs-DOSsector.txt ).

After applying changes (file-5.11-filesystems-DOSsector.diff ) a final
output file bootsector-DOSsector.txt for files in directory bootsector is
obtained.

All diffs, output and sample files are stored under
http://mitglied.multimania.de/jenderek/file/

thanks
Joerg

12 years agoPR?204: Jan Kaluza: Remove duplicate dump entries
Christos Zoulas [Wed, 3 Oct 2012 23:44:43 +0000 (23:44 +0000)]
PR?204: Jan Kaluza: Remove duplicate dump entries

12 years agoPR/205: add symmetric encryption (Alfredo Esteban de la Torre)
Christos Zoulas [Wed, 3 Oct 2012 23:38:12 +0000 (23:38 +0000)]
PR/205: add symmetric encryption (Alfredo Esteban de la Torre)

12 years agosoftmagic.c: fix buffer overrun (issue #206, reported by J. Greene)
Reuben Thomas [Wed, 3 Oct 2012 22:13:21 +0000 (22:13 +0000)]
softmagic.c: fix buffer overrun (issue #206, reported by J. Greene)