[hackers] [sbase] Make the tar(1)-header fixed again || FRIGN

From: <git_AT_suckless.org>
Date: Mon, 16 Feb 2015 20:12:14 +0100 (CET)

commit 252427f160b01383f536fae6095b120a2ce4ef46
Author: FRIGN <dev_AT_frign.de>
Date: Mon Feb 16 20:01:33 2015 +0100

    Make the tar(1)-header fixed again
    
    This is clearer.

diff --git a/tar.c b/tar.c
index 43fe80b..74146ef 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -21,8 +21,8 @@ struct header {
         char chksum[8];
         char type;
         char link[100];
- char *magic;
- char *version;
+ char magic[6];
+ char version[2];
         char uname[32];
         char gname[32];
         char major[8];
_AT_@ -111,8 +111,8 @@ archive(const char* path)
         putoctal(h->gid, (unsigned)st.st_gid, sizeof(h->gid));
         putoctal(h->size, 0, sizeof(h->size));
         putoctal(h->mtime, (unsigned)st.st_mtime, sizeof(h->mtime));
- h->magic = "ustar";
- h->version = "00";
+ memcpy(h->magic, "ustar", sizeof(h->magic));
+ memcpy(h->version, "00", sizeof(h->version));
         snprintf(h->uname, sizeof h->uname, "%s", pw ? pw->pw_name : "");
         snprintf(h->gname, sizeof h->gname, "%s", gr ? gr->gr_name : "");
 
Received on Mon Feb 16 2015 - 20:12:14 CET

This archive was generated by hypermail 2.3.0 : Mon Feb 16 2015 - 20:24:11 CET