pkg
pkg copied to clipboard
Pkg segfaults when adding a package whose manifest does not have abi or arch
If the +MANIFEST file does not contain abi or arch, pkg add segfaults.
For example:
{
"name": "example",
"version": "1.0.0",
"comment": "example package",
"desc": "Example package.",
"origin": "misc/example",
"www": "https://github.com/example/example",
"maintainer": "Nicolas Martyanoff <[email protected]>",
"prefix": "/"
}
With GDB:
(gdb) bt
#0 0x0000000800cf46c0 in strncasecmp_l () from /lib/libc.so.7
#1 0x000000000048b490 in is_valid_abi ()
#2 0x00000000004707ad in pkg_add_common ()
#3 0x00000000004705a8 in pkg_add ()
#4 0x00000000002a9c2d in exec_add ()
#5 0x00000000002b32e6 in main ()
The problem is that pkg_add_check_pkg_archive assumes that either pkg->abi or pkg->arch is not null.
There are two possibilities:
- Make
archmandatory and make sure it is not null inpkg_is_valid. - Do not call
is_valid_abiif bothabiandarchare null.
Do you have a preference ? I do not see the point in forcing arch (some packages are arch-independent), but it is up to you. I can send a patch.
Context: I'm writing a program to generate freebsd packages which automatically builds the file/directory index, generates the pre-install script for the required users, etc.