Changeset 4184 for trunk/console

Show
Ignore:
Timestamp:
08/13/05 10:32:14 (3 years ago)
Author:
phatfil
Message:

fix a couple of crashes (viewing history, last user) when user aliases were > 32 chars

Location:
trunk/console/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/console/src/console.cpp

    r4175 r4184  
    17691769    return; 
    17701770  } 
    1771   char szFrom[32]; 
     1771  char *szFrom; 
    17721772  if (gUserManager.FindOwner(szId, nPPID)) 
    1773     strcpy(szFrom, "Server"); 
     1773    szFrom = "Server\0"; 
    17741774  else 
    1775     strcpy(szFrom, u->GetAlias()); 
     1775    szFrom = strdup(u->GetAlias()); 
    17761776  gUserManager.DropUser(u); 
    17771777 
     
    17911791      winMain->wprintf("%CNo System Events.\n", 8); 
    17921792    } 
     1793    free(szFrom); 
    17931794    return; 
    17941795  } 
     
    18071808    winMain->wprintf("%CInvalid start range: %A%s\n", 16, 
    18081809                     A_BOLD, szStart); 
     1810    free(szFrom); 
    18091811    return; 
    18101812  } 
     
    18131815    winMain->wprintf("%CStart value out of range, history contains %d events.\n", 
    18141816                     16, nLast); 
     1817    free(szFrom); 
    18151818    return; 
    18161819  } 
     
    18231826      winMain->wprintf("%CInvalid end range: %A%s\n", 16, 
    18241827                       A_BOLD, szEnd); 
     1828      free(szFrom); 
    18251829      return; 
    18261830    } 
     
    18291833      winMain->wprintf("%CEnd value out of range, history contains %d events.\n", 
    18301834                       16, nLast); 
     1835      free(szFrom); 
    18311836      return; 
    18321837    } 
     
    18391844  winMain->nLastHistory = nEnd; 
    18401845  PrintHistory(lHistory, nStart - 1, nEnd - 1, szFrom); 
     1846  free(szFrom); 
    18411847} 
    18421848 
  • trunk/console/src/console_print.cpp

    r4023 r4184  
    126126{ 
    127127  static char szMsgStr[16]; 
    128   static char szLastUser[32]; 
     128  static char *szLastUser; 
    129129 
    130130  werase(winStatus->Win()); 
     
    151151      winMain->sLastContact.nPPID, LOCK_R); 
    152152    if (u == NULL) 
    153       strcpy(szLastUser, "<Removed>"); 
     153      szLastUser = "<Removed>\0"; 
    154154    else 
    155155    { 
    156       strcpy(szLastUser, u->GetAlias()); 
     156      szLastUser = strdup(u->GetAlias()); 
    157157      gUserManager.DropUser(u); 
    158158    } 
    159159  } 
    160160  else 
    161     strcpy(szLastUser, "<None>"); 
     161    szLastUser = "<None>\0"; 
    162162 
    163163  o = gUserManager.FetchOwner(LOCK_R);