diff options
author | Pedro F. Giffuni <pfg@FreeBSD.org> | 2016-12-12 03:46:40 +0000 |
---|---|---|
committer | Pedro F. Giffuni <pfg@FreeBSD.org> | 2016-12-12 03:46:40 +0000 |
commit | 27150ef8bc3626955f6d285c813a210143a9459d (patch) | |
tree | 75c24979437345641f2cec7b44ff0381c748c570 /bin/ed | |
parent | 63ecfce85324ace4be1004a710c7f0a08d4078ca (diff) | |
download | src-27150ef8bc3626955f6d285c813a210143a9459d.tar.gz src-27150ef8bc3626955f6d285c813a210143a9459d.zip |
ed(1): Prevent possible overflows during allocation.
Make sure the parameters used for malloc(3) can hold size_t sizes.
This should help ed(1) handle bigger data in the future.
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=309873
Diffstat (limited to 'bin/ed')
-rw-r--r-- | bin/ed/ed.h | 4 | ||||
-rw-r--r-- | bin/ed/glbl.c | 2 | ||||
-rw-r--r-- | bin/ed/main.c | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/bin/ed/ed.h b/bin/ed/ed.h index 8cb8cec731ef..597e3464e7fa 100644 --- a/bin/ed/ed.h +++ b/bin/ed/ed.h @@ -115,7 +115,7 @@ if (--mutex == 0) { \ /* REALLOC: assure at least a minimum size for buffer b */ #define REALLOC(b,n,i,err) \ if ((i) > (n)) { \ - int ti = (n); \ + size_t ti = (n); \ char *ts; \ SPL1(); \ if ((b) != NULL) { \ @@ -141,7 +141,7 @@ if ((i) > (n)) { \ /* REALLOC: assure at least a minimum size for buffer b */ #define REALLOC(b,n,i,err) \ if ((i) > (n)) { \ - int ti = (n); \ + size_t ti = (n); \ char *ts; \ SPL1(); \ if ((ts = (char *) realloc((b), ti += max((i), MINBUFSZ))) == NULL) { \ diff --git a/bin/ed/glbl.c b/bin/ed/glbl.c index dfb44d28ca0d..d3677989235e 100644 --- a/bin/ed/glbl.c +++ b/bin/ed/glbl.c @@ -146,7 +146,7 @@ int set_active_node(line_t *lp) { if (active_last + 1 > active_size) { - int ti = active_size; + size_t ti = active_size; line_t **ts; SPL1(); #if defined(sun) || defined(NO_REALLOC_NULL) diff --git a/bin/ed/main.c b/bin/ed/main.c index 174931494e34..6cb7d03364d0 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -1356,7 +1356,7 @@ handle_hup(int signo) char *hup = NULL; /* hup filename */ char *s; char ed_hup[] = "ed.hup"; - int n; + size_t n; if (!sigactive) quit(1); |