mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 06:32:10 +01:00
Fix bug in strinfo
We can't search for a larger needle inside of a smaller haystack, and unsigned integer subtraction tends to result in very large numbers rather than small ones. Add a check for this case and abort out immediately. Also add a test case (lifted directly from the docs) that demonstrates the problem. Issue discovered and tracked down by Milan Bouchet-Valat
This commit is contained in:
parent
e91541bf8c
commit
a768953760
@ -147,6 +147,9 @@ strinfo_scan (const guint32 *strinfo,
|
||||
{
|
||||
guint i = 0;
|
||||
|
||||
if (length < n_words)
|
||||
return -1;
|
||||
|
||||
while (i <= length - n_words)
|
||||
{
|
||||
guint j = 0;
|
||||
|
@ -91,7 +91,8 @@ static const SchemaTest tests[] = {
|
||||
{ "range-high-default", NULL, "*<default> is not contained in the specified range*" },
|
||||
{ "range-default-low", NULL, "*<default> is not contained in the specified range*" },
|
||||
{ "range-default-high", NULL, "*<default> is not contained in the specified range*" },
|
||||
{ "range-parse-error", NULL, "*invalid character in number*" }
|
||||
{ "range-parse-error", NULL, "*invalid character in number*" },
|
||||
{ "from-docs", NULL, NULL }
|
||||
};
|
||||
|
||||
int
|
||||
|
34
gio/tests/schema-tests/from-docs.gschema.xml
Normal file
34
gio/tests/schema-tests/from-docs.gschema.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<schemalist>
|
||||
<!-- from the GSettings docs. Should work, I guess :) -->
|
||||
|
||||
<enum id="myenum">
|
||||
<value nick="first" value="1"/>
|
||||
<value nick="second" value="2"/>
|
||||
</enum>
|
||||
|
||||
<schema id="org.gtk.test">
|
||||
|
||||
<key name="key-with-range" type="i">
|
||||
<range min="1" max="100"/>
|
||||
<default>10</default>
|
||||
</key>
|
||||
|
||||
<key name="key-with-choices" type="s">
|
||||
<choices>
|
||||
<choice value='Elisabeth'/>
|
||||
<choice value='Annabeth'/>
|
||||
<choice value='Joe'/>
|
||||
</choices>
|
||||
<aliases>
|
||||
<alias value='Anna' target='Annabeth'/>
|
||||
<alias value='Beth' target='Elisabeth'/>
|
||||
</aliases>
|
||||
<default>'Joe'</default>
|
||||
</key>
|
||||
|
||||
<key name='enumerated-key' enum='myenum'>
|
||||
<default>'first'</default>
|
||||
</key>
|
||||
|
||||
</schema>
|
||||
</schemalist>
|
Loading…
x
Reference in New Issue
Block a user