1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 02:33:02 +01:00

core: Fix a possible buffer overflow using getself_name().

If the passed buffer is smaller than MAX_NAME_LENGTH then, you
will probably overflow it.
This commit is contained in:
Andreas Schneider 2013-08-11 15:24:47 +02:00
parent b5a4cac6e1
commit 98ecf06b4c

2
chat.c
View File

@ -210,7 +210,7 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd, struct
wattroff(ctx->history, COLOR_PAIR(2)); wattroff(ctx->history, COLOR_PAIR(2));
uint8_t selfname[MAX_NAME_LENGTH]; uint8_t selfname[MAX_NAME_LENGTH];
int len = getself_name(m, selfname); int len = getself_name(m, selfname, sizeof(selfname));
char msg[MAX_STR_SIZE-len-4]; char msg[MAX_STR_SIZE-len-4];
snprintf(msg, sizeof(msg), "* %s %s\n", (uint8_t*) selfname, action); snprintf(msg, sizeof(msg), "* %s %s\n", (uint8_t*) selfname, action);