title: strncpy() core dump when I use Libtar in ubuntu12.04
body: <p>I trace the coredump in the encode.c:33.</p>
  
  <p>The source code like this:</p>
  
  <pre><code>if (t-&gt;options &amp; TAR_GNU) 
      strncpy(t-&gt;th_buf.magic, "ustar  ", 8);    // here is the coredump                                                                                                                                 
  else
      .... 
  </code></pre>
  
  <p>the function call stack like this:</p>
  
  <pre><code>0x4064d73a in strncpy (__len=8, __src=0x40663b34 "ustar  ", __dest=0x4104e5ed "") at /usr/include/i386-linux-gnu/bits/string3.h:121
  0x4024e342 in __strncpy_chk () from /lib/i386-linux-gnu/libc.so.6
  0x4024ee1a in __chk_fail () from /lib/i386-linux-gnu/libc.so.6
  0x40250065 in __fortify_fail () from /lib/i386-linux-gnu/libc.so.6
  0x401b739a in ?? () from /lib/i386-linux-gnu/libc.so.6
  0x4017d825 in abort () from /lib/i386-linux-gnu/libc.so.6
  0x4017a1df in raise () from /lib/i386-linux-gnu/libc.so.6
  0x40064424 in __kernel_vsyscall ()
  &lt;signal handler called&gt;
  sig_coredump (sig=6) at mpm_common.c:1207
  </code></pre>
  
  <p>the t->th_buf.magic is sturct of tar_header, the defination:</p>
  
  <pre><code>struct tar_header{
      ...;
      char magic[6];
      char version[2];
      ...;
  }
  </code></pre>
  
  <p>I pretty sure strncpy can use in this way.</p>
  
  <p>And in my case, the t->th_buf has malloc already.</p>
  
  <p>In gdb:</p>
  
  <pre><code>(gdb) p t-&gt;th_buf
  $5 = {name = "/TARFILE.C", '\000' &lt;repeats 89 times&gt;, mode = "100644 ", 
        uid = "    41", gid = "    41 ", size = "     207114 ", mtime = "12115070475 ", 
        chksum = "\000\000\000\000\000\000\000", typeflag = 48 '0', linkname = '\000' &lt;repeats 99 times&gt;, 
        magic = "\000\000\000\000\000", version = "\000",
        ...
  </code></pre>