View Issue Details

IDProjectCategoryView StatusLast Update
0000304file[All Projects] Generalpublic2021-12-17 14:43
Reporterzachs18Assigned Tochristos 
PrioritylowSeveritytweakReproducibilityalways
Status resolvedResolutionfixed 
Product Version5.41 
Target VersionFixed in VersionHEAD 
Summary0000304: Netpbm format does not correctly parse size for some images
DescriptionThe Netpbm image formats allow any amount of any whitespace between the width, height, and (if given) maxval fields in the header (it is only after the last field that exactly one whitespace character is allowed).
The format specification in magic/Magdir/images, however, assumes that there is exactly one space character (\ ) between width and height. This leads file to not correctly parse the width and height in files where the width and height are separated by other whitespace, e.g. a newline, two spaces, or a tab.
Steps To ReproducePlace the below into a file (not including quotes):
"P2
2
2
255
0 1 2 3"
`file` will report the file as `Netpbm image data, size = 0 x 1, greymap, ASCII text`, instead of `Netpbm image data, size = 2 x 2, greymap, ASCII text`
Additional InformationI believe this can be fixed by changing the regular expression on line 182 of magic/Magdir/images from "[0-9]{1,50}\ [0-9]{1,50}" to "[0-9]{1,50}[\040\t\f\r\n]+[0-9]{1,50}"

Attached files are reported as:
test1.pgm: `Netpbm image data, size = 0 x 0, greymap, ASCII text`
test2.pgm: `, rawbits, greymap`
but should be reported as:
test1.pgm: `Netpbm image data, size = 2 x 2, greymap, ASCII text`
test2.pgm: `Netpbm image data, size = 2 x 2, rawbits, greymap`
Tagsmagic

Activities

zachs18

2021-12-06 06:32

reporter  

test1.pgm (19 bytes)
test2.pgm (15 bytes)

christos

2021-12-17 14:43

manager   ~0003684

Fixed as suggested, thanks!

Issue History

Date Modified Username Field Change
2021-12-06 06:32 zachs18 New Issue
2021-12-06 06:32 zachs18 File Added: test2.pgm
2021-12-06 06:32 zachs18 File Added: test1.pgm
2021-12-06 06:32 zachs18 Tag Attached: magic
2021-12-17 14:42 christos Assigned To => christos
2021-12-17 14:42 christos Status new => assigned
2021-12-17 14:43 christos Status assigned => resolved
2021-12-17 14:43 christos Resolution open => fixed
2021-12-17 14:43 christos Fixed in Version => HEAD
2021-12-17 14:43 christos Note Added: 0003684