Bug 399573 – replace strtoul in pango-markup.c with pango_scan_int()
authorBehdad Esfahbod <behdad@gnome.org>
Mon, 10 Dec 2007 10:56:18 +0000 (10:56 +0000)
committerBehdad Esfahbod <behdad@src.gnome.org>
Mon, 10 Dec 2007 10:56:18 +0000 (10:56 +0000)
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

ChangeLog
pango/pango-markup.c

index d17108b..b7ad3b4 100644 (file)
--- 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
 
index af337e1..abb3890 100644 (file)
@@ -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);