From 14de087472737ffa116912dbcba7741c8b27e862 Mon Sep 17 00:00:00 2001 From: Marcos Marado Date: Thu, 26 Feb 2015 15:44:03 +0000 Subject: [PATCH 1/2] compilation default without optimization Taking -O2 from the compilation flags with make Amnuts behave a little better (avoiding crashes), specially in recent gcc versions. Those bugs should be hunted and fixed, but in the meantime, better "safe" than sorry. --- src/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 054e27e..c0dc3e0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -43,7 +43,8 @@ IDENTDCPPFLAGS = -I$(INCDIR) #IDENTDCPPFLAGS = -I$(INCDIR) -DMANDNS # These are sort of gcc dependant; roll your own if you use another compiler -CFLAGS = -g -O2 -Wall -W +CFLAGS = -g -Wall -W +#CFLAGS = -g -O2 -Wall -W #CFLAGS = -g -O0 -fno-inline #CFLAGS = -g -O2 -Wall -W -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wpacked -Wnested-externs -Winline -Wlong-long #CFLAGS = -g -O2 -Wall -W -pedantic -Wfloat-equal -Wtraditional -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Wunreachable-code -Winline -Wlong-long From 06981062bc077e4c6cffa9f67fc59939934c9c61 Mon Sep 17 00:00:00 2001 From: Marcos Marado Date: Thu, 26 Feb 2015 15:46:23 +0000 Subject: [PATCH 2/2] Adjust buffer size properly If you're creating a char buffer to which you're planning to strcpy stuff, you need to take into account in its length space for the terminating null character. In this case, we sometimes strcpy "YES" there, so we need it to be of size 4. While I'm fixing this here, I'd bet: 1) we have this same issue in other places (size 3 buffers for noyes results); 2) we have a similar issue with other buffers; --- src/amnuts230.c | 2 +- src/includes/globals.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/amnuts230.c b/src/amnuts230.c index 4952fb4..c73a262 100644 --- a/src/amnuts230.c +++ b/src/amnuts230.c @@ -6924,7 +6924,7 @@ help_amnuts_credits(UR_OBJECT user) void status(UR_OBJECT user) { - char ir[ROOM_NAME_LEN + 1], text2[ARR_SIZE], text3[ARR_SIZE], rm[3], + char ir[ROOM_NAME_LEN + 1], text2[ARR_SIZE], text3[ARR_SIZE], rm[4], qcall[USER_NAME_LEN]; char email[82], nm[5], muzlev[20], arrlev[20]; UR_OBJECT u; diff --git a/src/includes/globals.h b/src/includes/globals.h index a6d1fea..3927f4a 100644 --- a/src/includes/globals.h +++ b/src/includes/globals.h @@ -607,7 +607,7 @@ const struct colour_codes_struct colour_codes[] = { /* * some general arrays being defined */ -const char *const noyes[] = { "NO", "YES" }; +const char *const noyes[] = { "NO", "YES" }; // 3 characters max const char *const offon[] = { "OFF", "ON" }; const char *const minmax[] = { "OFF", "MIN", "MAX" }; const char *const sex[] = { "Neuter", "Male", "Female" };