Add build-time assert for filename buffer size

Suggested by @cfcs
This commit is contained in:
Marek Marczykowski-Górecki 2018-05-28 22:45:39 +02:00
parent bd445742fb
commit b5a9d9bf8e
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -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);