dateutils icon indicating copy to clipboard operation
dateutils copied to clipboard

dateconv: Corruption/segfaults when feeding it sequence of lines without final terminating newline

Open Earnestly opened this issue 3 years ago • 2 comments

When feeding dateconv a sequence of lines I noticed it segfaulting when the final newline was missing. While trying to create a reproducer I instead found it misbehaving, first printing the result without the input newlines and then started dumping binary:

$ dateconv -V
dateconv 0.4.9

$ printf 'foo\nbar\nqux\0' | dateconv -S
foobarqux

... lots of terminal garbage, ELF file headers, etc. ...

I can't include the binary literally as it crashes qutebrowser whenever I try to save it, so here's a sample with xxd
```
00000000: 666f 6f62 6172 7175 780a 20ef bfbd 4640  foobarqux. ...F@
00000010: efbf bd20 efbf bd46 40ef bfbd efbf bdef  ... ...F@.......
00000020: bfbd efbf bdef bfbd efbf bdef bfbd efbf  ................
00000030: bdef bfbd d092 efbf bd5f efbf bd50 efbf  ........._...P..
00000040: bd46 40ef bfbd efbf bdef bfbd efbf bd5f  .F@............_
00000050: efbf bdef bfbd 4640 efbf bdef bfbd efbf  ......F@........
00000060: bd46 40ef bfbd 5045 efbf bd72 5520 6845  [email protected] hE
00000070: efbf bd72 55ef bfbd efbf bd6d 40ef bfbd  ...rU......m@...
00000080: 585f 47ef bfbd 7255 7045 efbf bd72 5525  X_G...rUpE...rU%
00000090: 2547 efbf bd72 55ef bfbd efbf bd6d 40ef  %G...rU......m@.
000000a0: bfbd 585f 47ef bfbd 7255 3047 efbf bd72  ..X_G...rU0G...r
000000b0: 55ef bfbd 47ef bfbd 7255 efbf bdef bfbd  U...G...rU......
000000c0: 6d40 efbf bd58 5f47 efbf bd72 5550 efbf  [email protected]_G...rUP..
000000d0: bd47 efbf bd72 55ef bfbd efbf bd48 efbf  .G...rU......H..
000000e0: bd72 55ef bfbd efbf bd6d 40ef bfbd 585f  [email protected]_
000000f0: 47ef bfbd 7255 efbf bd46 40ef bfbd efbf  G...rU...F@.....
00000100: bdef bfbd 6740 efbf bdef bfbd 6740 efbf  [email protected]@..
00000110: bdef bfbd 7463 40ef bfbd 506a 40ef bfbd  [email protected]@...
00000120: efbf bdef bfbd 6d40 efbf bdef bfbd efbf  ......m@........
00000130: bd6d 40ef bfbd 784e 6d40 efbf bd30 efbf  [email protected]@...0..
00000140: bd5f efbf bd0a 2020 2020 2020 2020 2020  ._....          
00000150: 2020 2020 2020 2020 2020 2020 2020 2020                  
00000160: 2020 2020 2020 2020 2020 2020 2020 2020                  
00000170: 2020 2020 2020 2020 2020 2020 2020 2020                  
00000180: 2020 2020 2020 2020 2020 2020 2020 2020                  
00000190: 2020 2020 2020 2020 2020 2020 2020 2020                  
000001a0: 2020 2020 2020 2020 2020 2020 2020 2020                  
000001b0: 2020 2020 2020 2020 2020 2020 2020 2020                  
000001c0: 2020 2020 2020 2020 2020 2020 2020 2020                  
000001d0: 2020 2020 2020 2020 2020 2020 2020 2020                  
000001e0: 2020 2020 2020 2020 2020 2020 2020 2020                  
000001f0: 3eef bfbd 5fef bfbd 50ef bfbd 6d40 efbf  >..._...P...m@..
00000200: bd44 35ef bfbd 5fef bfbd 454c 463e efbf  .D5..._...ELF>..
00000210: bdef bfbd 40d8 8525 4038 4043 4240 40f8  ....@..%@8@CB@@.
00000220: 8fbf bd84 f88f bfbd 84f8 8fbf bd84 30ef  ..............0.
00000230: bfbd 30ef bfbd efbf bdef bfbd efbf bdef  ..0.............
00000240: bfbd 56ef bfbd 5620 2020 efbf bd38 efbf  ..V...V   ...8..
00000250: bd38 efbf bd65 efbf bd75 efbf bd75 efbf  .8...e...u...u..
00000260: bd4f 3025 efbf bdef bfbd efbf bdef bfbd  .O0%............
00000270: 5050 5050 efbf bdef bfbd efbf bd44 44ef  PPPP.........DD.
00000280: bfbd 65ef bfbd 75ef bfbd 7553 efbf bd74  ..e...u...uS...t
00000290: 6450 5050 5050 efbf bd74 64ef bfbd efbf  dPPPPP...td.....
...

Earnestly avatar Feb 15 '22 20:02 Earnestly

Thank you, good catch. A fix is in b60d2ddcfa2909d5103a8a2718ea3123dfd43d22.

hroptatyr avatar Feb 16 '22 07:02 hroptatyr

That commit appears to fix both the demo here and the real example which segfaulted.

Earnestly avatar Feb 16 '22 09:02 Earnestly