X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2eb37f730d29c1edd3e3339930f12c3c2d2635b3..5b8cadd2bab565c99d0f13b2450bf30c0a626af9:/src/common/tarstrm.cpp diff --git a/src/common/tarstrm.cpp b/src/common/tarstrm.cpp index 32b55f3a7b..7eb827582e 100644 --- a/src/common/tarstrm.cpp +++ b/src/common/tarstrm.cpp @@ -362,7 +362,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) @@ -384,7 +385,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) @@ -943,7 +945,7 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs) size_t recPos, recSize; bool ok = true; - for (recPos = 0; recPos < len; recPos += recSize) { + for (recPos = 0; recPos < len && ok; recPos += recSize) { char *pRec = buf.data() + recPos; char *p = pRec;