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
This commit is contained in:
Stefan Fritsch
2010-07-31 20:08:44 +00:00
parent e444411df7
commit 02dc2d45cf
4 changed files with 4 additions and 10 deletions

View File

@ -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));

View File

@ -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,

View File

@ -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 " */

View File

@ -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;