diff options
| author | Paul Eggert | 2011-07-12 10:34:59 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-07-12 10:34:59 -0700 |
| commit | c8907a930eb953a30831faa3a7ccae74e4ae2f23 (patch) | |
| tree | 0c75aae3721b488e49c207908d7f8d1eb64330ca /src | |
| parent | e9eb6f14fe334d0e37d2037c952e6541eeb242ad (diff) | |
| download | emacs-c8907a930eb953a30831faa3a7ccae74e4ae2f23.tar.gz emacs-c8907a930eb953a30831faa3a7ccae74e4ae2f23.zip | |
* xfaces.c (Fbitmap_spec_p): Fix integer overflow bug.
Without this fix, (bitmap-spec-p '(34359738368 1 "x"))
would wrongly return t on a 64-bit host.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/xfaces.c | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b0913ab983c..8911b6bdce2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2011-07-12 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * xfaces.c (Fbitmap_spec_p): Fix integer overflow bug. | ||
| 4 | Without this fix, (bitmap-spec-p '(34359738368 1 "x")) | ||
| 5 | would wrongly return t on a 64-bit host. | ||
| 6 | |||
| 1 | 2011-07-11 Paul Eggert <eggert@cs.ucla.edu> | 7 | 2011-07-11 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 8 | ||
| 3 | * dispnew.c (init_display): Use *_RANGE_OVERFLOW macros. | 9 | * dispnew.c (init_display): Use *_RANGE_OVERFLOW macros. |
diff --git a/src/xfaces.c b/src/xfaces.c index c1e75ab3e59..e0dc2883f33 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -940,11 +940,13 @@ the pixmap. Bits are stored row by row, each row occupies | |||
| 940 | } | 940 | } |
| 941 | } | 941 | } |
| 942 | 942 | ||
| 943 | if (NATNUMP (width) && NATNUMP (height) && STRINGP (data)) | 943 | if (STRINGP (data) |
| 944 | && INTEGERP (width) && 0 < XINT (width) | ||
| 945 | && INTEGERP (height) && 0 < XINT (height)) | ||
| 944 | { | 946 | { |
| 945 | int bytes_per_row = ((XFASTINT (width) + BITS_PER_CHAR - 1) | 947 | EMACS_INT bytes_per_row = ((XINT (width) + BITS_PER_CHAR - 1) |
| 946 | / BITS_PER_CHAR); | 948 | / BITS_PER_CHAR); |
| 947 | if (SBYTES (data) >= bytes_per_row * XINT (height)) | 949 | if (XINT (height) <= SBYTES (data) / bytes_per_row) |
| 948 | pixmap_p = 1; | 950 | pixmap_p = 1; |
| 949 | } | 951 | } |
| 950 | } | 952 | } |