Bug 2140566 - /usr/bin/which fails for long path
Summary: /usr/bin/which fails for long path
Keywords:
Status: VERIFIED
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: which
Version: 8.6
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: rc
: ---
Assignee: Than Ngo
QA Contact: CS System Management SST QE
Šárka Jana
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-11-07 09:30 UTC by Pradeep Jagtap
Modified: 2023-07-31 22:28 UTC (History)
2 users (show)

Fixed In Version: which-2.21-20.el8
Doc Type: Bug Fix
Doc Text:
the bug is triggered when user executes the 'which' command in directory with very long path and the consequence is that 'which' aborts with error "Can't get current working directory" To fix this issue it is use PATH_MAX instead hardcoded 256
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-138460 0 None None None 2022-11-07 09:45:24 UTC

Description Pradeep Jagtap 2022-11-07 09:30:27 UTC
Description of problem:
=======================
/usr/bin/which fails for long path

Version-Release number of selected component (if applicable):
which-2.21-17.el8.x86_64

How reproducible:
====================
Steps to Reproduce:
-------------------
1. Create Directory with long path
      # mkdir -p /tmp/1111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000/1111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000/11111111112222222222333333333344444444445555555555

2. Change directory to the created one
     # cd !$

3. Execute which command 
     # which cd

Actual results:
=================
Fails with error:
Can't get current working directory

Expected results:
===================
Should show below results
$ which cd
/usr/bin/cd


Additional info:
=================
In RHEL 7,8 and 9)
-------------------
The buffer is 256 in which.c

static char home[256];
static char cwd[256];
  static char result[256];


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