[Fontconfig] robustness of the mmap cache branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think FcGlobalCacheLoad() needs some robustness love. Just
copy any text file to ~/.fonts.cache-2 and watch FcGlobalCacheLoad()
go in an infinite loop:

    while (1) 
    {
	FcCacheReadString (cache->fd, name_buf, sizeof (name_buf));

	if (!strlen(name_buf))
	    break;

	d = malloc (sizeof (FcGlobalCacheDir));
	if (!d)
	    goto bail1;

	d->next = cache->dirs;
	cache->dirs = d;

	d->name = FcStrCopy (name_buf);
	d->ent = 0;
	d->offset = lseek (cache->fd, 0, SEEK_CUR);
	read (cache->fd, &d->metadata, sizeof (FcCache));
	lseek (cache->fd, d->metadata.count, SEEK_CUR);
    }

I have no concrete proposal for how to rework this, but at the very
least, the return values of read() and lseek() should be checked to
handle errors.


Regards, Matthias



[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux