r4309 - branches/2.0/varnish-cache/bin/varnishd
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Thu Oct 8 16:34:44 CEST 2009
Author: tfheen
Date: 2009-10-08 16:34:44 +0200 (Thu, 08 Oct 2009)
New Revision: 4309
Modified:
branches/2.0/varnish-cache/bin/varnishd/shmlog.c
Log:
Merge r4200: Be more paranoid about shmlog magics,
Don't explode manager if it gets overwritten.
Modified: branches/2.0/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/shmlog.c 2009-10-08 14:29:34 UTC (rev 4308)
+++ branches/2.0/varnish-cache/bin/varnishd/shmlog.c 2009-10-08 14:34:44 UTC (rev 4309)
@@ -71,16 +71,19 @@
vsl_wrap(void)
{
+ assert(loghead->magic == SHMLOGHEAD_MAGIC);
*logstart = SLT_ENDMARKER;
logstart[loghead->ptr] = SLT_WRAPMARKER;
loghead->ptr = 0;
VSL_stats->shm_cycles++;
+ assert(loghead->magic == SHMLOGHEAD_MAGIC);
}
static void
vsl_hdr(enum shmlogtag tag, unsigned char *p, unsigned len, unsigned id)
{
+ assert(loghead->magic == SHMLOGHEAD_MAGIC);
assert(len < 0x10000);
assert(id < 0x10000);
p[__SHMLOG_LEN_HIGH] = (len >> 8) & 0xff;
@@ -280,13 +283,18 @@
void
VSL_Panic(int *len, char **ptr)
{
+ static char a[1] = { '\0' };
AN(len);
AN(ptr);
- assert(loghead->magic == SHMLOGHEAD_MAGIC);
- assert(loghead->hdrsize == sizeof *loghead);
- *len = sizeof(loghead->panicstr);
- *ptr = loghead->panicstr;
+ if (loghead->magic == SHMLOGHEAD_MAGIC) {
+ assert(loghead->hdrsize == sizeof *loghead);
+ *len = sizeof(loghead->panicstr);
+ *ptr = loghead->panicstr;
+ } else {
+ *len = 0;
+ *ptr = a;
+ }
}
/*--------------------------------------------------------------------*/
More information about the varnish-commit
mailing list