diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2006-07-15 16:14:32 +0300 |
---|---|---|
committer | H.Merijn Brand <h.m.brand@xs4all.nl> | 2006-07-15 11:53:36 +0000 |
commit | d130778686fc2c04eb7d731512df9e71304d5573 (patch) | |
tree | 74953202209cd3371cc54464d6300b2dea41d77a /util.c | |
parent | 59bea8cf0bba843bea2b2a6c959c3fd1cf5e3075 (diff) | |
download | perl-d130778686fc2c04eb7d731512df9e71304d5573.tar.gz |
various safety/portability tweaks
Message-ID: <44B8C008.4030300@iki.fi>
p4raw-id: //depot/perl@28578
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -5225,7 +5225,7 @@ Perl_mem_log_alloc(const UV n, const UV typesize, const char *typename, Malloc_t { const STRLEN len = my_snprintf(buf, - PERL_MEM_LOG_SPRINTF_BUF_SIZE, + sizeof(buf), # ifdef PERL_MEM_LOG_TIMESTAMP "%10d.%06d: " # endif @@ -5270,7 +5270,7 @@ Perl_mem_log_realloc(const UV n, const UV typesize, const char *typename, Malloc { const STRLEN len = my_snprintf(buf, - PERL_MEM_LOG_SPRINTF_BUF_SIZE, + sizeof(buf), # ifdef PERL_MEM_LOG_TIMESTAMP "%10d.%06d: " # endif @@ -5316,7 +5316,7 @@ Perl_mem_log_free(Malloc_t oldalloc, const char *filename, const int linenumber, { const STRLEN len = my_snprintf(buf, - PERL_MEM_LOG_SPRINTF_BUF_SIZE, + sizeof(buf), # ifdef PERL_MEM_LOG_TIMESTAMP "%10d.%06d: " # endif @@ -5458,16 +5458,17 @@ Perl_my_clearenv(pTHX) (void)clearenv(); # elif defined(HAS_UNSETENV) int bsiz = 80; /* Most envvar names will be shorter than this. */ - char *buf = (char*)safesysmalloc(bsiz * sizeof(char)); + int bufsiz = bsiz * sizeof(char); /* sizeof(char) paranoid? */ + char *buf = (char*)safesysmalloc(bufsiz); while (*environ != NULL) { char *e = strchr(*environ, '='); int l = e ? e - *environ : strlen(*environ); if (bsiz < l + 1) { (void)safesysfree(buf); bsiz = l + 1; - buf = (char*)safesysmalloc(bsiz * sizeof(char)); + buf = (char*)safesysmalloc(bufsiz); } - strncpy(buf, *environ, l); + my_strlcpy(buf, bufsiz, *environ, l); *(buf + l) = '\0'; (void)unsetenv(buf); } |