summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doio.c7
-rw-r--r--mg.c3
-rw-r--r--pp_sys.c7
-rw-r--r--toke.c2
-rw-r--r--util.c9
5 files changed, 13 insertions, 15 deletions
diff --git a/doio.c b/doio.c
index 1fcb165065..29b5b19f50 100644
--- a/doio.c
+++ b/doio.c
@@ -1443,10 +1443,9 @@ Perl_do_exec3(pTHX_ const char *incmd, int fd, int do_report)
char *cmd;
/* Make a copy so we can change it */
- const int cmdlen = strlen(incmd);
- Newx(cmd, cmdlen+1, char);
- strncpy(cmd, incmd, cmdlen);
- cmd[cmdlen] = 0;
+ const Size_t cmdlen = strlen(incmd) + 1;
+ Newx(cmd, cmdlen, char);
+ my_strlcpy(cmd, incmd, cmdlen);
while (*cmd && isSPACE(*cmd))
cmd++;
diff --git a/mg.c b/mg.c
index dec8588efc..168d456c62 100644
--- a/mg.c
+++ b/mg.c
@@ -1073,8 +1073,7 @@ Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg)
Stat_t sbuf;
int i = 0, j = 0;
- strncpy(eltbuf, s, 255);
- eltbuf[255] = 0;
+ my_strlcpy(eltbuf, s, sizeof(eltbuf));
elt = eltbuf;
do { /* DCL$PATH may be a search list */
while (1) { /* as may dev portion of any element */
diff --git a/pp_sys.c b/pp_sys.c
index 25deca1f9e..a5028ba7b1 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3580,10 +3580,11 @@ S_dooneliner(pTHX_ const char *cmd, const char *filename)
char *s;
PerlIO *myfp;
int anum = 1;
+ Size_t size = strlen(cmd) + (strlen(filename) * 2) + 10;
- Newx(cmdline, strlen(cmd) + (strlen(filename) * 2) + 10, char);
- strcpy(cmdline, cmd);
- strcat(cmdline, " ");
+ Newx(cmdline, size, char);
+ my_strlcpy(cmdline, cmd, size);
+ my_strlcat(cmdline, " ", size);
for (s = cmdline + strlen(cmdline); *filename; ) {
*s++ = '\\';
*s++ = *filename++;
diff --git a/toke.c b/toke.c
index c6e00efdc3..f4e44993ad 100644
--- a/toke.c
+++ b/toke.c
@@ -499,7 +499,7 @@ S_feature_is_enabled(pTHX_ const char *name, STRLEN namelen)
dVAR;
HV * const hinthv = GvHV(PL_hintgv);
char he_name[32] = "feature_";
- (void) strncpy(&he_name[8], name, 24);
+ (void) my_strlcpy(&he_name[8], name, 24);
return (hinthv && hv_exists(hinthv, he_name, 8 + namelen));
}
diff --git a/util.c b/util.c
index 7a3be16a09..1bb7283491 100644
--- a/util.c
+++ b/util.c
@@ -3022,7 +3022,7 @@ Perl_find_script(pTHX_ const char *scriptname, bool dosearch,
if ((strlen(tmpbuf) + strlen(scriptname)
+ MAX_EXT_LEN) >= sizeof tmpbuf)
continue; /* don't search dir with too-long name */
- strcat(tmpbuf, scriptname);
+ my_strlcat(tmpbuf, scriptname, sizeof(tmpbuf));
#else /* !VMS */
#ifdef DOSISH
@@ -3054,11 +3054,10 @@ Perl_find_script(pTHX_ const char *scriptname, bool dosearch,
len = strlen(scriptname);
if (len+MAX_EXT_LEN+1 >= sizeof(tmpbuf))
break;
- /* FIXME? Convert to memcpy */
- cur = strcpy(tmpbuf, scriptname);
+ cur = my_strlcpy(tmpbuf, scriptname, sizeof(tmpbuf));
}
} while (extidx >= 0 && ext[extidx] /* try an extension? */
- && strcpy(tmpbuf+len, ext[extidx++]));
+ && my_strlcpy(tmpbuf+len, ext[extidx++], sizeof(tmpbuf) - len));
#endif
}
#endif
@@ -3135,7 +3134,7 @@ Perl_find_script(pTHX_ const char *scriptname, bool dosearch,
#ifdef SEARCH_EXTS
} while ( retval < 0 /* not there */
&& extidx>=0 && ext[extidx] /* try an extension? */
- && strcpy(tmpbuf+len, ext[extidx++])
+ && my_strlcpy(tmpbuf+len, ext[extidx++], sizeof(tmpbuf) - len)
);
#endif
if (retval < 0)