[Haiku-commits] r31195 - haiku/trunk/src/bin/keymap

Marcus Overhagen marcusoverhagen at arcor.de
Tue Jun 23 13:39:53 CEST 2009


axeld at BerliOS <axeld at mail.berlios.de> wrote:

As the message was
> [... truncated: 1088 lines follow ...]
I'm referring to the removed code that just seems to have moved.

> -void
> -Keymap::GetKey(char *chars, int32 offset, char* string) 
> -{
shouldn't chars be const?

> -	int size = chars[offset++];
There is no bounds checking on size, it could be -127 to 128

> -	char str[32];
This local variable is probably not needed.

> -	memset(str, 0, 32);
There is no need to memset the string

> -	memset(string, 0, 32);
And this could be harmfull when the input buffer is too short


> -	switch (size) {
> -		case 0:
> -			// Not mapped 
> -			sprintf(str, "''");
> -			break; 
strcpy would be fine

> -	strncpy(string, str, strlen(str) < 12 ? strlen(str) : 12);
> -		// TODO: Huh?
well, why is the length copied here limited here to 12, when 32 bytes
of string were memset earlier, and whats the intermediate str good for anyway?


regards
Marcus

Jetzt klicken und gucken! Das Arcor.de Fotoalbum mit tausenden von öffentlich einsehbaren Privatfotos!
Wir empfehlen die Kategorie Singles!
http://www.arcor.de/rd/palb



More information about the Haiku-commits mailing list