[PATCH] fix wrong usage of gethostname()

Marc Mutz mutz at kde.org
Sun Dec 15 23:57:02 GMT 2002


Hi!

These patches fix wrong usage of gethostname in arts/ and kdelibs/ 
(kdebase/ is currently compiling ;-)).

There are two issues:
1. According to my man page of gethostname, gethostname may return a 
truncated hostname. Thus, you should terminate the returned string 
explicitely at the end of the buffer.
2. gethostname can fail. Thus you should explicitely initialize the 
buffer to be empty before calling gethostname and later doing stuff 
like QString::fromLatin1( buf ) on the result.

Marc

-- 
"You're hackers, aren't you," the barman said, eyeing us. No one said
a thing. The darkness of the Eurotunnel rolled by. Apparently we'd
given ourselves away by talking too enthusiastically about IPv6. He
looked around conspiratorially, lowered his voice. "Can you get me
some credit card numbers?"
      -- James J. King "What's the shortest way to hack a Linux box?"
         Telepolis 2001/08/11 (#9293)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gethostname-kdelibs.diff
Type: text/x-diff
Size: 11545 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20021216/f1fdbabd/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gethostname-arts.diff
Type: text/x-diff
Size: 562 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20021216/f1fdbabd/attachment-0001.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20021216/f1fdbabd/attachment.sig>


More information about the kde-core-devel mailing list