code-audit- reading (unrelated to my first post).

10 views
Skip to first unread message

Zaphod Beeblebrox

unread,
Oct 13, 2021, 1:25:31 PM10/13/21
to libarchive-discuss
So ... I was getting a lay-of-the-land and reading code.  Tar's options are intensely complex, so your own version of getopt is cool... but.

For struct bsdtar_option, in the equivalent field, you have either a literal character or a enumerated constant.  The enumerated constants start at one and I count 56 of them.  That overlaps printable charcters --- even the numbers --- s.t., if I read this correctly, you couldn't have an argument of -0 (among others) as it would conflict with OPOTION_STRIP_COMPONENTS if I count lines correctly.

I would propose starting the enum at either 128 (unprintable characters) or 256 (not a character) or 65536 (not even a wide character).  _or_ -255 (since It's clearly a signed integer).   I haven't read forward to how it's used (other than the case statement in main and probably the printing of usage) ... but this would open up some single character options and prevent expanding the command line from encroaching on used characters (only 9 more to go by my count, before you get to -a).

Zaphod Beeblebrox

unread,
Oct 17, 2021, 1:52:43 PM10/17/21
to libarchive-discuss
In an obvious progression of my source reading, I'm down to archive_write_open_{filename|fp}.c right now.  Both these files contain identical file_write() static functions and nearly identical file_free() functions.  It strikes me in audit mode that the most straightforward refactoring of this code is to combine these two files and making that work doesn't really add any palpable complexity.

Is anyone reading this?  I haven't seen any posts since I started posting here.
Reply all
Reply to author
Forward
0 new messages