diff options
| author | John Wiseman <john.wiseman@cantab.net> | 2023-01-25 10:12:51 +0000 |
|---|---|---|
| committer | John Wiseman <john.wiseman@cantab.net> | 2023-01-25 10:12:51 +0000 |
| commit | c15de2c7f7e70c97a89b591b3ece72c5047ab4fa (patch) | |
| tree | 576b57d456bea59c60d265149e7969769bb6b015 /HanksRT.c | |
| parent | 9a44d00480888cb11c614034489cc048d798f40f (diff) | |
6.0.23.4223.46
Diffstat (limited to 'HanksRT.c')
| -rw-r--r-- | HanksRT.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -130,7 +130,7 @@ int AddtoHistory(struct user_t * user, char * text) struct HistoryRec * Rec;
struct HistoryRec * ptr;
int n = 1;
- char buf[512];
+ char buf[2048];
char Stamp[16];
struct tm * tm;
time_t Now = time(NULL);
@@ -150,6 +150,9 @@ int AddtoHistory(struct user_t * user, char * text) tm = gmtime(&Now);
+ if (strlen(text) + strlen(user->name) + strlen(user->call) > 2000)
+ return 0; // Shouldn't be that long, but protect buffer
+
sprintf(Stamp,"%02d:%02d ", tm->tm_hour, tm->tm_min);
sprintf(buf, "%s%-6.6s %s %c %s\r", Stamp, user->call, user->name, ':', text);
@@ -290,11 +293,11 @@ VOID __cdecl nprintf(ChatCIRCUIT * conn, const char * format, ...) {
// seems to be printf to a socket
- char buff[600];
+ char buff[65536];
va_list(arglist);
va_start(arglist, format);
- vsprintf(buff, format, arglist);
+ vsnprintf(buff, sizeof(buff), format, arglist);
nputs(conn, buff);
}
@@ -517,6 +520,11 @@ VOID ProcessChatLine(ChatCIRCUIT * conn, struct UserInfo * user, char* OrigBuffe WCHAR BufferW[65536];
UCHAR BufferB[65536];
+ // Sanity Check
+
+ if (len > 32768)
+ return;
+
// Convert to UTF8 if not already in UTF-8
if (len == 73 && memcmp(&OrigBuffer[40], " ", 20) == 0)
|
