Fossil SCM

Change the anonymous login cookie name to include a hash of the base URL. Ticket [3edef69bf3e995ed2]

drh 2010-11-06 13:52 UTC trunk
Commit 9dd6c43185d68d61cfd2a86e60fe189f48e24922
1 file changed +4 -5
+4 -5
--- src/login.c
+++ src/login.c
@@ -51,15 +51,14 @@
5151
** Return the name of the login cookie
5252
*/
5353
static char *login_cookie_name(void){
5454
static char *zCookieName = 0;
5555
if( zCookieName==0 ){
56
- int n = strlen(g.zTop);
57
- zCookieName = fossil_malloc( n*2+16 );
58
- /* 0123456789 12345 */
59
- strcpy(zCookieName, "fossil_login_");
60
- encode16((unsigned char*)g.zTop, (unsigned char*)&zCookieName[13], n);
56
+ unsigned int h = 0;
57
+ const char *z = g.zBaseURL;
58
+ while( *z ){ h = (h<<3) ^ (h>>26) ^ *(z++); }
59
+ zCookieName = mprintf("fossil_login_%08x", h);
6160
}
6261
return zCookieName;
6362
}
6463
6564
/*
6665
--- src/login.c
+++ src/login.c
@@ -51,15 +51,14 @@
51 ** Return the name of the login cookie
52 */
53 static char *login_cookie_name(void){
54 static char *zCookieName = 0;
55 if( zCookieName==0 ){
56 int n = strlen(g.zTop);
57 zCookieName = fossil_malloc( n*2+16 );
58 /* 0123456789 12345 */
59 strcpy(zCookieName, "fossil_login_");
60 encode16((unsigned char*)g.zTop, (unsigned char*)&zCookieName[13], n);
61 }
62 return zCookieName;
63 }
64
65 /*
66
--- src/login.c
+++ src/login.c
@@ -51,15 +51,14 @@
51 ** Return the name of the login cookie
52 */
53 static char *login_cookie_name(void){
54 static char *zCookieName = 0;
55 if( zCookieName==0 ){
56 unsigned int h = 0;
57 const char *z = g.zBaseURL;
58 while( *z ){ h = (h<<3) ^ (h>>26) ^ *(z++); }
59 zCookieName = mprintf("fossil_login_%08x", h);
 
60 }
61 return zCookieName;
62 }
63
64 /*
65

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button