summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdtime
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1998-09-16 04:17:47 +0000
committerimp <imp@FreeBSD.org>1998-09-16 04:17:47 +0000
commitbfe73fd683053201c326f9ff2c8e5e0f69cc7fe7 (patch)
treeb17d45198953bfbbad4bfd632dfdf1a37b7159d2 /lib/libc/stdtime
parent68a8c771724d4fc671cac3ce95f78d4fb1874cfe (diff)
downloadFreeBSD-src-bfe73fd683053201c326f9ff2c8e5e0f69cc7fe7.zip
FreeBSD-src-bfe73fd683053201c326f9ff2c8e5e0f69cc7fe7.tar.gz
Replace memory leaking instances of realloc with non-leaking reallocf.
In some cases replace if (a == null) a = malloc(x); else a = realloc(a, x); with simple reallocf(a, x). Per ANSI-C, this is guaranteed to be the same thing. I've been running these on my system here w/o ill effects for some time. However, the CTM-express is at part 6 of 34 for the CAM changes, so I've not been able to do a build world with the CAM in the tree with these changes. Shouldn't impact anything, but...
Diffstat (limited to 'lib/libc/stdtime')
-rw-r--r--lib/libc/stdtime/localtime.c9
-rw-r--r--lib/libc/stdtime/timelocal.c4
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c
index 7928157..ad227cf 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 ef40035..31f0340 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);
OpenPOWER on IntegriCloud