diff options
34 files changed, 70 insertions, 67 deletions
| diff --git a/lib/libI77/lread.c b/lib/libI77/lread.c index 27f0269caa7d..76d84f769936 100644 --- a/lib/libI77/lread.c +++ b/lib/libI77/lread.c @@ -408,7 +408,7 @@ l_CHAR(Void)  			*p++ = ch;  			f__lcount = 10*f__lcount + ch - '0';  			if (++i == size) { -				f__lchar = (char *)realloc(f__lchar, +				f__lchar = (char *)reallocf(f__lchar,  					(unsigned int)(size += BUFSIZE));  				if(f__lchar == NULL)  					errfl(f__elist->cierr,113,rafail); diff --git a/lib/libc/db/btree/bt_overflow.c b/lib/libc/db/btree/bt_overflow.c index b28b8e04711a..db28a22c73c1 100644 --- a/lib/libc/db/btree/bt_overflow.c +++ b/lib/libc/db/btree/bt_overflow.c @@ -99,7 +99,7 @@ __ovfl_get(t, p, ssz, buf, bufsz)  #endif  	/* Make the buffer bigger as necessary. */  	if (*bufsz < sz) { -		*buf = (char *)(*buf == NULL ? malloc(sz) : realloc(*buf, sz)); +		*buf = (char *)(*buf == NULL ? malloc(sz) : reallocf(*buf, sz));  		if (*buf == NULL)  			return (RET_ERROR);  		*bufsz = sz; diff --git a/lib/libc/db/recno/rec_get.c b/lib/libc/db/recno/rec_get.c index 47dd773fb97f..0a8b880062bb 100644 --- a/lib/libc/db/recno/rec_get.c +++ b/lib/libc/db/recno/rec_get.c @@ -132,7 +132,7 @@ __rec_fpipe(t, top)  	if (t->bt_rdata.size < t->bt_reclen) {  		t->bt_rdata.data = t->bt_rdata.data == NULL ?  		    malloc(t->bt_reclen) : -		    realloc(t->bt_rdata.data, t->bt_reclen); +		    reallocf(t->bt_rdata.data, t->bt_reclen);  		if (t->bt_rdata.data == NULL)  			return (RET_ERROR);  		t->bt_rdata.size = t->bt_reclen; @@ -205,7 +205,7 @@ __rec_vpipe(t, top)  				t->bt_rdata.size += (sz = 256);  				t->bt_rdata.data = t->bt_rdata.data == NULL ?  				    malloc(t->bt_rdata.size) : -				    realloc(t->bt_rdata.data, t->bt_rdata.size); +				    reallocf(t->bt_rdata.data, t->bt_rdata.size);  				if (t->bt_rdata.data == NULL)  					return (RET_ERROR);  				p = (u_char *)t->bt_rdata.data + len; @@ -244,7 +244,7 @@ __rec_fmap(t, top)  	if (t->bt_rdata.size < t->bt_reclen) {  		t->bt_rdata.data = t->bt_rdata.data == NULL ?  		    malloc(t->bt_reclen) : -		    realloc(t->bt_rdata.data, t->bt_reclen); +		    reallocf(t->bt_rdata.data, t->bt_reclen);  		if (t->bt_rdata.data == NULL)  			return (RET_ERROR);  		t->bt_rdata.size = t->bt_reclen; diff --git a/lib/libc/db/recno/rec_put.c b/lib/libc/db/recno/rec_put.c index 1afae0d5a675..0a5bddfadb6b 100644 --- a/lib/libc/db/recno/rec_put.c +++ b/lib/libc/db/recno/rec_put.c @@ -88,9 +88,8 @@ __rec_put(dbp, key, data, flags)  			goto einval;  		if (t->bt_rdata.size < t->bt_reclen) { -			t->bt_rdata.data = t->bt_rdata.data == NULL ? -			    malloc(t->bt_reclen) : -			    realloc(t->bt_rdata.data, t->bt_reclen); +			t->bt_rdata.data =  +			    reallocf(t->bt_rdata.data, t->bt_reclen);  			if (t->bt_rdata.data == NULL)  				return (RET_ERROR);  			t->bt_rdata.size = t->bt_reclen; diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c index 02cad6c00dc4..da88ed139460 100644 --- a/lib/libc/gen/fts-compat.c +++ b/lib/libc/gen/fts-compat.c @@ -881,7 +881,7 @@ fts_sort(sp, head, nitems)  	 */  	if (nitems > sp->fts_nitems) {  		sp->fts_nitems = nitems + 40; -		if ((sp->fts_array = realloc(sp->fts_array, +		if ((sp->fts_array = reallocf(sp->fts_array,  		    (size_t)(sp->fts_nitems * sizeof(FTSENT *)))) == NULL) {  			sp->fts_nitems = 0;  			return (head); @@ -959,7 +959,7 @@ fts_palloc(sp, more)  	size_t more;  {  	sp->fts_pathlen += more + 256; -	sp->fts_path = realloc(sp->fts_path, (size_t)sp->fts_pathlen); +	sp->fts_path = reallocf(sp->fts_path, (size_t)sp->fts_pathlen);  	return (sp->fts_path == NULL);  } diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 02cad6c00dc4..da88ed139460 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -881,7 +881,7 @@ fts_sort(sp, head, nitems)  	 */  	if (nitems > sp->fts_nitems) {  		sp->fts_nitems = nitems + 40; -		if ((sp->fts_array = realloc(sp->fts_array, +		if ((sp->fts_array = reallocf(sp->fts_array,  		    (size_t)(sp->fts_nitems * sizeof(FTSENT *)))) == NULL) {  			sp->fts_nitems = 0;  			return (head); @@ -959,7 +959,7 @@ fts_palloc(sp, more)  	size_t more;  {  	sp->fts_pathlen += more + 256; -	sp->fts_path = realloc(sp->fts_path, (size_t)sp->fts_pathlen); +	sp->fts_path = reallocf(sp->fts_path, (size_t)sp->fts_pathlen);  	return (sp->fts_path == NULL);  } diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c index 0295984d4e1e..aaee0ddc3599 100644 --- a/lib/libc/gen/getcap.c +++ b/lib/libc/gen/getcap.c @@ -344,7 +344,7 @@ getent(cap, len, db_array, fd, name, depth, nfield)  					pos = rp - record;  					newsize = r_end - record + BFRAG; -					record = realloc(record, newsize); +					record = reallocf(record, newsize);  					if (record == NULL) {  						errno = ENOMEM;  						if (myfd) @@ -484,7 +484,7 @@ tc_exp:	{  				newsize = r_end - record + diff + BFRAG;  				tcpos = tcstart - record;  				tcposend = tcend - record; -				record = realloc(record, newsize); +				record = reallocf(record, newsize);  				if (record == NULL) {  					errno = ENOMEM;  					if (myfd) @@ -524,7 +524,7 @@ tc_exp:	{  	*len = rp - record - 1;	/* don't count NUL */  	if (r_end > rp)  		if ((record = -		     realloc(record, (size_t)(rp - record))) == NULL) { +		     reallocf(record, (size_t)(rp - record))) == NULL) {  			errno = ENOMEM;  			return (-2);  		} @@ -867,7 +867,7 @@ cgetstr(buf, cap, str)  		if (m_room == 0) {  			size_t size = mp - mem; -			if ((mem = realloc(mem, size + SFRAG)) == NULL) +			if ((mem = reallocf(mem, size + SFRAG)) == NULL)  				return (-2);  			m_room = SFRAG;  			mp = mem + size; @@ -881,7 +881,7 @@ cgetstr(buf, cap, str)  	 * Give back any extra memory and return value and success.  	 */  	if (m_room != 0) -		if ((mem = realloc(mem, (size_t)(mp - mem))) == NULL) +		if ((mem = reallocf(mem, (size_t)(mp - mem))) == NULL)  			return (-2);  	*str = mem;  	return (len); @@ -940,7 +940,7 @@ cgetustr(buf, cap, str)  		if (m_room == 0) {  			size_t size = mp - mem; -			if ((mem = realloc(mem, size + SFRAG)) == NULL) +			if ((mem = reallocf(mem, size + SFRAG)) == NULL)  				return (-2);  			m_room = SFRAG;  			mp = mem + size; @@ -954,7 +954,7 @@ cgetustr(buf, cap, str)  	 * Give back any extra memory and return value and success.  	 */  	if (m_room != 0) -		if ((mem = realloc(mem, (size_t)(mp - mem))) == NULL) +		if ((mem = reallocf(mem, (size_t)(mp - mem))) == NULL)  			return (-2);  	*str = mem;  	return (len); diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c index fae252db02bd..8d57e6ce8a73 100644 --- a/lib/libc/gen/getcwd.c +++ b/lib/libc/gen/getcwd.c @@ -182,7 +182,7 @@ getcwd(pt, size)  		 * possible component name, plus a trailing NULL.  		 */  		if (bup + 3  + MAXNAMLEN + 1 >= eup) { -			if ((up = realloc(up, upsize *= 2)) == NULL) +			if ((up = reallocf(up, upsize *= 2)) == NULL)  				goto err;  			bup = up;  			eup = up + upsize; diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index 26069c6f5684..5b5c9dac1f83 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -266,7 +266,7 @@ grscan(search, gid, name)  				    maxlinelength >= MAXLINELENGTHLIMIT)  					return(0); -				if ((line = (char *)realloc(line,  +				if ((line = (char *)reallocf(line,   				     sizeof(char) *   				     (maxlinelength + MAXLINELENGTH))) == NULL)  					return(0); @@ -381,7 +381,7 @@ grscan(search, gid, name)  		for (m = members; ; bp++) {  			if (m == (members + maxgrp - 1)) {  				if ((members = (char **) -				     realloc(members,  +				     reallocf(members,   					     sizeof(char **) *   					     (maxgrp + MAXGRP))) == NULL)  					return(0); @@ -439,7 +439,7 @@ _gr_breakout_yp(struct group *gr, char *result)  	for (m = members; ; s++) {  		if (m == members + maxgrp - 1) { -			if ((members = (char **)realloc(members,  +			if ((members = (char **)reallocf(members,   			     sizeof(char **) * (maxgrp + MAXGRP))) == NULL)  				return(0);  			m = members + maxgrp - 1; diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index b26b9275fd5d..02ec190519fe 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -287,7 +287,7 @@ __hashpw(key)  	/* Increase buffer size for long lines if necessary. */  	if (data.size > max) {  		max = data.size + 1024; -		if (!(line = realloc(line, max))) +		if (!(line = reallocf(line, max)))  			return(0);  	} diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c index 73da108a991e..ff01646843aa 100644 --- a/lib/libc/gen/opendir.c +++ b/lib/libc/gen/opendir.c @@ -137,7 +137,7 @@ __opendir2(name, flags)  			if (space < DIRBLKSIZ) {  				space += incr;  				len += incr; -				buf = realloc(buf, len); +				buf = reallocf(buf, len);  				if (buf == NULL)  					goto fail;  				ddptr = buf + (len - space); diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c index e6e840802703..8a8b7d2d5b6f 100644 --- a/lib/libc/gen/scandir.c +++ b/lib/libc/gen/scandir.c @@ -109,7 +109,7 @@ scandir(dirname, namelist, select, dcomp)  			if (fstat(dirp->dd_fd, &stb) < 0)  				return(-1);	/* just might have grown */  			arraysz = stb.st_size / 12; -			names = (struct dirent **)realloc((char *)names, +			names = (struct dirent **)reallocf((char *)names,  				arraysz * sizeof(struct dirent *));  			if (names == NULL)  				return(-1); diff --git a/lib/libc/gen/stringlist.c b/lib/libc/gen/stringlist.c index 57c4d91485e8..bb749191edac 100644 --- a/lib/libc/gen/stringlist.c +++ b/lib/libc/gen/stringlist.c @@ -72,7 +72,7 @@ sl_add(sl, name)  {  	if (sl->sl_cur == sl->sl_max - 1) {  		sl->sl_max += _SL_CHUNKSIZE; -		sl->sl_str = realloc(sl->sl_str, sl->sl_max * sizeof(char *)); +		sl->sl_str = reallocf(sl->sl_str, sl->sl_max * sizeof(char *));  		if (sl->sl_str == NULL)  			err(1, "stringlist: %m");  	} diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c index d1f03e7ac560..87b4058c66e3 100644 --- a/lib/libc/locale/collate.c +++ b/lib/libc/locale/collate.c @@ -24,7 +24,7 @@   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF   * SUCH DAMAGE.   * - * $Id$ + * $Id: collate.c,v 1.15 1997/02/22 14:59:52 peter Exp $   */  #include <rune.h> @@ -114,7 +114,7 @@ __collate_substitute(s)  			if(!dest_str)  				dest_str = calloc(dest_len = delta, 1);  			else -				dest_str = realloc(dest_str, dest_len += delta); +				dest_str = reallocf(dest_str, dest_len += delta);  			if(dest_str == NULL)  				__collate_err(EX_OSERR, __FUNCTION__);  		} diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index 8bb135504c83..67fdf47ee37e 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -1185,12 +1185,12 @@ register struct parse *p;  		if (p->g->sets == NULL)  			p->g->sets = (cset *)malloc(nc * sizeof(cset));  		else -			p->g->sets = (cset *)realloc((char *)p->g->sets, +			p->g->sets = (cset *)reallocf((char *)p->g->sets,  							nc * sizeof(cset));  		if (p->g->setbits == NULL)  			p->g->setbits = (uch *)malloc(nbytes);  		else { -			p->g->setbits = (uch *)realloc((char *)p->g->setbits, +			p->g->setbits = (uch *)reallocf((char *)p->g->setbits,  								nbytes);  			/* xxx this isn't right if setbits is now NULL */  			for (i = 0; i < no; i++) @@ -1331,7 +1331,7 @@ register char *cp;  	if (cs->multis == NULL)  		cs->multis = malloc(cs->smultis);  	else -		cs->multis = realloc(cs->multis, cs->smultis); +		cs->multis = reallocf(cs->multis, cs->smultis);  	if (cs->multis == NULL) {  		SETERROR(REG_ESPACE);  		return; @@ -1365,7 +1365,7 @@ register char *cp;  		return;  	} -	cs->multis = realloc(cs->multis, cs->smultis); +	cs->multis = reallocf(cs->multis, cs->smultis);  	assert(cs->multis != NULL);  } diff --git a/lib/libc/stdio/asprintf.c b/lib/libc/stdio/asprintf.c index 7a3e39aeace2..43e90a92c11b 100644 --- a/lib/libc/stdio/asprintf.c +++ b/lib/libc/stdio/asprintf.c @@ -28,7 +28,7 @@   */  #if defined(LIBC_RCS) && !defined(lint) -static char rcsid[] = "$Id: asprintf.c,v 1.3 1997/02/22 15:01:45 peter Exp $"; +static char rcsid[] = "$Id: asprintf.c,v 1.4 1998/07/08 00:44:51 peter Exp $";  #endif /* LIBC_RCS and not lint */  #include <stdio.h> @@ -71,7 +71,7 @@ asprintf(str, fmt, va_alist)  	ret = vfprintf(&f, fmt, ap);  	*f._p = '\0';  	va_end(ap); -	f._bf._base = realloc(f._bf._base, f._bf._size + 1); +	f._bf._base = reallocf(f._bf._base, f._bf._size + 1);  	if (f._bf._base == NULL) {  		errno = ENOMEM;  		ret = -1; diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c index 75dfca92430f..9cce8f2085fd 100644 --- a/lib/libc/stdio/fvwrite.c +++ b/lib/libc/stdio/fvwrite.c @@ -39,7 +39,7 @@  static char sccsid[] = "@(#)fvwrite.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id: fvwrite.c,v 1.7 1997/12/24 23:23:18 ache Exp $"; +		"$Id: fvwrite.c,v 1.8 1998/07/08 00:44:54 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> @@ -123,7 +123,7 @@ __sfvwrite(fp, uio)  				fp->_w = len + 128;  				fp->_bf._size = blen + len + 128;  				fp->_bf._base = -				    realloc(fp->_bf._base, fp->_bf._size + 1); +				    reallocf(fp->_bf._base, fp->_bf._size + 1);  				if (fp->_bf._base == NULL)  					goto err;  				fp->_p = fp->_bf._base + blen; diff --git a/lib/libc/stdio/vasprintf.c b/lib/libc/stdio/vasprintf.c index 87db4cd5dbcd..3c509ac74161 100644 --- a/lib/libc/stdio/vasprintf.c +++ b/lib/libc/stdio/vasprintf.c @@ -28,7 +28,7 @@   */  #if defined(LIBC_RCS) && !defined(lint) -static char rcsid[] = "$Id: vasprintf.c,v 1.8 1998/03/09 06:51:23 jb Exp $"; +static char rcsid[] = "$Id: vasprintf.c,v 1.9 1998/07/08 00:44:56 peter Exp $";  #endif /* LIBC_RCS and not lint */  #include <stdio.h> @@ -55,7 +55,7 @@ vasprintf(str, fmt, ap)  	f._bf._size = f._w = 127;		/* Leave room for the NULL */  	ret = vfprintf(&f, fmt, ap);  	*f._p = '\0'; -	f._bf._base = realloc(f._bf._base, f._bf._size + 1); +	f._bf._base = reallocf(f._bf._base, f._bf._size + 1);  	if (f._bf._base == NULL) {  		errno = ENOMEM;  		ret = -1; diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 57022e5060e2..3cb58ed163eb 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -39,7 +39,7 @@  static char sccsid[] = "@(#)vfprintf.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id: vfprintf.c,v 1.18 1998/04/11 07:40:47 jb Exp $"; +		"$Id: vfprintf.c,v 1.19 1998/05/08 05:10:32 jb Exp $";  #endif /* LIBC_SCCS and not lint */  /* @@ -1182,7 +1182,7 @@ __grow_type_table (nextarg, typetable, tablesize)  		bcopy (oldtable, *typetable, *tablesize);  	} else {  		*typetable = (unsigned char *) -		    realloc (typetable, sizeof (unsigned char) * newsize); +		    reallocf (typetable, sizeof (unsigned char) * newsize);  	}  	memset (&typetable [*tablesize], T_UNUSED, (newsize - *tablesize)); diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index 998ef57912cf..b5177e9c221c 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -105,7 +105,7 @@ loop:                                errno = ELOOP;                                goto err1;                        } -			n = readlink(p, resolved, MAXPATHLEN); +			n = readlink(p, resolved, MAXPATHLEN - 1);  			if (n < 0)  				goto err1;  			resolved[n] = '\0'; diff --git a/lib/libc/stdlib/setenv.c b/lib/libc/stdlib/setenv.c index d9812771e700..4c00b6e882f3 100644 --- a/lib/libc/stdlib/setenv.c +++ b/lib/libc/stdlib/setenv.c @@ -73,7 +73,7 @@ setenv(name, value, rewrite)  		for (p = environ, cnt = 0; *p; ++p, ++cnt);  		if (alloced) {			/* just increase size */ -			environ = (char **)realloc((char *)environ, +			environ = (char **)reallocf((char *)environ,  			    (size_t)(sizeof(char *) * (cnt + 2)));  			if (!environ)  				return (-1); diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index 792815779504..ad227cf32029 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -273,6 +273,11 @@ register struct state * const	sp;  	register int		i;  	register int		fid; +	/* XXX The following is from OpenBSD, and I'm not sure it is correct */ +	if (name != NULL && issetugid() != 0) +		if ((name[0] == ':' && name[1] == '/') ||  +		    name[0] == '/' || strchr(name, '.')) +			name = NULL;  	if (name == NULL && (name = TZDEFAULT) == NULL)  		return -1;  	{ @@ -293,7 +298,7 @@ register struct state * const	sp;  		if (!doaccess) {  			if ((p = TZDIR) == NULL)  				return -1; -			if ((strlen(p) + strlen(name) + 1) >= sizeof fullname) +			if ((strlen(p) + 1 + strlen(name) + 1) >= sizeof fullname)  				return -1;  			(void) strcpy(fullname, p);  			(void) strcat(fullname, "/"); @@ -306,7 +311,7 @@ register struct state * const	sp;  			name = fullname;  		}  		if (doaccess && access(name, R_OK) != 0) -			return -1; +		     	return -1;  		if ((fid = open(name, OPEN_MODE)) == -1)  			return -1;  		if ((fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) diff --git a/lib/libc/stdtime/timelocal.c b/lib/libc/stdtime/timelocal.c index ef40035c09f4..31f0340c4187 100644 --- a/lib/libc/stdtime/timelocal.c +++ b/lib/libc/stdtime/timelocal.c @@ -23,7 +23,7 @@   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF   * SUCH DAMAGE.   * - *	$Id$ + *	$Id: timelocal.c,v 1.1 1997/08/09 15:43:57 joerg Exp $   */  #include <sys/types.h> @@ -146,7 +146,7 @@ __time_load_locale(const char *name)  	bufsize = namesize + st.st_size;  	locale_buf = NULL;  	lbuf = (lbuf == NULL || lbuf == locale_buf_C) ? -		malloc(bufsize) : realloc(lbuf, bufsize); +		malloc(bufsize) : reallocf(lbuf, bufsize);  	if (lbuf == NULL)  		goto bad_locale;  	(void) strcpy(lbuf, name); diff --git a/lib/libedit/el.c b/lib/libedit/el.c index f163ec898db8..c9c3f725593b 100644 --- a/lib/libedit/el.c +++ b/lib/libedit/el.c @@ -77,7 +77,7 @@ el_init(prog, fin, fout)      el->el_prog = strdup(prog);  #ifdef DEBUG -    if ((tty = getenv("DEBUGTTY")) != NULL) { +    if (issetugid() == 0 && (tty = getenv("DEBUGTTY")) != NULL) {  	el->el_errfile = fopen(tty, "w");  	if (el->el_errfile == NULL) {  		extern errno; @@ -291,7 +291,7 @@ el_source(el, fname)      if (fname == NULL) {  	fname = &elpath[1];  	if ((fp = fopen(fname, "r")) == NULL) { -	    if ((ptr = getenv("HOME")) == NULL) +	    if (issetugid() != 0 || (ptr = getenv("HOME")) == NULL)  		return -1;  	    (void)snprintf(path, sizeof(path), "%s%s", ptr, elpath);  	    fname = path; diff --git a/lib/libedit/el.h b/lib/libedit/el.h index 77cce15a3d45..a608e2055be5 100644 --- a/lib/libedit/el.h +++ b/lib/libedit/el.h @@ -86,6 +86,7 @@ typedef struct el_state_t {   */  #define el_malloc(a)	malloc(a)  #define el_realloc(a,b)	realloc(a, b) +#define el_reallocf(a,b) reallocf(a, b)  #define el_free(a)	free(a)  #include "tty.h" diff --git a/lib/libedit/map.c b/lib/libedit/map.c index 571982704e22..4b940d40a8e1 100644 --- a/lib/libedit/map.c +++ b/lib/libedit/map.c @@ -1380,9 +1380,9 @@ map_addfunc(el, name, help, func)  	return -1;      el->el_map.func = (el_func_t *) -		el_realloc(el->el_map.func, nf * sizeof(el_func_t)); +		el_reallocf(el->el_map.func, nf * sizeof(el_func_t));      el->el_map.help = (el_bindings_t *) -		el_realloc(el->el_map.help, nf * sizeof(el_bindings_t)); +		el_reallocf(el->el_map.help, nf * sizeof(el_bindings_t));      nf = el->el_map.nfunc;      el->el_map.func[nf] = func; diff --git a/lib/libedit/tokenizer.c b/lib/libedit/tokenizer.c index bbe847e2cab2..62c02498177f 100644 --- a/lib/libedit/tokenizer.c +++ b/lib/libedit/tokenizer.c @@ -59,6 +59,7 @@ typedef enum { Q_none, Q_single, Q_double, Q_one, Q_doubleone } quote_t;  #define tok_malloc(a)		malloc(a)  #define tok_free(a)		free(a)  #define tok_realloc(a, b)	realloc(a, b) +#define tok_reallocf(a, b)	reallocf(a, b)  struct tokenizer { @@ -377,8 +378,8 @@ tok_line(tok, line, argc, argv)  	if (tok->argc >= tok->amax - 4) {  	    tok->amax += AINCR; -	    tok->argv = (char **) tok_realloc(tok->argv, -					      tok->amax * sizeof(char*)); +	    tok->argv = (char **) tok_reallocf(tok->argv, +					       tok->amax * sizeof(char*));  	}      } diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c index 75bace451f42..4bcc2e575e4d 100644 --- a/lib/libkvm/kvm_proc.c +++ b/lib/libkvm/kvm_proc.c @@ -370,8 +370,10 @@ _kvm_realloc(kd, p, n)  {  	void *np = (void *)realloc(p, n); -	if (np == 0) +	if (np == 0) { +		free(p);  		_kvm_err(kd, kd->program, "out of memory"); +	}  	return (np);  } diff --git a/lib/libmytinfo/buildpath.c b/lib/libmytinfo/buildpath.c index cecba422e2c8..4e6f529bea1e 100644 --- a/lib/libmytinfo/buildpath.c +++ b/lib/libmytinfo/buildpath.c @@ -57,13 +57,8 @@ int type; {  	if (files >= size) {  		size += HUNK; -		if (path == NULL) -			path = (struct term_path *) -				malloc(size * sizeof(struct term_path)); -		else -			path = (struct term_path *) -				realloc((anyptr) path, -					size * sizeof(struct term_path)); +		path = (struct term_path *) reallocf((anyptr) path, +			size * sizeof(struct term_path));  		if (path == NULL)  			return 0;  	} diff --git a/lib/libss/help.c b/lib/libss/help.c index 48aece430028..078224d6a664 100644 --- a/lib/libss/help.c +++ b/lib/libss/help.c @@ -111,7 +111,7 @@ void ss_add_info_dir(sci_idx, info_dir, code_ptr)      dirs = info->info_dirs;      for (n_dirs = 0; dirs[n_dirs] != (char *)NULL; n_dirs++)  	;		/* get number of non-NULL dir entries */ -    dirs = (char **)realloc((char *)dirs, +    dirs = (char **)reallocf((char *)dirs,  			    (unsigned)(n_dirs + 2)*sizeof(char *));      if (dirs == (char **)NULL) {  	info->info_dirs = (char **)NULL; diff --git a/lib/libss/invocation.c b/lib/libss/invocation.c index 513ec7d1d128..f56c01a8cb7b 100644 --- a/lib/libss/invocation.c +++ b/lib/libss/invocation.c @@ -37,7 +37,7 @@ int ss_create_invocation(subsystem_name, version_string, info_ptr,  	for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++)  		; -	table = (ss_data **) realloc((char *)table, +	table = (ss_data **) reallocf((char *)table,  				     ((unsigned)sci_idx+2)*size);  	table[sci_idx+1] = (ss_data *) NULL;  	table[sci_idx] = new_table; diff --git a/lib/libss/parse.c b/lib/libss/parse.c index 8a61ea8a8d8f..878677e0ea80 100644 --- a/lib/libss/parse.c +++ b/lib/libss/parse.c @@ -31,7 +31,7 @@ enum parse_mode { WHITESPACE, TOKEN, QUOTED_STRING };   *              Series of pointers to parsed tokens.   */ -#define NEW_ARGV(old,n) (char **)realloc((char *)old,\ +#define NEW_ARGV(old,n) (char **)reallocf((char *)old,\  					 (unsigned)(n+2)*sizeof(char*))  char **ss_parse (sci_idx, line_ptr, argc_ptr) diff --git a/lib/libss/request_tbl.c b/lib/libss/request_tbl.c index b8600647d70d..1564689b6515 100644 --- a/lib/libss/request_tbl.c +++ b/lib/libss/request_tbl.c @@ -25,7 +25,7 @@ ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr)  		;  	/* size == C subscript of NULL == #elements */  	size += 2;		/* new element, and NULL */ -	info->rqt_tables = (ssrt **)realloc((char *)info->rqt_tables, +	info->rqt_tables = (ssrt **)reallocf((char *)info->rqt_tables,  					    (unsigned)size*sizeof(ssrt));  	if (info->rqt_tables == (ssrt **)NULL) {  		*code_ptr = errno; diff --git a/lib/libutil/login_auth.c b/lib/libutil/login_auth.c index 1bd6c132dd24..b0c617c38ba5 100644 --- a/lib/libutil/login_auth.c +++ b/lib/libutil/login_auth.c @@ -25,7 +25,7 @@   *   * Low-level routines relating to the user capabilities database   * - *	$Id: login_auth.c,v 1.7 1997/05/10 18:55:37 davidn Exp $ + *	$Id: login_auth.c,v 1.8 1997/07/19 04:47:05 davidn Exp $   */  #include <sys/types.h> @@ -393,7 +393,7 @@ auth_mkvalue(const char *value)  	    }  	}  	*p = '\0'; -	big = realloc(big, strlen(big) + 1); +	big = reallocf(big, strlen(big) + 1);      }      return big;  } | 
