diff options
-rw-r--r-- | modules/mappers/mod_rewrite.c | 4 | ||||
-rw-r--r-- | modules/metadata/mod_mime_magic.c | 3 | ||||
-rw-r--r-- | server/mpm/netware/mpm_netware.c | 2 | ||||
-rw-r--r-- | server/util_pcre.c | 5 |
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; |