]> wimlib.net Git - wimlib/commitdiff
win32_apply: bail if paths are too long for a UNICODE_STRING
authorEric Biggers <ebiggers3@gmail.com>
Sat, 29 Jul 2017 20:39:28 +0000 (13:39 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 29 Jul 2017 20:50:08 +0000 (13:50 -0700)
src/win32_apply.c

index 96d9df6f578842eea91fc7b5308066b9a0df5715..94285aca793cf763cd1cf377ecaace6be4eb1bcf 100644 (file)
@@ -1087,6 +1087,12 @@ prepare_target(struct list_head *dentry_list, struct win32_apply_ctx *ctx)
                        8 + 1 + 3);
 
        ctx->pathbuf.MaximumLength = path_max * sizeof(wchar_t);
                        8 + 1 + 3);
 
        ctx->pathbuf.MaximumLength = path_max * sizeof(wchar_t);
+       if (ctx->pathbuf.MaximumLength != path_max * sizeof(wchar_t)) {
+               /* Paths are too long for a UNICODE_STRING! */
+               ERROR("Some paths are too long to extract (> 32768 characters)!");
+               return WIMLIB_ERR_UNSUPPORTED;
+       }
+
        ctx->pathbuf.Buffer = MALLOC(ctx->pathbuf.MaximumLength);
        if (!ctx->pathbuf.Buffer)
                return WIMLIB_ERR_NOMEM;
        ctx->pathbuf.Buffer = MALLOC(ctx->pathbuf.MaximumLength);
        if (!ctx->pathbuf.Buffer)
                return WIMLIB_ERR_NOMEM;