tar: Don't crash when get{pw,gr}uid fails
This commit is contained in:
parent
73115682ed
commit
453ce96d44
4
tar.c
4
tar.c
|
@ -177,8 +177,8 @@ archive(const char* path)
|
||||||
putoctal(h->mtime, (unsigned)st.st_mtime, sizeof h->mtime);
|
putoctal(h->mtime, (unsigned)st.st_mtime, sizeof h->mtime);
|
||||||
memcpy(h->magic, "ustar", sizeof h->magic);
|
memcpy(h->magic, "ustar", sizeof h->magic);
|
||||||
memcpy(h->version, "00", sizeof h->version);
|
memcpy(h->version, "00", sizeof h->version);
|
||||||
snprintf(h->uname, sizeof h->uname, "%s", pw->pw_name);
|
snprintf(h->uname, sizeof h->uname, "%s", pw ? pw->pw_name : "");
|
||||||
snprintf(h->gname, sizeof h->gname, "%s", gr->gr_name);
|
snprintf(h->gname, sizeof h->gname, "%s", gr ? gr->gr_name : "");
|
||||||
|
|
||||||
mode = st.st_mode;
|
mode = st.st_mode;
|
||||||
if(S_ISREG(mode)) {
|
if(S_ISREG(mode)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user