X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=a502ec49026cd1baab8dc85ac4f267a8a1cd68c6;hp=59a273e15b6607f5d771123bfec43ca98cfeb2a0;hb=4b1b5a2a67227d3023ff6da4596be31eae8eaefc;hpb=983b7bc7f3493b1522d08d8e7bdecb3bd8e462eb diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 59a273e1..a502ec49 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -337,26 +337,24 @@ static char *get_corrected_real_name(char *real_name) char *from_ptr = real_name; char *to_ptr = real_name_new; - if (strchr(real_name, 'ß') == NULL) /* name does not contain 'ß' */ - { - strncpy(real_name_new, real_name, MAX_USERNAME_LEN); - real_name_new[MAX_USERNAME_LEN] = '\0'; - - return real_name_new; - } - - /* the user's real name may contain a 'ß' character (german sharp s), - which has no equivalent in upper case letters (which our fonts use) */ + /* copy the name string, but not more than MAX_USERNAME_LEN characters */ while (*from_ptr && (long)(to_ptr - real_name_new) < MAX_USERNAME_LEN - 1) { - if (*from_ptr != 'ß') - *to_ptr++ = *from_ptr++; - else + /* the name field read from "passwd" file may also contain additional + user information, separated by commas, which will be removed here */ + if (*from_ptr == ',') + break; + + /* the user's real name may contain 'ß' characters (german sharp s), + which have no equivalent in upper case letters (used by our fonts) */ + if (*from_ptr == 'ß') { from_ptr++; *to_ptr++ = 's'; *to_ptr++ = 's'; } + else + *to_ptr++ = *from_ptr++; } *to_ptr = '\0';