diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2011-01-22 23:30:19 -0800 | 
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-01-22 23:30:19 -0800 | 
| commit | 9055082ef8a2f1b9033f77f0eb2b9c756a306c01 (patch) | |
| tree | 041665ff66c2bdab89f2f59976fb9ce0e2003ab0 /src | |
| parent | f77fabaf6bc1296631b1a4bcdf363721e19a3ac4 (diff) | |
| download | emacs-9055082ef8a2f1b9033f77f0eb2b9c756a306c01.tar.gz | |
Check return values of some library calls.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/emacs.c | 3 | ||||
| -rw-r--r-- | src/frame.c | 11 | 
3 files changed, 14 insertions, 5 deletions
| diff --git a/src/ChangeLog b/src/ChangeLog index 2e9e80d938d..c717b3fe3ee 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@  2011-01-23  Paul Eggert  <eggert@cs.ucla.edu> +	Check return values of some library calls. +	* emacs.c (main): Check dup result. +	* frame.c: Include <limits.h>, for INT_MIN and INT_MAX. +	(frame_name_fnn_p): Check strtol result. +  	* image.c (x_create_bitmap_from_xpm_data): Add cast to fix type	clash  	when calling XpmCreatePixmapFromData. diff --git a/src/emacs.c b/src/emacs.c index 70dd76d3a3b..9e9989ebbc6 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -912,13 +912,12 @@ main (int argc, char **argv)  	  emacs_close (0);  	  emacs_close (1);  	  result = emacs_open (term, O_RDWR, 0); -	  if (result < 0) +	  if (result < 0 || dup (0) < 0)  	    {  	      char *errstring = strerror (errno);  	      fprintf (stderr, "%s: %s: %s\n", argv[0], term, errstring);  	      exit (1);  	    } -	  dup (0);  	  if (! isatty (0))  	    {  	      fprintf (stderr, "%s: %s: not a tty\n", argv[0], term); diff --git a/src/frame.c b/src/frame.c index 5cbdcf15abf..e663538a840 100644 --- a/src/frame.c +++ b/src/frame.c @@ -23,6 +23,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */  #include <stdio.h>  #include <ctype.h> +#include <errno.h> +#include <limits.h>  #include <setjmp.h>  #include "lisp.h"  #include "character.h" @@ -2149,10 +2151,13 @@ frame_name_fnn_p (char *str, EMACS_INT len)    if (len > 1 && str[0] == 'F')      {        char *end_ptr; +      long int n; +      errno = 0; +      n = strtol (str + 1, &end_ptr, 10); -      strtol (str + 1, &end_ptr, 10); - -      if (end_ptr == str + len) +      if (end_ptr == str + len +	  && INT_MIN <= n && n <= INT_MAX +	  && ((LONG_MIN < n && n < LONG_MAX) || errno != ERANGE))  	return 1;      }    return 0; | 
