Fix ar naming and io read/write api (#3419)

This commit is contained in:
Giovanni 2023-03-10 14:21:39 +08:00 committed by GitHub
parent 125f0333aa
commit c7dfbbcdcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View file

@ -113,14 +113,22 @@ static int rz_io_ar_read(RzIO *io, RzIODesc *fd, ut8 *buf, int count) {
if (!fd || !fd->data || !buf) {
return -1;
}
return ar_read_at((RzArFp *)fd->data, io->off, buf, count);
int res = ar_read_at((RzArFp *)fd->data, io->off, buf, count);
if (res > 0) {
io->off += res;
}
return res;
}
static int rz_io_ar_write(RzIO *io, RzIODesc *fd, const ut8 *buf, int count) {
if (!fd || !fd->data || !buf) {
return -1;
}
return ar_write_at((RzArFp *)fd->data, io->off, (void *)buf, count);
int res = ar_write_at((RzArFp *)fd->data, io->off, (void *)buf, count);
if (res > 0) {
io->off += res;
}
return res;
}
static int rz_io_ar_close(RzIODesc *fd) {

View file

@ -177,8 +177,9 @@ static void ar_sanitize_name(RzArFp *arf) {
// thus the path needs to be unix only
arf->name[i] = '/';
} else if (!IS_PATH(arf->name[i])) {
trim_end = false;
arf->name[i] = '_';
} else {
trim_end = false;
}
}
}

View file

@ -319,11 +319,11 @@ EOF
RUN
NAME=Open only one object in the win archive file.
FILE=ar://bins/ar/ucrtd.osmode.lib//d_/os/obj/x86fre/minkernel/crts/ucrt/src/appcrt/dll/osmode_debug_public/../not_callable_by_os_objfre_i386_clog10l.obj
FILE=ar://bins/ar/ucrtd.osmode.lib//d_/os/obj/x86fre/minkernel/crts/ucrt/src/appcrt/dll/osmode_debug_public/../not_callable_by_os/objfre/i386/clog10l.obj
CMDS=<<EOF
ol
EOF
EXPECT=<<EOF
3 * r-x 0x000000b4 d_/os/obj/x86fre/minkernel/crts/ucrt/src/appcrt/dll/osmode_debug_public/../not_callable_by_os_objfre_i386_clog10l.obj
3 * r-x 0x000000b4 d_/os/obj/x86fre/minkernel/crts/ucrt/src/appcrt/dll/osmode_debug_public/../not_callable_by_os/objfre/i386/clog10l.obj
EOF
RUN