diff options
author | Michal Soltys <soltys@ziu.info> | 2013-02-14 16:51:46 +0100 |
---|---|---|
committer | Michal Soltys <soltys@ziu.info> | 2013-02-14 16:53:05 +0100 |
commit | d9976c5f4230aa0bcc6f6572091bd2732bf35db9 (patch) | |
tree | faf76f1f6af0cf348b19d8e13fa5e9529daeae40 /com32/chain/options.c | |
parent | 9729a776507e811040ebb65699312b4620546ba3 (diff) | |
download | syslinux-d9976c5f4230aa0bcc6f6572091bd2732bf35db9.tar.gz |
com32/chain: rely more on addr_t, replace ADDR*
Whenever the computation imply use of that type, even if it's just
uint32_t.
Add dosmax (using 40:13) and dosmin (0x500) instead of separate ADDR*
and dosmem (in do_boot()).
Signed-off-by: Michal Soltys <soltys@ziu.info>
Diffstat (limited to 'com32/chain/options.c')
-rw-r--r-- | com32/chain/options.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/com32/chain/options.c b/com32/chain/options.c index 70f50697..531caf82 100644 --- a/com32/chain/options.c +++ b/com32/chain/options.c @@ -28,6 +28,7 @@ * * ----------------------------------------------------------------------- */ +#include <syslinux/movebits.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -38,14 +39,17 @@ struct options opt; -static int soi_s2n(char *ptr, unsigned int *seg, - unsigned int *off, - unsigned int *ip, - unsigned int def) +static int soi_s2n(char *ptr, + addr_t *seg, + addr_t *off, + addr_t *ip, + addr_t def) { - unsigned int segval = 0, offval, ipval, val; + addr_t segval, offval, ipval, val; char *p; + /* defaults */ + segval = 0; offval = def; ipval = def; @@ -55,16 +59,21 @@ static int soi_s2n(char *ptr, unsigned int *seg, if (p[0] == ':' && p[1] && p[1] != ':') ipval = strtoul(p+1, NULL, 0); + /* verify if load address is within [dosmin, dosmax) */ val = (segval << 4) + offval; - if (val < ADDRMIN || val > ADDRMAX) { + if (val < dosmin || val >= dosmax) { error("Invalid seg:off:* address specified."); goto bail; } + /* + * verify if jump address is within [dosmin, dosmax) and offset is 16bit + * sane + */ val = (segval << 4) + ipval; - if (ipval > 0xFFFE || val < ADDRMIN || val > ADDRMAX) { + if (ipval > 0xFFFE || val < dosmin || val >= dosmax) { error("Invalid seg:*:ip address specified."); goto bail; } |