RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 816328 - finger segfaults if pw->pw_gecos is NULL.
Summary: finger segfaults if pw->pw_gecos is NULL.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: finger
Version: 6.4
Hardware: All
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Tomáš Hozza
QA Contact: Martin Žember
URL:
Whiteboard:
Depends On:
Blocks: 836169 947782
TreeView+ depends on / blocked
 
Reported: 2012-04-25 19:49 UTC by Lars Kellogg-Stedman
Modified: 2015-07-13 04:14 UTC (History)
6 users (show)

Fixed In Version: finger-0.17-40.el6
Doc Type: Bug Fix
Doc Text:
When the "compat" method is specified in the nsswitch.conf file, special entries containing the "+" or "-" characters are allowed to be used in the /etc/passwd file. Previously, when the finger utility was run with a "username" argument on a host that had the special entries in /etc/passwd, finger terminated with a segmentation fault. With this update, the code that handles the "username" argument has been fixed to perform the necessary checks and the finger utility no longer crashes in the described scenario.
Clone Of:
: 866873 (view as bug list)
Environment:
Last Closed: 2014-06-02 07:20:32 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Patch for this issue. (503 bytes, patch)
2012-10-16 10:28 UTC, Tomáš Hozza
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:0587 0 normal SHIPPED_LIVE finger bug fix update 2014-06-02 11:20:15 UTC

Description Lars Kellogg-Stedman 2012-04-25 19:49:36 UTC
Description of problem:

We have a NIS-bound system with 'passwd: compat' in /etc/nsswitch.conf.  The final line in /etc/passwd on this was system was:

  +:

On this system, "finger" would segfault when passed a username as an
argument.  On line 188 in finger/util.c, finger was calling strncpy()
like this:

  int                         
  match(struct passwd *pw, const char *user)
  {                               
          char *p;                        
          int i, j, ct, rv=0;             
          char *rname;            
                          
          strncpy(tbuf, pw->pw_gecos, TBUFLEN);

With our /etc/passwd file configured as described, pw->pw_gecos would
have a NULL rather than empty value, causing strncpy() to segfault.
An ideal fix would be to have match() return 0 if pw->pw_gecos is
NULL, as in this patch:

diff --git a/finger/util.c b/finger/util.c
index 8e28d63..c82bc86 100644
--- a/finger/util.c
+++ b/finger/util.c
@@ -186,6 +186,9 @@ match(struct passwd *pw, const char *user)
        int i, j, ct, rv=0;
        char *rname;
 
+       if (pw->pw_gecos == NULL)
+               return 0;
+
        strncpy(tbuf, pw->pw_gecos, TBUFLEN);
        tbuf[TBUFLEN-1] = 0;  /* guarantee null termination */
        p = tbuf;

Comment 3 Lars Kellogg-Stedman 2012-10-11 13:02:30 UTC
Problem identified and patch provided...any updates on this issue?  Thanks!

Comment 4 Tomáš Hozza 2012-10-16 10:28:11 UTC
Created attachment 628085 [details]
Patch for this issue.

Comment 13 Tomáš Hozza 2014-03-27 08:58:40 UTC
(In reply to Lars Kellogg-Stedman from comment #3)
> Problem identified and patch provided...any updates on this issue?  Thanks!

Hi Lars.

If everything goes well, this issue will be fixed in the next RHEL-6 minor
update release.

Comment 16 errata-xmlrpc 2014-06-02 07:20:32 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-0587.html


Note You need to log in before you can comment on or make changes to this bug.