From: Paul Eggert Date: Mon, 18 Apr 2011 23:32:38 +0000 (-0700) Subject: * frame.c (frame_name_fnn_p): Get rid of strtol, which isn't right X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~254 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5e073ec7384c432e42a8affeeb6d6906588f2af9;p=emacs.git * frame.c (frame_name_fnn_p): Get rid of strtol, which isn't right here, since it parses constructs like leading '-' and spaces, which are not wanted; and it overflows with large numbers. Instead, simply match F[0-9]+, which is what is wanted anyway. --- diff --git a/src/ChangeLog b/src/ChangeLog index 3ca41d7b51b..42c7d06168f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2011-04-18 Paul Eggert + * frame.c (frame_name_fnn_p): Get rid of strtol, which isn't right + here, since it parses constructs like leading '-' and spaces, + which are not wanted; and it overflows with large numbers. + Instead, simply match F[0-9]+, which is what is wanted anyway. + * alloc.c: Remove unportable assumptions about struct layout. (SDATA_SELECTOR, SDATA_DATA_OFFSET): New macros. (SDATA_OF_STRING, SDATA_SIZE, allocate_string_data): diff --git a/src/frame.c b/src/frame.c index 9024a2fb5e2..179ae4019dc 100644 --- a/src/frame.c +++ b/src/frame.c @@ -2154,18 +2154,15 @@ store_in_alist (Lisp_Object *alistptr, Lisp_Object prop, Lisp_Object val) static int frame_name_fnn_p (char *str, EMACS_INT len) { - if (len > 1 && str[0] == 'F') + if (len > 1 && str[0] == 'F' && '0' <= str[1] && str[1] <= '9') { - char *end_ptr; - long int n; - errno = 0; - n = strtol (str + 1, &end_ptr, 10); - - if (end_ptr == str + len - && INT_MIN <= n && n <= INT_MAX - && ((LONG_MIN < n && n < LONG_MAX) || errno != ERANGE)) + char *p = str + 2; + while ('0' <= *p && *p <= '9') + p++; + if (p == str + len) return 1; } + return 0; }