Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FcFontSetMatchInternal can go out of bounds for a bad priority if PRI_MAX gets broken #3

Open
Artoria2e5 opened this issue Feb 22, 2018 · 1 comment

Comments

@Artoria2e5
Copy link

Artoria2e5 commented Feb 22, 2018

In the current version:

static const FcMatcher _FcMatchers [] = {
    { FC_INVALID_OBJECT, NULL, NULL, -1, -1 },
#include "fcobjs.h"
};
/* ... */

// Find the matcher for given priority
const FcMatcher *matcher = NULL;
for (matcher = &_FcMatchers[0]; matcher->weak != priority && matcher->strong != priority; matcher++);
assert(matcher); // The assertion will do nothing as the loop will always set a nice value. 

With a bad priority the loop might just go on indefinitely since it doesn't check for an end. This generally won't happen unless someone made the priorities inconsistent with fcobj.h.

An extra check likely(matcher - _FcMatchers <= FC_MAX_BASE_OBJECT) can be added to catch this problem for debug builds.

@Artoria2e5 Artoria2e5 changed the title FcFontSetMatchInternal can go out of bounds for a bad priority FcFontSetMatchInternal can go out of bounds for a bad priority if someone breaks fcobj/pri_max Feb 22, 2018
@Artoria2e5 Artoria2e5 changed the title FcFontSetMatchInternal can go out of bounds for a bad priority if someone breaks fcobj/pri_max FcFontSetMatchInternal can go out of bounds for a bad priority if PRI_MAX gets broken Feb 22, 2018
@michalsrb
Copy link
Owner

The assumption is of course that the _FcMatchers and _FcMatcherPriority match together. As long as they do, no external input can break it. But a debug assert to catch mistakes during development would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants