From c0d3fd10d0cba3fedfa917e04d39a7803e34df6e Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 29 Jul 2017 13:39:28 -0700 Subject: [PATCH] win32_apply: bail if paths are too long for a UNICODE_STRING --- src/win32_apply.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/win32_apply.c b/src/win32_apply.c index 96d9df6f..94285aca 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -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); + 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; -- 2.43.0