diff --git a/libmspack/mspack/cabd.c b/libmspack/mspack/cabd.c index d3083de..c8597fd 100644 --- a/libmspack/mspack/cabd.c +++ b/libmspack/mspack/cabd.c @@ -1012,7 +1012,7 @@ static int cabd_extract(struct mscab_decompressor *base, struct mscabd_folder_p *fol; struct mspack_system *sys; struct mspack_file *fh; - off_t filelen; + unsigned int filelen; if (!self) return MSPACK_ERR_ARGS; if (!file) return self->error = MSPACK_ERR_ARGS; @@ -1049,7 +1049,7 @@ static int cabd_extract(struct mscab_decompressor *base, * In salvage mode, don't assume block sizes, just try decoding */ if (!self->salvage) { - off_t maxlen = fol->base.num_blocks * CAB_BLOCKMAX; + unsigned int maxlen = fol->base.num_blocks * CAB_BLOCKMAX; if ((file->offset + filelen) > maxlen) { sys->message(NULL, "ERROR; file \"%s\" cannot be extracted, " "cabinet set is incomplete", file->filename); diff --git a/libmspack/test/cabd_md5.c b/libmspack/test/cabd_md5.c index 7585275..b8f31b6 100644 --- a/libmspack/test/cabd_md5.c +++ b/libmspack/test/cabd_md5.c @@ -7,7 +7,7 @@ #include #include "mspack.h" #include -#ifdef _WIN32 +#ifdef _MSC_VER #include "dirent.h" #else #include diff --git a/libmspack/test/cabd_test.c b/libmspack/test/cabd_test.c index ab82dcd..2b94ed2 100644 --- a/libmspack/test/cabd_test.c +++ b/libmspack/test/cabd_test.c @@ -20,6 +20,13 @@ unsigned int test_count = 0; if (!(x)) {printf("%s:%d FAILED %s\n",__func__,__LINE__,#x);exit(1);} \ } while (0) + +#ifdef _MSC_VER +# define DEV_NULL "NUL" +#else +# define DEV_NULL "/dev/null" +#endif + /* open where cab file doesn't exist */ void cabd_open_test_01() { struct mscab_decompressor *cabd; @@ -342,7 +349,7 @@ void cabd_extract_test_01() { TEST(cab = cabd->open(cabd, files[i])); TEST(cab->files != NULL); for (file = cab->files; file; file = file->next) { - int err = cabd->extract(cabd, file, "/dev/null"); + int err = cabd->extract(cabd, file, DEV_NULL); TEST(err == MSPACK_ERR_DATAFORMAT || err == MSPACK_ERR_DECRUNCH); } cabd->close(cabd, cab); @@ -363,11 +370,11 @@ void cabd_extract_test_02() { */ TEST(cabd = mspack_create_cab_decompressor(NULL)); TEST(cab = cabd->open(cabd, TESTFILE("cve-2014-9732-folders-segfault.cab"))); - err = cabd->extract(cabd, cab->files, "/dev/null"); + err = cabd->extract(cabd, cab->files, DEV_NULL); TEST(err == MSPACK_ERR_OK); - err = cabd->extract(cabd, cab->files->next, "/dev/null"); + err = cabd->extract(cabd, cab->files->next, DEV_NULL); TEST(err == MSPACK_ERR_DATAFORMAT || err == MSPACK_ERR_DECRUNCH); - err = cabd->extract(cabd, cab->files, "/dev/null"); + err = cabd->extract(cabd, cab->files, DEV_NULL); TEST(err == MSPACK_ERR_OK); cabd->close(cabd, cab); mspack_destroy_cab_decompressor(cabd);