summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2010-07-31 22:08:44 +0200
committerStefan Fritsch <sf@apache.org>2010-07-31 22:08:44 +0200
commit02dc2d45cfe00db38ef519bebb6b74f87a03a464 (patch)
tree9871eb369e64bf87922282d11ccf65ef0b7b35c7
parentReplace apr_palloc+memcpy by apr_memdup (diff)
downloadapache2-02dc2d45cfe00db38ef519bebb6b74f87a03a464.tar.xz
apache2-02dc2d45cfe00db38ef519bebb6b74f87a03a464.zip
Code cleanup: replace strncpy by apr_cpystrn or apr_pstrmemdup
Submitted by: Takashi Sato <takashi lans tv com> PR: 43432 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@981086 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--modules/mappers/mod_rewrite.c4
-rw-r--r--modules/metadata/mod_mime_magic.c3
-rw-r--r--server/mpm/netware/mpm_netware.c2
-rw-r--r--server/util_pcre.c5
4 files changed, 4 insertions, 10 deletions
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
index 8a2c65e30b..a1cad924de 100644
--- a/modules/mappers/mod_rewrite.c
+++ b/modules/mappers/mod_rewrite.c
@@ -2313,9 +2313,7 @@ static char *do_expand(char *input, rewrite_ctx *ctx, rewriterule_entry *entry)
if (entry && (entry->flags & RULEFLAG_ESCAPEBACKREF)) {
/* escape the backreference */
char *tmp2, *tmp;
- tmp = apr_palloc(pool, span + 1);
- strncpy(tmp, bri->source + bri->regmatch[n].rm_so, span);
- tmp[span] = '\0';
+ tmp = apr_pstrmemdup(pool, bri->source + bri->regmatch[n].rm_so, span);
tmp2 = escape_uri(pool, tmp);
rewritelog((ctx->r, 5, ctx->perdir, "escaping backreference '%s' to '%s'",
tmp, tmp2));
diff --git a/modules/metadata/mod_mime_magic.c b/modules/metadata/mod_mime_magic.c
index fde91cadff..f9ef86f7ce 100644
--- a/modules/metadata/mod_mime_magic.c
+++ b/modules/metadata/mod_mime_magic.c
@@ -1275,8 +1275,7 @@ static int parse(server_rec *serv, apr_pool_t *p, char *l, int lineno)
}
else
m->nospflag = 0;
- strncpy(m->desc, l, sizeof(m->desc) - 1);
- m->desc[sizeof(m->desc) - 1] = '\0';
+ apr_cpystrn(m->desc, l, sizeof(m->desc));
#if MIME_MAGIC_DEBUG
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, serv,
diff --git a/server/mpm/netware/mpm_netware.c b/server/mpm/netware/mpm_netware.c
index a71b6e33fe..482509737b 100644
--- a/server/mpm/netware/mpm_netware.c
+++ b/server/mpm/netware/mpm_netware.c
@@ -1197,7 +1197,7 @@ static int CommandLineInterpreter(scr_t screenID, const char *commandLine)
if (strlen(commandLine) <= strlen(szCommand))
return NOTMYCOMMAND;
- strncpy (szcommandLine, commandLine, sizeof(szcommandLine)-1);
+ apr_cpystrn(szcommandLine, commandLine, sizeof(szcommandLine));
/* All added commands begin with "APACHE2 " */
diff --git a/server/util_pcre.c b/server/util_pcre.c
index c69c978503..089c6d360b 100644
--- a/server/util_pcre.c
+++ b/server/util_pcre.c
@@ -85,10 +85,7 @@ if (errbuf_size > 0)
apr_snprintf(errbuf, sizeof errbuf,
"%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
else
- {
- strncpy(errbuf, message, errbuf_size - 1);
- errbuf[errbuf_size-1] = 0;
- }
+ apr_cpystrn(errbuf, message, errbuf_size);
}
return length + addlength;