Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 265792 | Differences between
and this patch

Collapse All | Expand All

(-)src/lib/utils.h (-1 / +1 lines)
Lines 9-15 Link Here
9
#include <windows.h>
9
#include <windows.h>
10
#endif
10
#endif
11
11
12
#ifdef ARM
12
#if defined(ARM) || defined(__sparc__)
13
static inline guint32 get_uint32(const gchar *addr)
13
static inline guint32 get_uint32(const gchar *addr)
14
{
14
{
15
	guint32 result;
15
	guint32 result;
(-)src/lib/stddict.cpp (-6 / +17 lines)
Lines 310-317 Link Here
310
	std::auto_ptr<MapFile> mf(new MapFile);
310
	std::auto_ptr<MapFile> mf(new MapFile);
311
	if (!mf->open(filename, cachestat.st_size))
311
	if (!mf->open(filename, cachestat.st_size))
312
		return NULL;
312
		return NULL;
313
313
	guint32  word_off_size = (get_uint32(mf->begin()) + 1) * sizeof(guint32);
314
	gchar *p = mf->begin();
314
	if (word_off_size >= cachestat.st_size ||
315
	    *(mf->begin() + cachestat.st_size - 1) != '\0')
316
		return NULL;
317
	
318
	gchar *p = mf->begin() + word_off_size;
315
	gboolean has_prefix;
319
	gboolean has_prefix;
316
	if (cachefiletype == CacheFileType_oft)
320
	if (cachefiletype == CacheFileType_oft)
317
		has_prefix = g_str_has_prefix(p, OFFSETFILE_MAGIC_DATA);
321
		has_prefix = g_str_has_prefix(p, OFFSETFILE_MAGIC_DATA);
Lines 346-352 Link Here
346
			if (atoi(tmpstr.c_str())!=cltfunc)
350
			if (atoi(tmpstr.c_str())!=cltfunc)
347
				return NULL;
351
				return NULL;
348
		}
352
		}
349
		if (cachestat.st_size!=glong(filedatasize + strlen(mf->begin()) +1))
353
		if (cachestat.st_size != static_cast<gulong>(filedatasize + sizeof(guint32) + strlen(mf->begin() + word_off_size) +1))
350
			return NULL;
354
			return NULL;
351
		struct stat idxstat;
355
		struct stat idxstat;
352
		if (g_stat(url.c_str(), &idxstat)!=0)
356
		if (g_stat(url.c_str(), &idxstat)!=0)
Lines 385-391 Link Here
385
		mf = get_cache_for_load(oftfilename.c_str(), url, saveurl, cltfunc, filedatasize, 2);
389
		mf = get_cache_for_load(oftfilename.c_str(), url, saveurl, cltfunc, filedatasize, 2);
386
		if (!mf)
390
		if (!mf)
387
			continue;
391
			continue;
388
		wordoffset = (guint32 *)(mf->begin()+strlen(mf->begin())+1);
392
		wordoffset = reinterpret_cast<guint32 *>(mf->begin()) + 1;
389
		return true;
393
		return true;
390
	}
394
	}
391
	return false;
395
	return false;
Lines 427-433 Link Here
427
	if (!mf.open(filename, oftstat.st_size)) {
431
	if (!mf.open(filename, oftstat.st_size)) {
428
		return fopen(filename, "wb");
432
		return fopen(filename, "wb");
429
	}
433
	}
430
	gchar *p = mf.begin();
434
	guint32  word_off_size = (get_uint32(mf.begin()) + 1) * sizeof(guint32);
435
	if (word_off_size >= oftstat.st_size ||
436
	    *(mf.begin() + oftstat.st_size - 1) != '\0')
437
		return fopen(filename, "wb");
438
439
	gchar *p = mf.begin() + word_off_size;
431
	bool has_prefix;
440
	bool has_prefix;
432
	if (cachefiletype == CacheFileType_oft)
441
	if (cachefiletype == CacheFileType_oft)
433
		has_prefix = g_str_has_prefix(p, OFFSETFILE_MAGIC_DATA);
442
		has_prefix = g_str_has_prefix(p, OFFSETFILE_MAGIC_DATA);
Lines 481-486 Link Here
481
		FILE *out= get_cache_for_save(oftfilename.c_str(), saveurl, 2, cfilename, cltfunc);
490
		FILE *out= get_cache_for_save(oftfilename.c_str(), saveurl, 2, cfilename, cltfunc);
482
		if (!out)
491
		if (!out)
483
			continue;
492
			continue;
493
		guint32 nentries = npages;
494
		fwrite(&nentries, sizeof(nentries), 1, out);
495
		fwrite(wordoffset, sizeof(guint32), npages, out);
484
		if (cachefiletype == CacheFileType_oft)
496
		if (cachefiletype == CacheFileType_oft)
485
			fwrite(OFFSETFILE_MAGIC_DATA, 1, sizeof(OFFSETFILE_MAGIC_DATA)-1, out);
497
			fwrite(OFFSETFILE_MAGIC_DATA, 1, sizeof(OFFSETFILE_MAGIC_DATA)-1, out);
486
		else
498
		else
Lines 495-501 Link Here
495
#endif
507
#endif
496
		}
508
		}
497
		fwrite("\n", 1, 2, out);
509
		fwrite("\n", 1, 2, out);
498
		fwrite(wordoffset, sizeof(guint32), npages, out);
499
		fclose(out);
510
		fclose(out);
500
		g_print("Save cache file: %s\n", cfilename.c_str());
511
		g_print("Save cache file: %s\n", cfilename.c_str());
501
		return true;
512
		return true;

Return to bug 265792