Page MenuHomeFreeBSD

Fix ports-mgmt/portfind string management/searching issues
ClosedPublic

Authored by ngie on Jul 12 2016, 4:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 13, 3:29 PM
Unknown Object (File)
Fri, Nov 1, 5:59 PM
Unknown Object (File)
Oct 2 2024, 1:05 PM
Unknown Object (File)
Sep 21 2024, 3:47 PM
Unknown Object (File)
Sep 17 2024, 12:32 PM
Unknown Object (File)
Sep 8 2024, 9:09 PM
Unknown Object (File)
Sep 8 2024, 6:01 PM
Unknown Object (File)
Sep 8 2024, 11:16 AM
Subscribers

Details

Reviewers
brd
mizhka
Summary

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`.

PR: 211032 [*]
Sponsored by: EMC / Isilon Storage Division

Test Plan
$ portfind portfind
+ portfind-1.6.1 (/usr/ports/ports-mgmt/portfind)
$ portfind pkg     
- dpkg-1.18.9 (/usr/ports/archivers/dpkg)
- R-cran-pkgmaker-0.22 (/usr/ports/devel/R-cran-pkgmaker)
- fpc-fppkg-3.0.0 (/usr/ports/devel/fpc-fppkg)
- libgpkg-0.9.18_2 (/usr/ports/devel/libgpkg)
- p5-ExtUtils-PkgConfig-1.15_1 (/usr/ports/devel/p5-ExtUtils-PkgConfig)
- p5-PkgConfig-0.12026 (/usr/ports/devel/p5-PkgConfig)
- pkg-info.el-0.5_2 (/usr/ports/devel/pkg-info.el)
+ pkgconf-0.9.12_1 (/usr/ports/devel/pkgconf)
- py27-apipkg-1.2 (/usr/ports/devel/py-apipkg)
- py27-pkgconfig-1.1.0 (/usr/ports/devel/py-pkgconfig)
- rubygem-pkg-config-1.1.7_1 (/usr/ports/devel/rubygem-pkg-config)
- octave-forge-odepkg-0.8.5_1 (/usr/ports/math/octave-forge-odepkg)
- managepkg-1.1 (/usr/ports/ports-mgmt/managepkg)
- octopkg-0.2.0 (/usr/ports/ports-mgmt/octopkg)
+ pkg-1.8.7 (/usr/ports/ports-mgmt/pkg)
- pkg-devel-1.8.99.9 (/usr/ports/ports-mgmt/pkg-devel)
- pkg-plist-1.4_1 (/usr/ports/ports-mgmt/pkg-plist)
- pkg-rmleaf-0.3 (/usr/ports/ports-mgmt/pkg-rmleaf)
- pkg_cleanup-2.1 (/usr/ports/ports-mgmt/pkg_cleanup)
- pkg_cutleaves-20090810 (/usr/ports/ports-mgmt/pkg_cutleaves)
- pkg_jail-1.89 (/usr/ports/ports-mgmt/pkg_jail)
- pkg_replace-20160411 (/usr/ports/ports-mgmt/pkg_replace)
- pkg_rmleaves-20140222 (/usr/ports/ports-mgmt/pkg_rmleaves)
- pkg_search-1.3 (/usr/ports/ports-mgmt/pkg_search)
- pkg_tree-1.1_4 (/usr/ports/ports-mgmt/pkg_tree)
- pkgcompare-1.1 (/usr/ports/ports-mgmt/pkgcompare)
- pkgs_which-0.4.1 (/usr/ports/ports-mgmt/pkgs_which)
- firstboot-pkgs-1.4 (/usr/ports/sysutils/firstboot-pkgs)
- gnome-pkgview-1.0.7_6 (/usr/ports/sysutils/gnome-pkgview)
- py27-pkginfo-1.2.1 (/usr/ports/sysutils/py-pkginfo)
$ portfind foobar; echo $?
0

Diff Detail

Repository
rP FreeBSD ports repository
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 4488
Build 4539: arc lint + arc unit

Event Timeline

ngie retitled this revision from to Fix ports-mgmt/portfind string management/searching issues.
ngie updated this object.
ngie edited the test plan for this revision. (Show Details)

Update the patch with the desired content for the program

ports-mgmt/portfind/files/patch-portfind.c
56

This is unnecessary now that release isn't being free'd in get_release(..).

ngie marked an inline comment as done.Jul 12 2016, 5:08 PM
ngie added inline comments.
ports-mgmt/portfind/files/patch-portfind.c
56

Nevermind. goto fail still calls free(release). This comment was invalid (I couldn't read the diff).

ngie marked 2 inline comments as done.Jul 12 2016, 5:08 PM
mizhka added a reviewer: mizhka.
This revision is now accepted and ready to land.Jul 14 2016, 3:19 PM
brd added a reviewer: brd.