aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-01-22 23:32:08 -0800
committerPaul Eggert2011-01-22 23:32:08 -0800
commit200034fcff6b5bd3274bf2e986133e0a7ae97a8d (patch)
tree9fa3b1f4d5dac6e1ee7beb7b1d963b412820eb3b /src
parent5c7d01a54e356f905e16bdb24f9a8bfc1d676d0e (diff)
parent9055082ef8a2f1b9033f77f0eb2b9c756a306c01 (diff)
downloademacs-200034fcff6b5bd3274bf2e986133e0a7ae97a8d.tar.gz
emacs-200034fcff6b5bd3274bf2e986133e0a7ae97a8d.zip
Merge: Check return values of some library calls.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/emacs.c3
-rw-r--r--src/frame.c11
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 @@
12011-01-23 Paul Eggert <eggert@cs.ucla.edu> 12011-01-23 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Check return values of some library calls.
4 * emacs.c (main): Check dup result.
5 * frame.c: Include <limits.h>, for INT_MIN and INT_MAX.
6 (frame_name_fnn_p): Check strtol result.
7
3 * image.c (x_create_bitmap_from_xpm_data): Add cast to fix type clash 8 * image.c (x_create_bitmap_from_xpm_data): Add cast to fix type clash
4 when calling XpmCreatePixmapFromData. 9 when calling XpmCreatePixmapFromData.
5 10
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)
912 emacs_close (0); 912 emacs_close (0);
913 emacs_close (1); 913 emacs_close (1);
914 result = emacs_open (term, O_RDWR, 0); 914 result = emacs_open (term, O_RDWR, 0);
915 if (result < 0) 915 if (result < 0 || dup (0) < 0)
916 { 916 {
917 char *errstring = strerror (errno); 917 char *errstring = strerror (errno);
918 fprintf (stderr, "%s: %s: %s\n", argv[0], term, errstring); 918 fprintf (stderr, "%s: %s: %s\n", argv[0], term, errstring);
919 exit (1); 919 exit (1);
920 } 920 }
921 dup (0);
922 if (! isatty (0)) 921 if (! isatty (0))
923 { 922 {
924 fprintf (stderr, "%s: %s: not a tty\n", argv[0], term); 923 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/>. */
23 23
24#include <stdio.h> 24#include <stdio.h>
25#include <ctype.h> 25#include <ctype.h>
26#include <errno.h>
27#include <limits.h>
26#include <setjmp.h> 28#include <setjmp.h>
27#include "lisp.h" 29#include "lisp.h"
28#include "character.h" 30#include "character.h"
@@ -2149,10 +2151,13 @@ frame_name_fnn_p (char *str, EMACS_INT len)
2149 if (len > 1 && str[0] == 'F') 2151 if (len > 1 && str[0] == 'F')
2150 { 2152 {
2151 char *end_ptr; 2153 char *end_ptr;
2154 long int n;
2155 errno = 0;
2156 n = strtol (str + 1, &end_ptr, 10);
2152 2157
2153 strtol (str + 1, &end_ptr, 10); 2158 if (end_ptr == str + len
2154 2159 && INT_MIN <= n && n <= INT_MAX
2155 if (end_ptr == str + len) 2160 && ((LONG_MIN < n && n < LONG_MAX) || errno != ERANGE))
2156 return 1; 2161 return 1;
2157 } 2162 }
2158 return 0; 2163 return 0;