Skip to content

Commit

Permalink
Add build-time assert for filename buffer size
Browse files Browse the repository at this point in the history
Suggested by @cfcs
  • Loading branch information
marmarek committed May 28, 2018
1 parent bd44574 commit b5a9d9b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qubes-rpc/qopen-in-vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b5a9d9b

Please sign in to comment.