http://www.feep.net/libtar/
どうもビミョーにバグっているような。
パッチ送るかなぁ…。
diff -ru libtar-1.2.11.orig/lib/encode.c libtar-1.2.11/lib/encode.c --- libtar-1.2.11.orig/lib/encode.c 2003-01-07 10:40:59.000000000 +0900 +++ libtar-1.2.11/lib/encode.c 2008-09-01 16:51:22.390625000 +0900 @@ -38,10 +38,12 @@ } for (i = 0; i < T_BLOCKSIZE; i++) - sum += ((char *)(&(t->th_buf)))[i]; + sum += ((unsigned char *)(&(t->th_buf)))[i]; for (i = 0; i < 8; i++) sum += (' ' - t->th_buf.chksum[i]); - int_to_oct(sum, t->th_buf.chksum, 8); + snprintf(t->th_buf.chksum, 8, "%06lo", (unsigned long)(sum)); + t->th_buf.chksum[6] = 0; + t->th_buf.chksum[7] = ' '; } @@ -188,7 +190,7 @@ fmode &= ~S_IFSOCK; fmode |= S_IFIFO; } - int_to_oct(fmode, (t)->th_buf.mode, 8); + int_to_oct((fmode & 0xFFF), (t)->th_buf.mode, 8); } diff -ru libtar-1.2.11.orig/lib/libtar.h libtar-1.2.11/lib/libtar.h --- libtar-1.2.11.orig/lib/libtar.h 2003-01-07 10:40:59.000000000 +0900 +++ libtar-1.2.11/lib/libtar.h 2008-09-01 15:36:22.265625000 +0900 @@ -271,7 +271,7 @@ /* integer to NULL-terminated string-octal conversion */ #define int_to_oct(num, oct, octlen) \ - snprintf((oct), (octlen), "%*lo ", (octlen) - 2, (unsigned long)(num)) + snprintf((oct), (octlen), "%0*lo", (octlen) - 1, (unsigned long)(num)) /* integer to string-octal conversion, no NULL */ void int_to_oct_nonull(int num, char *oct, size_t octlen); diff -ru libtar-1.2.11.orig/lib/util.c libtar-1.2.11/lib/util.c --- libtar-1.2.11.orig/lib/util.c 2003-01-07 10:41:00.000000000 +0900 +++ libtar-1.2.11/lib/util.c 2008-09-01 16:59:24.500000000 +0900 @@ -143,8 +143,8 @@ void int_to_oct_nonull(int num, char *oct, size_t octlen) { - snprintf(oct, octlen, "%*lo", octlen - 1, (unsigned long)num); - oct[octlen - 1] = ' '; + snprintf(oct, octlen, "%0*lo", octlen - 1, (unsigned long)num); + oct[octlen - 1] = 0; }