changeset 9:d2cd8c5672fa

Increase filename limit 256 bytes is enough for anybody
author Paper <mrpapersonic@gmail.com>
date Wed, 26 Jan 2022 23:12:41 -0500
parents 9d862edfd3cc
children 9692d33cec71 a4e604789e2e
files src/gui.c src/main.c
diffstat 2 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/gui.c	Wed Jan 26 22:32:41 2022 -0500
+++ b/src/gui.c	Wed Jan 26 23:12:41 2022 -0500
@@ -11,7 +11,7 @@
 
 HWND hWndListBox, hWndComboBox;
 int16_t version = 11, type = 1; /* type: 0 is vf, 1 is veg */
-char* file_name = " "; /* initialize as a space, a filename cannot literally just be a space */
+char* file_name = " "; /* initialize as a space, a (windows) filename can't just be a space */
 
 void set_data(unsigned char magic[], uint16_t version, FILE* target) {
 	int i;
@@ -64,14 +64,14 @@
 
 char* open_file(HWND hWnd) {
 	OPENFILENAME ofn;
-	char filename[127];
+	char filename[256];
 
 	ZeroMemory(&ofn, sizeof(OPENFILENAME));
 	ofn.lStructSize = sizeof(OPENFILENAME);
 	ofn.hwndOwner = hWnd;
 	ofn.lpstrFile = filename;
 	ofn.lpstrFile[0] = '\0';
-	ofn.nMaxFile = 127;
+	ofn.nMaxFile = 256;
 	ofn.lpstrFilter = "Project files\0*.veg;*.vf\0All files\0*.*\0";
 	ofn.nFilterIndex = 1;
 
@@ -88,14 +88,14 @@
 		return;
 	}
 	OPENFILENAME ofn;
-	char output_file[127];
+	char output_file[256];
 
 	ZeroMemory(&ofn, sizeof(OPENFILENAME));
 	ofn.lStructSize = sizeof(OPENFILENAME);
 	ofn.hwndOwner = hWnd;
 	ofn.lpstrFile = output_file;
 	ofn.lpstrFile[0] = '\0';
-	ofn.nMaxFile = 127;
+	ofn.nMaxFile = 256;
 	ofn.lpstrFilter = "Project files\0*.veg\0All files\0*.*\0";
 	ofn.nFilterIndex = 1;
 
--- a/src/main.c	Wed Jan 26 22:32:41 2022 -0500
+++ b/src/main.c	Wed Jan 26 23:12:41 2022 -0500
@@ -73,10 +73,10 @@
 	unsigned char magic[16];
 	FILE* outfile;
 	struct arguments {
-		char input[128];
-		char output[128];
+		char input[256];
+		char output[256];
 		int version;
-		char type[128];
+		char type[256];
 	} args;
 	strcpy(args.input, " ");
 	strcpy(args.output, " ");
@@ -147,16 +147,16 @@
 	}
 	fflush(stdout);
 	if (strcmp(args.output, " ") == 0) { /* string manipulation hell */
-		char temp[128] = {'V'};
+		char temp[256] = {'V'};
 		char str_version[16] = {};
 		sprintf(str_version, "%d", args.version);
 		strncat(temp, str_version, 2);
 		strncat(temp, "_", 1);
-		strncat(temp, args.input, 120);
+		strncat(temp, args.input, 248);
 		strcpy(temp, strremove(temp, strrchr(args.input, ('.')))); /* remove file extension */
 		strncat(temp, ".", 1);
 		strncat(temp, args.type, 3);
-		strncpy(args.output, temp, 127);
+		strncpy(args.output, temp, 255);
 	}
 	if (strcmp(args.type, "veg") == 0) {
 		const unsigned char T[] = {0xEF, 0x29, 0xC4, 0x46, 0x4A, 0x90, 0xD2, 0x11, 0x87, 0x22, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A};