From 899683398997e2e36da6750b5f5bebd0e32a629f Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Mon, 29 Dec 2014 22:16:21 +0200 Subject: [PATCH] Fix crash on Ubuntu when opening assembly files. Ubuntu enables GCC's buffer overflow checks by default. In SAVEDptr union, the path was declared as 'char', even though MAX_PATH memory was actually allocated. The buffer overflow check mistakenly thought that the buffer size was only 1 and aborted the program whenever it tried to read a path from a file. --- src/file.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index ff8dc36..b1b661b 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -204,7 +204,7 @@ const SolveSpace::SaveTable SolveSpace::SAVED[] = { union SAVEDptr { IdList M; NameStr N; - char P; + char P[MAX_PATH]; bool b; RgbColor c; int d; @@ -228,7 +228,7 @@ void SolveSpace::SaveUsingTable(int type) { fprintf(fh, "%s=", SAVED[i].desc); switch(fmt) { case 'N': fprintf(fh, "%s", p->N.str); break; - case 'P': fprintf(fh, "%s", &(p->P)); break; + case 'P': fprintf(fh, "%s", p->P); break; case 'b': fprintf(fh, "%d", p->b ? 1 : 0); break; case 'c': fprintf(fh, "%08x", p->c.ToPackedInt()); break; case 'd': fprintf(fh, "%d", p->d); break; @@ -385,7 +385,7 @@ void SolveSpace::LoadUsingTable(char *key, char *val) { break; case 'P': - if(strlen(val)+1 < MAX_PATH) strcpy(&(p->P), val); + if(strlen(val)+1 < MAX_PATH) strcpy(p->P, val); break; case 'M': {