View | Details | Raw Unified | Return to bug 26463
Collapse All | Expand All

(-)a/hdrcache.c (-1 / +13 lines)
Lines 95-100 int make_key(const char *path, const struct stat *st, char *key) Link Here
95
static
95
static
96
const int hdrsize_max = (256 << 10);
96
const int hdrsize_max = (256 << 10);
97
97
98
static
99
unsigned hash(const unsigned char *blob, int size)
100
{
101
    unsigned h = 5381;
102
    while (size-- > 0)
103
	h = h * 33 + *blob++;
104
    return h;
105
}
106
98
Header hdrcache_get(const char *path, const struct stat *st, unsigned *off)
107
Header hdrcache_get(const char *path, const struct stat *st, unsigned *off)
99
{
108
{
100
    if (initialize() < 0)
109
    if (initialize() < 0)
Lines 117-125 Header hdrcache_get(const char *path, const struct stat *st, unsigned *off) Link Here
117
	mcdb_put(env, key, keysize, data, datasize);
126
	mcdb_put(env, key, keysize, data, datasize);
118
    }
127
    }
119
    void *blob = data->blob;
128
    void *blob = data->blob;
129
    int blobsize = datasize - sizeof(struct cache_ent) + 1;
120
    char ublob[hdrsize_max];
130
    char ublob[hdrsize_max];
121
    if (data->vflags & V_LZO) {
131
    if (data->vflags & V_LZO) {
122
	int blobsize = datasize - sizeof(struct cache_ent) + 1;
123
	lzo_uint ublobsize = 0;
132
	lzo_uint ublobsize = 0;
124
	int rc = lzo1x_decompress(blob, blobsize, ublob, &ublobsize, NULL);
133
	int rc = lzo1x_decompress(blob, blobsize, ublob, &ublobsize, NULL);
125
	if (rc != LZO_E_OK || ublobsize < 1 || ublobsize > hdrsize_max) {
134
	if (rc != LZO_E_OK || ublobsize < 1 || ublobsize > hdrsize_max) {
Lines 127-134 Header hdrcache_get(const char *path, const struct stat *st, unsigned *off) Link Here
127
	    return NULL;
136
	    return NULL;
128
	}
137
	}
129
	blob = ublob;
138
	blob = ublob;
139
	blobsize = ublobsize;
130
    }
140
    }
141
    fprintf(stderr, "blob %x (%d) hash 1: %x\n", *(unsigned *) blob, blobsize, hash(blob, blobsize));
131
    Header h = headerLoad(blob);
142
    Header h = headerLoad(blob);
143
    fprintf(stderr, "blob %x (%d) hash 2: %x\n", *(unsigned *) blob, blobsize, hash(blob, blobsize));
132
    if (h == NULL) {
144
    if (h == NULL) {
133
	fprintf(stderr, "%s %s: headerLoad failed\n", __func__, key);
145
	fprintf(stderr, "%s %s: headerLoad failed\n", __func__, key);
134
	return NULL;
146
	return NULL;

Return to bug 26463