Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 9761 - `man -k` seg faults if its argument contains multiple words
Summary: `man -k` seg faults if its argument contains multiple words
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-27 09:12 UTC by Ivan Raikov
Modified: 2002-12-29 11:42 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
man-1.5k-util_c-segfault.patch (man-1.5k-util_c-segfault.patch,2.22 KB, patch)
2002-12-26 12:55 UTC, Martin Schlemmer (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Raikov 2002-10-27 09:12:21 UTC
$ man -k blah       
blah: nothing appropriate

$ man -k "blah blah"
sh: unsafe: command not found
Error executing formatting or display command.
System command unsafe exited with status 127.
Segmentation fault

$ man --version
man, version 1.5k
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2002-12-26 12:55:57 UTC
Created attachment 6746 [details, diff]
man-1.5k-util_c-segfault.patch

  26 Dec 2002; Martin Schlemmer <azarah@gentoo.org> man-1.5k.ebuild,
						    man-1.5k-r1.ebuild :

  Bugfixes:
  - Add man-1.5k-util_c-segfault.patch to fix a crash when calling man
    with:  man -k "foo bar" (bug #9761).
Comment 2 Martin Schlemmer (RETIRED) gentoo-dev 2002-12-26 12:58:58 UTC
The reason for this is that my_xsprintf() in util.c passes
NOT_SAFE as the result if the string is not shell safe.
When do_appros() (or whatever) then calls 'free(command)',
free() tries to free a constant, and segfault.

The attached solution are not eligant, but works without
breaking the API.  Basically we redefine NOT_SAFE as a
message that we want to display, prepended with 'echo'.
When the command is then executed, our message are displayed,
and not the the line containing:
  
  sh: line 1: unsafe: command not found

Further more, we do not return NOT_SAFE, but rather a string
that we malloc, and then fill with the contents of NOT_SAFE,
which will solve us trying to free a constant.

Alternatively it is possible to redefine what is "shell safe",
but that will me a much more comprehensive fix ...

-----
$ man -k "blah blah"
Cannot run command, as it is not shell safe!
Check that you do not quote search strings, etc.
Comment 3 Martin Schlemmer (RETIRED) gentoo-dev 2002-12-29 11:42:39 UTC
Fixed.