summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-12-10 10:56:18 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-12-10 10:56:18 +0000
commit3d03fdbfe443cfea53a51def8275f200d4aa0617 (patch)
treec912d1de6d22f66df2e5439bffa478b910790a64
parentf4fad0c741636d017aefd76d58e271466696cc6f (diff)
downloadpango-3d03fdbfe443cfea53a51def8275f200d4aa0617.tar.gz
Bug 399573 – replace strtoul in pango-markup.c with pango_scan_int()
2007-12-10 Behdad Esfahbod <behdad@gnome.org> Bug 399573 – replace strtoul in pango-markup.c with pango_scan_int() * pango/pango-markup.c (span_parse_func): Use pango_scan_int() and improve error message on parse failure. svn path=/trunk/; revision=2520
-rw-r--r--ChangeLog7
-rw-r--r--pango/pango-markup.c17
2 files changed, 16 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index d17108ba..b7ad3b49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2007-12-10 Behdad Esfahbod <behdad@gnome.org>
+ Bug 399573 – replace strtoul in pango-markup.c with pango_scan_int()
+
+ * pango/pango-markup.c (span_parse_func): Use pango_scan_int() and
+ improve error message on parse failure.
+
+2007-12-10 Behdad Esfahbod <behdad@gnome.org>
+
Bug 478914 – Use something invalid instead of '?' when validating
input text
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index af337e17..abb3890a 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -1079,20 +1079,21 @@ span_parse_func (MarkupData *md,
{
if (g_ascii_isdigit (*size))
{
- char *end = NULL;
- gulong n;
+ const char *end;
+ gint n;
- n = strtoul (size, &end, 10);
+/* cap size from the top at an arbitrary 2048 */
+#define MAX_SIZE (2048 * PANGO_SCALE)
- if (*end != '\0' || n < 0 || n > 1000000)
+ if ((end = size, !pango_scan_int (&end, &n)) || *end != '\0' || n < 0 || n > MAX_SIZE)
{
g_set_error (error,
G_MARKUP_ERROR,
G_MARKUP_ERROR_INVALID_CONTENT,
- _("Value of 'size' attribute on <span> tag on line %d"
- "could not be parsed; should be an integer, or a "
+ _("Value of 'size' attribute on <span> tag on line %d "
+ "could not be parsed; should be an integer less than %d, or a "
"string such as 'small', not '%s'"),
- line_number, size);
+ line_number, MAX_SIZE+1, size);
goto error;
}
@@ -1123,7 +1124,7 @@ span_parse_func (MarkupData *md,
g_set_error (error,
G_MARKUP_ERROR,
G_MARKUP_ERROR_INVALID_CONTENT,
- _("Value of 'size' attribute on <span> tag on line %d"
+ _("Value of 'size' attribute on <span> tag on line %d "
"could not be parsed; should be an integer, or a "
"string such as 'small', not '%s'"),
line_number, size);