Skip to content

Commit

Permalink
Adjust buffer size properly
Browse files Browse the repository at this point in the history
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;
  • Loading branch information
marado committed Feb 26, 2015
1 parent 14de087 commit 0698106
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/amnuts230.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/includes/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" };
Expand Down

0 comments on commit 0698106

Please sign in to comment.