aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert2013-08-23 19:23:34 -0700
committerPaul Eggert2013-08-23 19:23:34 -0700
commit9c05bccfb9cd29ab66b5c46643467671315a0f29 (patch)
tree575a7eadf45f2a93f5eb3d56b2ce6c0ef9f92279 /src/process.c
parent2d85dc347ccdffc32d3dd6fa163ea94a860540de (diff)
downloademacs-9c05bccfb9cd29ab66b5c46643467671315a0f29.tar.gz
emacs-9c05bccfb9cd29ab66b5c46643467671315a0f29.zip
System-dependent integer overflow fixes.
* process.c (Fset_process_window_size): Signal an error if the window size is outside the range supported by the lower level. * sysdep.c (set_window_size): Return negative on error, nonnegative on success, rather than -1, 0, 1 on not in system, failure, success. This is simpler. Caller changed. (serial_configure): Remove unnecessary initialization of local. (procfs_get_total_memory) [GNU_LINUX]: Don't assume system memory size fits in unsigned long; this isn't true on some 32-bit hosts. Avoid buffer overrun if some future version of /proc/meminfo has a variable name longer than 20 bytes. (system_process_attributes) [__FreeBSD__]: Don't assume hw.availpages fits in 'int'.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/process.c b/src/process.c
index ea1129ffbb8..c5e691bf602 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1140,15 +1140,18 @@ See `set-process-sentinel' for more info on sentinels. */)
1140DEFUN ("set-process-window-size", Fset_process_window_size, 1140DEFUN ("set-process-window-size", Fset_process_window_size,
1141 Sset_process_window_size, 3, 3, 0, 1141 Sset_process_window_size, 3, 3, 0,
1142 doc: /* Tell PROCESS that it has logical window size HEIGHT and WIDTH. */) 1142 doc: /* Tell PROCESS that it has logical window size HEIGHT and WIDTH. */)
1143 (register Lisp_Object process, Lisp_Object height, Lisp_Object width) 1143 (Lisp_Object process, Lisp_Object height, Lisp_Object width)
1144{ 1144{
1145 CHECK_PROCESS (process); 1145 CHECK_PROCESS (process);
1146 CHECK_RANGED_INTEGER (height, 0, INT_MAX); 1146
1147 CHECK_RANGED_INTEGER (width, 0, INT_MAX); 1147 /* All known platforms store window sizes as 'unsigned short'. */
1148 CHECK_RANGED_INTEGER (height, 0, USHRT_MAX);
1149 CHECK_RANGED_INTEGER (width, 0, USHRT_MAX);
1148 1150
1149 if (XPROCESS (process)->infd < 0 1151 if (XPROCESS (process)->infd < 0
1150 || set_window_size (XPROCESS (process)->infd, 1152 || (set_window_size (XPROCESS (process)->infd,
1151 XINT (height), XINT (width)) <= 0) 1153 XINT (height), XINT (width))
1154 < 0))
1152 return Qnil; 1155 return Qnil;
1153 else 1156 else
1154 return Qt; 1157 return Qt;