From bdbfedab84ef2fb5395b6c646549f6ea9351e52d Mon Sep 17 00:00:00 2001 From: Michael Wetherell Date: Thu, 17 Apr 2008 17:29:22 +0000 Subject: [PATCH] Backport getgrgid_r fix. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53248 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/tarstrm.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/tarstrm.cpp b/src/common/tarstrm.cpp index 7233ef3c2d..d7c4d4ca86 100644 --- a/src/common/tarstrm.cpp +++ b/src/common/tarstrm.cpp @@ -359,7 +359,8 @@ static wxString wxTarUserName(int uid) wxCharBuffer buf(bufsize); struct passwd pw; - if (getpwuid_r(uid, &pw, buf.data(), bufsize, &ppw) == 0) + memset(&pw, 0, sizeof(pw)); + if (getpwuid_r(uid, &pw, buf.data(), bufsize, &ppw) == 0 && pw.pw_name) return wxString(pw.pw_name, wxConvLibc); #else if ((ppw = getpwuid(uid)) != NULL) @@ -381,7 +382,8 @@ static wxString wxTarGroupName(int gid) wxCharBuffer buf(bufsize); struct group gr; - if (getgrgid_r(gid, &gr, buf.data(), bufsize, &pgr) == 0) + memset(&gr, 0, sizeof(gr)); + if (getgrgid_r(gid, &gr, buf.data(), bufsize, &pgr) == 0 && gr.gr_name) return wxString(gr.gr_name, wxConvLibc); #else if ((pgr = getgrgid(gid)) != NULL)