HomeFreeBSD

Fix ports-mgmt/portfind string management/searching issues

Description

Fix ports-mgmt/portfind string management/searching issues

Makefile:

Bump `PORT_REVISION` for the change.

portfind.c:

get_release(..):

The function was incorrectly modifying a pointer that wasn't the original
calloc'ed pointer, tripping asserts when MALLOC_PRODUCTION wasn't enabled
in jemalloc [*].

- Use one temporary buffer (`release`) instead of two (`release` and
  `version`).
- Improve temporary memory idiom for managing memory used with
  sysctlbyname(3) by first checking the length, mallocing the buffer,
  then filling it with a second call to sysctlbyname(3).
- Use strchr(3) instead of handrolling it in a while-loop and to
  avoid the improper free(3) of the memory allocated for `release`.

main(..):

- Use asprintf instead of calloc + sprintf.
- Use constant `pasting` with `INDEX_FILE` instead of passing it in to
  asprintf(3).
- Fix error message when unable to open `INDEX_FILE`.

Approved by: brd
Differential Revision: https://reviews.freebsd.org/D7198
PR: 211032 [*]
Reported by: Michael Zhilin <mizhka@gmail.com>
Reviewed by: Michael Zhilin <mizhka@gmail.com>
Sponsored by: EMC / Isilon Storage Division

Details

Provenance
ngieAuthored on
Parents
rP418536: MFH: r418408
Branches
Unknown
Tags
Unknown