[hackers] [sbase] tar: Don't crash when get{pw,gr}uid fails || Michael Forney
commit 453ce96d44b8bf9de7cccb68dba9d5233d630ea2
Author: Michael Forney <mforney_AT_mforney.org>
Date: Sat Nov 1 20:36:37 2014 +0000
tar: Don't crash when get{pw,gr}uid fails
diff --git a/tar.c b/tar.c
index 4f4abff..c18d89e 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -177,8 +177,8 @@ archive(const char* path)
putoctal(h->mtime, (unsigned)st.st_mtime, sizeof h->mtime);
memcpy(h->magic, "ustar", sizeof h->magic);
memcpy(h->version, "00", sizeof h->version);
- snprintf(h->uname, sizeof h->uname, "%s", pw->pw_name);
- snprintf(h->gname, sizeof h->gname, "%s", gr->gr_name);
+ snprintf(h->uname, sizeof h->uname, "%s", pw ? pw->pw_name : "");
+ snprintf(h->gname, sizeof h->gname, "%s", gr ? gr->gr_name : "");
mode = st.st_mode;
if(S_ISREG(mode)) {
Received on Sat Nov 01 2014 - 23:34:01 CET
This archive was generated by hypermail 2.3.0
: Sat Nov 01 2014 - 23:36:24 CET