Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fix rcon_crypt for any size of time_t #112

Open
VVD opened this issue Jan 1, 2023 · 0 comments
Open

BUG: fix rcon_crypt for any size of time_t #112

VVD opened this issue Jan 1, 2023 · 0 comments

Comments

@VVD
Copy link

VVD commented Jan 1, 2023

diff --git a/src/common.h b/src/common.h
index 0bece51..a5999d0 100644
--- a/src/common.h
+++ b/src/common.h
@@ -231,4 +231,6 @@ qbool COM_FileExists(char *path);
 // Name comparison: case insensitive, red/white text insensitive
 int Q_namecmp(const char* s1, const char* s2);
 
+#define TIME_T_SIZE    8
+
 #endif /* !__COMMON_H__ */
diff --git a/src/sv_main.c b/src/sv_main.c
index 9629d9d..50091d5 100644
--- a/src/sv_main.c
+++ b/src/sv_main.c
@@ -1543,7 +1543,7 @@ int Rcon_Validate (char *client_string, char *password1)
                const char* digest = Cmd_Argv(1);
                const char* time_start = Cmd_Argv(1) + DIGEST_SIZE * 2;
 
-               if (strlen(digest) < DIGEST_SIZE * 2 + sizeof(time_t) * 2) {
+               if (strlen(digest) < DIGEST_SIZE * 2 + TIME_T_SIZE * 2) {
                        return 0;
                }
 
@@ -1552,9 +1552,9 @@ int Rcon_Validate (char *client_string, char *password1)
                        double difftime_server_client;
 
                        time(&server_time);
-                       for (i = 0; i < sizeof(client_time) * 2; i += 2) {
-                               client_time += (char2int((unsigned char)time_start[i]) << (4 + i * 4)) +
-                                              (char2int((unsigned char)time_start[i + 1]) << (i * 4));
+                       for (i = 0; i < TIME_T_SIZE * 2; i += 2) {
+                               client_time += ((time_t)char2int((unsigned char)time_start[i]) << (4 + i * 4)) +
+                                              ((time_t)char2int((unsigned char)time_start[i + 1]) << (i * 4));
                        }
                        difftime_server_client = difftime(server_time, client_time);
 

More information are here:
QW-Group/ezquake-source#719
QW-Group/ezquake-source#726

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant