diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2011-01-22 23:32:08 -0800 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-01-22 23:32:08 -0800 |
| commit | 200034fcff6b5bd3274bf2e986133e0a7ae97a8d (patch) | |
| tree | 9fa3b1f4d5dac6e1ee7beb7b1d963b412820eb3b /src | |
| parent | 5c7d01a54e356f905e16bdb24f9a8bfc1d676d0e (diff) | |
| parent | 9055082ef8a2f1b9033f77f0eb2b9c756a306c01 (diff) | |
Merge: 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 06b9e313bd5..fbc1b2175b8 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; |
