Bug 89739 - segfault if !getenv("HOME")
Summary: segfault if !getenv("HOME")
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: fontconfig
Version: 9
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Owen Taylor
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2003-04-27 11:41 UTC by David Woodhouse
Modified: 2007-04-18 16:53 UTC (History)
0 users

Clone Of:
Last Closed: 2003-06-10 22:15:47 UTC

Attachments (Terms of Use)
partial fix (477 bytes, patch)
2003-04-27 11:42 UTC, David Woodhouse
no flags Details | Diff

Description David Woodhouse 2003-04-27 11:41:19 UTC
Description of problem:
Apps segfault if $HOME isn't in the environment, because FcStrCopyFilename calls
strlen() on the result of getenv() before checking it for NULL.

# unset HOME ; /usr/bin/bluepin asd asd
Segmentation fault

Fixing the segfault with the (soon to be) attached patch is only vaguely helpful
-- apps still fail to start...

# unset HOME ;
/usr/bin/bluepin asd asd
No fonts found; this probably means that the fontconfig
library is not correctly configured. You may need to
edit the fonts.conf configuration file. More information
about fontconfig can be found in the fontconfig(3) manual
page and on http://fontconfig.org

Setting HOME to a bogus nonexistent directory makes the application work fine;
it's not that the directory is actually required.

Comment 1 David Woodhouse 2003-04-27 11:42:08 UTC
Created attachment 91316 [details]
partial fix

Comment 2 Owen Taylor 2003-04-27 13:29:00 UTC
Just out of couriousity - and to know how important a "functional"
fix is, when would programs be running without $HOME in the environment?
Is this a situation when using getpwuid() would work?

Comment 3 David Woodhouse 2003-04-27 13:49:40 UTC
Not sure how common it'll be -- the example is a GUI dialog box invoked from a
deamon (it's in the bluez-utils package if you want to look closer) and is the
WrongThing anyway -- dbus or whatever will obsolete it soon, hopefully.

If it didn't work with 'HOME=/somebogusdir' and actually _needed_ the home
directory, I'd suggest that it isn't worth fixing. But since it does work like
that, it seems like it might be fairly simple to make it work with !HOME. 

I've worked around it in bluez-utils for now, just by setting HOME to "" in the
bluepin script.

Comment 4 Owen Taylor 2003-06-10 22:15:47 UTC
Fixed upstream as of 2003/02/06, tests OK with fontconfig-2.2.1-1

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