Bug 235810 - [patch] shells/scponly: segfault in basename(3)
Summary: [patch] shells/scponly: segfault in basename(3)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Renato Botelho
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-17 18:15 UTC by fullermd
Modified: 2019-03-13 15:05 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (garga)


Attachments
Patch - use writable temp buffers for basename(3) calls (701 bytes, patch)
2019-02-17 18:15 UTC, fullermd
no flags Details | Diff
Updated patch that works with FreeBSD 11.2 too (722 bytes, patch)
2019-03-13 13:54 UTC, Stewart Morgan
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description fullermd 2019-02-17 18:15:29 UTC
Created attachment 202098 [details]
Patch - use writable temp buffers for basename(3) calls

In stable/12, basename(3) writes to its argument, which in scponly isn't a writable string, so it segfaults.  Attached patch works around it.

x-ref bug 235121 for similar behavior in rssh.
Comment 1 commit-hook freebsd_committer freebsd_triage 2019-02-25 13:38:46 UTC
A commit references this bug:

Author: garga
Date: Mon Feb 25 13:37:49 UTC 2019
New revision: 493861
URL: https://svnweb.freebsd.org/changeset/ports/493861

Log:
  shells/scponly: fix segfault on FreeBSD 12 and newer

  On FreeBSD 12+ basename(3) writes to its argument, which in scponly isn't a
  writable string, so it segfaults.  This patch works around it.

  PR:		235810
  Submitted by:	fullermd@over-yonder.net

Changes:
  head/shells/scponly/Makefile
  head/shells/scponly/files/patch-helper.c
Comment 2 Stewart Morgan 2019-03-13 13:54:32 UTC
Created attachment 202842 [details]
Updated patch that works with FreeBSD 11.2 too

The original patch may well work with FreeBSD 12, but it breaks under 11.2, possibly because the original patch returns the basename() of cmd->name, not the duplicate of it.  This patch should work with both; only tested under 11.2 though.
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-03-13 15:05:41 UTC
A commit references this bug:

Author: garga
Date: Wed Mar 13 15:04:38 UTC 2019
New revision: 495579
URL: https://svnweb.freebsd.org/changeset/ports/495579

Log:
  shells/scponly: fix segfault on FreeBSD 11

  Patch introduced in r493861 to fix segfault on FreeBSD 12+ broke it on
  FreeBSD 11.  This new version fixes it on both versions.

  While here, pet portlint a bit moving USES to proper place and removing
  RUN_DEPENDS := BUILD_DEPENDS adding individual run depends where it's
  necessary.

  PR:		235810
  Submitted by:	Stewart Morgan <stewart.morgan@gmail.com>
  Sponsored by:	Rubicon Communications, LLC (Netgate)

Changes:
  head/shells/scponly/Makefile
  head/shells/scponly/files/patch-helper.c