From b5b8c9e5d3c14ad3510af9edb2d693f312eecf53 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 19 Jun 2011 20:21:35 -0700 Subject: [PATCH] * font.c: Don't assume string length fits in int. (font_parse_xlfd, font_parse_fcname, font_unparse_fcname): Use ptrdiff_t, not int. --- src/ChangeLog | 4 ++++ src/font.c | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index fd17f85f1e1..32756b4427f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2011-06-20 Paul Eggert + * font.c: Don't assume string length fits in int. + (font_parse_xlfd, font_parse_fcname, font_unparse_fcname): + Use ptrdiff_t, not int. + * filelock.c: Fix some buffer overrun and integer overflow issues. (get_boot_time): Don't assume that gzip command string fits in 100 bytes. Reformulate so as not to need the command string. diff --git a/src/font.c b/src/font.c index 4619ed68913..b9cdde376a5 100644 --- a/src/font.c +++ b/src/font.c @@ -982,7 +982,7 @@ font_expand_wildcards (Lisp_Object *field, int n) int font_parse_xlfd (char *name, Lisp_Object font) { - int len = strlen (name); + ptrdiff_t len = strlen (name); int i, j, n; char *f[XLFD_LAST_INDEX + 1]; Lisp_Object val; @@ -1310,7 +1310,7 @@ font_parse_fcname (char *name, Lisp_Object font) char *p, *q; char *size_beg = NULL, *size_end = NULL; char *props_beg = NULL, *family_end = NULL; - int len = strlen (name); + ptrdiff_t len = strlen (name); if (len == 0) return -1; @@ -1376,7 +1376,7 @@ font_parse_fcname (char *name, Lisp_Object font) if (*q != '=') { /* Must be an enumerated value. */ - int word_len; + ptrdiff_t word_len; p = p + 1; word_len = q - p; val = font_intern_prop (p, q - p, 1); @@ -1452,7 +1452,7 @@ font_parse_fcname (char *name, Lisp_Object font) Lisp_Object weight = Qnil, slant = Qnil; Lisp_Object width = Qnil, size = Qnil; char *word_start; - int word_len; + ptrdiff_t word_len; /* Scan backwards from the end, looking for a size. */ for (p = name + len - 1; p >= name; p--) @@ -1542,7 +1542,8 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes) Lisp_Object family, foundry; Lisp_Object tail, val; int point_size; - int i, len = 1; + int i; + ptrdiff_t len = 1; char *p; Lisp_Object styles[3]; const char *style_names[3] = { "weight", "slant", "width" }; -- 2.39.2