| 458 | } |
| 459 | |
| 460 | char *MSG_ReadString( msg_t *msg ) { |
| 461 | static char string[MAX_STRING_CHARS]; |
| 462 | int c; |
| 463 | unsigned int l; |
| 464 | |
| 465 | l = 0; |
| 466 | do { |
| 467 | c = MSG_ReadByte(msg); // use ReadByte so -1 is out of bounds |
| 468 | if ( c == -1 || c == 0 ) { |
| 469 | break; |
| 470 | } |
| 471 | // translate all fmt spec to avoid crash bugs |
| 472 | if ( c == '%' ) { |
| 473 | c = '.'; |
| 474 | } |
| 475 | // eurofix: remove this so we can chat in european languages... -ste |
| 476 | // |
| 477 | // // don't allow higher ascii values |
| 478 | // if ( c > 127 ) { |
| 479 | // c = '.'; |
| 480 | // } |
| 481 | |
| 482 | string[l] = c; |
| 483 | l++; |
| 484 | } while (l <= sizeof(string)-1); |
| 485 | |
| 486 | // some bonus protection, shouldn't occur cause server doesn't write such things |
| 487 | if (l <= sizeof(string)-1) |
| 488 | { |
| 489 | string[l] = 0; |
| 490 | } |
| 491 | else |
| 492 | { |
| 493 | string[sizeof(string)-1] = 0; |
| 494 | } |
| 495 | |
| 496 | return string; |
| 497 | } |
| 498 | |
| 499 | char *MSG_ReadBigString( msg_t *msg ) { |
| 500 | static char string[BIG_INFO_STRING]; |
no test coverage detected