summaryrefslogtreecommitdiff
path: root/games/crossfire-client/files/patch-ag
blob: 6b36400a06c9a2c3d2898952a935eaf64f15a8ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--- server/main.c.orig	Sun Jan  5 19:59:27 1997
+++ server/main.c	Wed Sep 17 15:34:40 1997
@@ -139,6 +139,36 @@
   }
 }
 
+#if defined(__FreeBSD__)
+static unsigned char itoa64[] =
+    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
+
+static void
+to64(char *s, long v, int n)
+{
+	while (--n >= 0) {
+		*s++ = itoa64[v&0x3f];
+		v >>= 6;
+	}
+}
+
+char *
+crypt_string(char *str, char *salt)
+{
+	char	s[10];
+	if (salt==NULL) {
+		struct timeval	tv;
+		gettimeofday(&tv,0);
+		to64(&s[0], random(), 3);
+		to64(&s[3], tv.tv_usec, 3);
+		to64(&s[6], tv.tv_sec, 2);
+		s[8] = '\0';
+		salt = s;
+	}
+	return (crypt(str, salt));
+}
+#else
+
 char *crypt_string(char *str, char *salt) {
   static char *c=
     "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
@@ -151,6 +181,7 @@
     s[1]= salt[1];
   return crypt(str,s);
 }
+#endif
 
 int check_password(char *typed,char *crypted) {
   return !strcmp(crypt_string(typed,crypted),crypted);