Skip to content

cpp crashes when encountering a null byte (inp < pend) #44

@MinekPo1

Description

@MinekPo1

I'm writing a program (codeberg.org:MinekPo1/Aris16 – main — aas/) which invokes a c preprocessor, and I expect that in some cases the user may unintentionally direct my program to feed cpp binary data, therefore I'm comparing behavior between various implementations.

Unlike gcc's, clang's, and tcc's cpp, pcc's cpp cannot handle null bytes, crashing with a mysterious error: inp < pend message. Note than both gcc and clang have warnings informing the user that the software is ignoring a null byte, while tcc appears to silently ignore null bytes.

This issue affects at least the development version and 1.1.0 (from ubuntu archives)

For completeness, I'm including an xxd'd representation of the file (an assembled version of one of our tests, specifically codeberg.org:MinekPo1/Aris16 – main — test/instruction/add.a16) I was testing on below:

00000000: 7003 ff80 0070 0381 7003 ff80 0170 0381  p....p..p....p..
00000010: 0427 1223 e426 3503 8570 03ff 8009 7003  .'.#.&5..p....p.
00000020: 8100 2512 0426 23e4 2635 0385 7003 ff80  ..%..&#.&5..p...
00000030: 1170 0381 0025 2304 2512 e426 3503 8570  .p...%#.%..&5..p
00000040: 03ff 8019 7003 8100 2512 0045 2304 44e4  ....p...%..E#.D.
00000050: 2635 0385 7003 ff80 0505 7003 8104 0fff  &5..p.....p.....
00000060: ffa5 0003 8528 e404 0385 7003 ff80 0506  .....(....p.....
00000070: 7003 8144 0fff ffa5 0003 7fa4 0003 85e4  p..D............
00000080: 0403 85ac 01ac 05                        .......

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions