Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unadf improperly parses options with an argument #67

Closed
t-w opened this issue Jan 18, 2024 · 2 comments
Closed

unadf improperly parses options with an argument #67

t-w opened this issue Jan 18, 2024 · 2 comments
Labels

Comments

@t-w
Copy link
Collaborator

t-w commented Jan 18, 2024

2 issues have been found in the unadf command line option parser:

  1. unadf segfaults on invalid parameters
$ unadf -v
unADF v1.2 : a unzip like for .ADF files, powered by ADFlib (v0.8.0 - 2023-06-26)

Segmentation fault

$ unadf -d
unADF v1.2 : a unzip like for .ADF files, powered by ADFlib (v0.8.0 - 2023-06-26)

Segmentation fault
(gdb) r
Starting program: [...]/ADFlib/build/debug/examples/unadf -v
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
unADF v1.2 : a unzip like for .ADF files, powered by ADFlib (v0.8.0 - 2023-06-26)


Program received signal SIGSEGV, Segmentation fault.
__strlen_sse2 () at ../sysdeps/x86_64/multiarch/strlen-sse2.S:142
142     ../sysdeps/x86_64/multiarch/strlen-sse2.S: No such file or directory.
(gdb) bt
#0  __strlen_sse2 () at ../sysdeps/x86_64/multiarch/strlen-sse2.S:142
#1  0x00005555555a1f8d in __interceptor_strlen.part.0 ()
#2  0x000055555565895f in parse_args (argc=2, argv=0x7fffffffde68)
    at [...]/ADFlib/examples/unadf.c:199
#3  0x00005555556580a4 in main (argc=2, argv=0x7fffffffde68)
    at [...]/ADFlib/examples/unadf.c:94

  1. The argument given after the two options requiring an argument is (unexpectedly) used for both:
$ ../unadf -dv 0 ../tests/arccsh.adf
unADF v1.2 : a unzip like for .ADF files, powered by ADFlib (v0.8.0 - 2023-06-26)

Device : Floppy DD. Cylinders = 80, Heads = 2, Sectors = 11. Volumes = 1
Volume : Floppy 880 KBytes, "cshell" between sectors [0-1759]. OFS. Filled at 75.2%.
x - 0/c/
x - 0/c/Format
x - 0/c/Mount
x - 0/c/Zip
x - 0/c/Type
x - 0/c/DMS
x - 0/c/cmd.txt
x - 0/c/UNLZX
x - 0/c/Relabel
x - 0/c/Info
x - 0/c/CPU
x - 0/c/Assign
x - 0/c/Deksid
x - 0/c/List
x - 0/c/transdisk
x - 0/c/LhA
x - 0/c/LoadWB
x - 0/c/LZX
x - 0/l/
x - 0/l/LZX.Keyfile
x - 0/devs/
x - 0/devs/DOSDrivers/
x - 0/devs/DOSDrivers/SD0.info
x - 0/devs/DOSDrivers/SD0
x - 0/devs/statram.device
x - 0/devs/SyStEm-CoNfIgUrAtIoN
x - 0/s/
x - 0/s/.cshrc
x - 0/s/aliases
x - 0/s/.login
x - 0/s/startup-sequence
x - 0/libs/
x - 0/libs/arp.library
x - 0/libs/asl.library
x - 0/libs/diskfont.library
x - 0/CSH
x - 0/LoadWB
x - 0/system-configuration

$ ls
0

$ ls 0
c  CSH  devs  l  libs  LoadWB  s  system-configuration
  • Both to fix.
@t-w t-w added the bug label Jan 18, 2024
@t-w
Copy link
Collaborator Author

t-w commented Jan 18, 2024

@kyz, would you find a moment to have a look a this?

(We should fix this for the next release that is planned rather soon...).

@t-w t-w changed the title unadf segfaults on invalid parameters unadf improperly parses options with an argument Jan 21, 2024
@t-w
Copy link
Collaborator Author

t-w commented Jan 21, 2024

Actually, for 2 we have:

unADF v1.2 : a unzip like for .ADF files, powered by ADFlib (v0.8.0 - 2023-06-26)

Device : Floppy DD. Cylinders = 80, Heads = 2, Sectors = 11. Volumes = 1
Volume : Floppy 880 KBytes, "cshell" between sectors [0-1759]. OFS. Filled at 75.2%.
x - 3/c/
x - 3/c/Format
x - 3/c/Mount
x - 3/c/Zip
x - 3/c/Type
x - 3/c/DMS
x - 3/c/cmd.txt
x - 3/c/UNLZX
x - 3/c/Relabel
x - 3/c/Info
x - 3/c/CPU
x - 3/c/Assign
x - 3/c/Deksid
x - 3/c/List
x - 3/c/transdisk
x - 3/c/LhA
x - 3/c/LoadWB
x - 3/c/LZX
x - 3/l/
x - 3/l/LZX.Keyfile
x - 3/devs/
x - 3/devs/DOSDrivers/
x - 3/devs/DOSDrivers/SD0.info
x - 3/devs/DOSDrivers/SD0
x - 3/devs/statram.device
x - 3/devs/SyStEm-CoNfIgUrAtIoN
x - 3/s/
x - 3/s/.cshrc
x - 3/s/aliases
x - 3/s/.login
x - 3/s/startup-sequence
x - 3/libs/
x - 3/libs/arp.library
x - 3/libs/asl.library
x - 3/libs/diskfont.library
x - 3/CSH
x - 3/LoadWB
x - 3/system-configuration

so v (volume) silently becomes 0.

These options should rather be only allowed to be given separately - where they work fine (except 1.):

$ ../unadf -d 4 -v 3 ../tests/arccsh.adf
unADF v1.2 : a unzip like for .ADF files, powered by ADFlib (v0.8.0 - 2023-06-26)

Device : Floppy DD. Cylinders = 80, Heads = 2, Sectors = 11. Volumes = 1
../tests/arccsh.adf: volume 3 is invalid (device has 1 volume(s))

@t-w t-w mentioned this issue Jan 22, 2024
t-w added a commit to t-w/ADFlib that referenced this issue Jan 22, 2024
Fixed and improved checking options requiring arguments.
@t-w t-w closed this as completed Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant