l0dable/invaders.c: fix potential buffer overflow

This commit is contained in:
Hagen Fritsch 2011-08-11 12:05:03 +02:00 committed by Stefan `Sec` Zehl
parent 77fb7a388a
commit 87b1b9e2cf
1 changed files with 5 additions and 3 deletions

View File

@ -178,9 +178,11 @@ static bool highscore_set(uint32_t score, char nick[]) {
static uint32_t highscore_get(char nick[]){ static uint32_t highscore_get(char nick[]){
MPKT * mpkt= meshGetMessage('i'); MPKT * mpkt= meshGetMessage('i');
char * packet_nick = (char*)MO_BODY(mpkt->pkt);
strcpy(nick,(char*)MO_BODY(mpkt->pkt)); // the packet crc end is already zeroed
if(MAXNICK<MESHPKTSIZE-2-6-1)
packet_nick[MAXNICK-1] = 0;
strcpy(nick, packet_nick);
return MO_TIME(mpkt->pkt); return MO_TIME(mpkt->pkt);
} }