From b5a9d9bf8e12f991ad52c4d36922f8e069e5f440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 28 May 2018 22:45:39 +0200 Subject: [PATCH] Add build-time assert for filename buffer size Suggested by @cfcs --- qubes-rpc/qopen-in-vm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qubes-rpc/qopen-in-vm.c b/qubes-rpc/qopen-in-vm.c index 5e796a5..62985ff 100644 --- a/qubes-rpc/qopen-in-vm.c +++ b/qubes-rpc/qopen-in-vm.c @@ -21,6 +21,10 @@ void send_file(const char *fname, int view_only) int fd = open(fname, O_RDONLY); if (fd < 0) gui_fatal("open %s", fname); + + _Static_assert(DVM_FILENAME_SIZE > sizeof(DVM_VIEW_ONLY_PREFIX), + "DVM_FILENAME_SIZE > sizeof(DVM_VIEW_ONLY_PREFIX)"); + if (view_only) { strncpy(sendbuf, DVM_VIEW_ONLY_PREFIX, sendbuf_size); sendbuf_size -= strlen(DVM_VIEW_ONLY_PREFIX);