[hackers] [sltar] Trailing \0 are not written anymore; Reformating. || gottox

From: <hg_AT_suckless.org>
Date: Sun, 11 Nov 2012 17:23:39 +0100 (CET)

changeset: 3:32318838d4c8
user: gottox_AT_rootkit.lan
date: Wed Dec 19 10:41:03 2007 +0100
files: sltar.c
description:
Trailing \0 are not written anymore; Reformating.


diff -r 4cf52329fb3d -r 32318838d4c8 sltar.c
--- a/sltar.c Wed Dec 19 10:22:19 2007 +0100
+++ b/sltar.c Wed Dec 19 10:41:03 2007 +0100
_AT_@ -27,50 +27,50 @@
                 USAGE;
         lname[100] = fname[100] = '\0';
         for(l = 0, f = NULL; fread(b,END,1,stdin); l -= END) {
- if(l <= 0) {
+ if(l <= 0) {
                         if(*b == '\0')
                                 break;
                         memcpy(fname,b,100);
                         memcpy(lname,b+LINK,100);
- switch(a) {
- case 't':
+ l = strtoull(b + SIZE,0,8) + END;
+ if(a == 't') {
                                 puts(fname);
+ continue;
+ }
+ if(f) {
+ fclose(f);
+ f = NULL;
+ }
+ unlink(fname);
+ switch(b[TYPE]) {
+ case '0': /* file */
+ if(!(f = fopen(b,"w")))
+ perror(fname);
                                 break;
- case 'x':
- if(f) {
- fclose(f);
- f = NULL;
- }
- unlink(b);
- switch(b[TYPE]) {
- case '0': /* file */
- if(!(f = fopen(b,"w")))
- perror(fname);
- break;
- case '1': /* hardlink */
- if(!link(lname,fname))
- perror(fname);
- break;
- case '2': /* symlink */
- if(!symlink(lname,fname))
- perror(fname);
- break;
- case '5': /* directory */
- if(mkdir(fname,(mode_t) strtoull(b+MODE,0,8)))
- perror(fname);
- break;
- case '4': /* block device */
- case '3': /* char device */
- break;
- case '6': /* fifo */
- break;
- default:
- puts("not supported filetype");
- }
+ case '1': /* hardlink */
+ if(!link(lname,fname))
+ perror(fname);
+ break;
+ case '2': /* symlink */
+ if(!symlink(lname,fname))
+ perror(fname);
+ break;
+ case '5': /* directory */
+ if(mkdir(fname,(mode_t) strtoull(b + MODE,0,8)))
+ perror(fname);
+ break;
+ case '4': /* block device */
+ case '3': /* char device */
+ /* TODO */
+ break;
+ case '6': /* fifo */
+ /* TODO */
+ break;
+ default:
+ puts("not supported filetype");
                         }
- l = strtoull(b+SIZE,0,8)+END;
                 }
- else if(a == 'x' && f && !fwrite(b,END,1,f)) {
+ else if(a == 'x' && f && !fwrite(b,l > 512 ? END : l,1,f)) {
                         perror(fname);
                         break;
                 }
Received on Sun Nov 11 2012 - 17:23:39 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 11 2012 - 17:24:16 CET