jmichaelh / xar

Automatically exported from code.google.com/p/xar
0 stars 0 forks source link

Directory added with trailing slash shows properties set to null #65

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. xar -cf bar.xar file directory/ (the trailing slash is important!)
2. try to list the archive contents using pyxar:

    from xarfile import XarArchive
    XarArchive('bar.xar').getitems()

3. you get segfault and the reason is that the uid is set to null as the
simple program below will show:

#include <xar/xar.h>
#include <stdio.h>

void usage(char* argv[]){
    fprintf(stderr,"Usage : %s archive_name\n",argv[0]);
}

int main(int argc, char* argv[]){
    if (argc < 2){
        usage(argv);
        exit(1);
    }

    xar_t x;
    xar_iter_t i;
    xar_file_t f;

    x = xar_open(argv[1],READ);
    if ( x==NULL ){
        fprintf(stderr, "error opening xarchive: %s\n", argv[1]);
        exit(1);
    }

    i = xar_iter_new(x);
    if (!i){
        fprintf(stderr,"error creating iterator\n");
        exit(1);
    }

    for (f = xar_file_first(x,i);f;f=xar_file_next(i)){
        const char *name, *_type, *mode, *uid, *user, *gid, *group, *atime,
*mtime, *ctime;
        name = xar_get_path(f);
        xar_prop_get(f, "type", &_type);
        xar_prop_get(f, "mode", &mode);
        xar_prop_get(f, "uid", &uid);
        xar_prop_get(f, "user", &user);
        xar_prop_get(f, "gid", &gid);
        xar_prop_get(f, "group", &group);
        xar_prop_get(f, "atime", &atime);
        xar_prop_get(f, "mtime", &mtime);
        xar_prop_get(f, "ctime", &ctime);
        fprintf(stdout,"name %s, type %s, mode %s, uid %s, user %s, gid %s,
group %s, atime %s, mtime %s, ctime %s\n",
                name,_type,mode,uid,user,gid,group,atime,mtime,ctime);
        }
    xar_close(x);
}

One of the files below was created without using the trailing slash, and
the other one with trailing slash.

Original issue reported on code.google.com by radaczynski on 13 Jan 2009 at 11:27

Attachments: