bugDatabase-driven manual pager suite - Bugs: bug #60906, pathappend() mangles paths whose...

 
 

bug #60906: pathappend() mangles paths whose suffix is an element of oldpath

Submitter:  None
Submitted:  Sat 10 Jul 2021 05:56:10 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  cjwatson
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 04 Feb 2022 03:15:42 PM UTC, comment #2: 

Fixed in man-db 2.10.0.

Colin Watson <cjwatson>
Group administrator
Sun 11 Jul 2021 09:24:02 AM UTC, comment #1: 

Thanks for the very clear report!  Fixed for man-db 2.9.5:

  https://git.savannah.gnu.org/cgit/man-db.git/commit/?id=de881fb03bd80d55eab8bb4a842b483d85184062

Colin Watson <cjwatson>
Group administrator
Sat 10 Jul 2021 05:56:10 PM UTC, original submission:  

NOTICED ISSUE: man(1) produces odd errors when running on a SmartOS LX-branded zone

$ man man > /dev/null

EXPECTED OUTPUT: nothing

ACTUAL OUTPUT:
$ man man > /dev/null
mandb: can't remove /native/.zonecontrol/36786: Permission denied
mandb: can't search directory /native/.zonecontrol: Permission denied
mandb: can't remove /native/proc/36786: Function not implemented

ROOT CAUSE ANALYSIS:

There should be no reason for man(1) to touch /native/.zonecontrol or /native/proc at all.

I tried running with debug enabled, and I noticed that the issue appears while processing the manpath in add_nls_manpaths().

$ man -d man > /dev/null
<OMITTED FOR BREVITY>
add_nls_manpaths(): processing /usr/share/man:/usr/local/share/man:/native/usr/share/man:/native/usr/share/man:/native/usr/share/man
checking for locale en_US.UTF-8
/usr/share/man:/usr/local/share/man:/native/usr/share/man reduced to /usr/share/man:/usr/local/share/man:/native
/usr/share/man:/usr/local/share/man:/native:/native/usr/share/man reduced to /usr/share/man:/usr/local/share/man:/native
/usr/share/man:/usr/local/share/man:/native:/native/usr/share/man reduced to /usr/share/man:/usr/local/share/man:/native
<OMITTED FOR BREVITY>

(Never mind why I have /native/usr/share/man three times in my manpath, this is just the result of nested shell environments

The problem seems to lie in src/manp.c:286

 281             search = strstr (app_dedup, tok);
 282             while (search) {
 283                 char *terminator = search + strlen (tok);
 284                 if (!*terminator) {
 285                     /* End of the string, so chop here. */
 286                     *search = 0;
 287                     while (search > app_dedup &&
 288                            *--search == ':')
 289                         *search = 0;
 290                     break;
 291                 } else if (*terminator == ':') {

It seems that above, add_nls_manpaths() called get_nls_manpath() which calls (the equivalent of)

pathappend("/usr/share/man:/usr/local/share/man", "/native/usr/share/man")

On line 281 "/usr/share/man" is found as a substring of "/native/usr/share/man", and the found part if followed by '\0'. app_dedup then becomes "/native\0usr/share/man" and gets mangled into "/native" instead.

 303         if (!STREQ (appendage, app_dedup))
 304             debug ("%s:%s reduced to %s%s%s\n",
 305                    oldpath, appendage,
 306                    oldpath, *app_dedup ? ":" : "", app_dedup);
 307         if (*app_dedup)
 308             oldpath = appendstr (oldpath, ":", app_dedup,
 309                          (void *) 0);

STEPS TO REPRODUCE:

$ MANPATH=/usr/share/man manpath
manpath: warning: $MANPATH set, ignoring /etc/man_db.conf
/usr/share/man
$ sudo mkdir -p /foo/usr/share/man
$ MANPATH=/usr/share/man:/foo/usr/share/man man -d man >&/dev/null 2>&1 | grep reduced
/usr/share/man:/foo/usr/share/man reduced to /usr/share/man:/foo

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by cjwatson (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-02-04 cjwatson StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2021-07-11 cjwatson StatusNone Ready For Test
        Assigned toNone cjwatson

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code