From: Uwe Schindler Date: Sat, 26 Jun 2004 10:30:22 +0000 (+0000) Subject: MFH: replace strncpy with strlcpy X-Git-Tag: php-4.3.9RC1~73 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4b9d8117f2847ff0332cb536ad7005df2f85fa1;p=php MFH: replace strncpy with strlcpy --- diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c index 849317be31..870a386bac 100644 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@ -604,7 +604,7 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D while (entry) { if (!PG(safe_mode) || strncasecmp(entry->param->name, "authorization", 13)) { if (strcasecmp(entry->param->name, "content-length")==0 || strcasecmp(entry->param->name, "content-type")==0) { - strncpy(buf, entry->param->name, NS_BUF_SIZE); + strlcpy(buf, entry->param->name, NS_BUF_SIZE); pos = 0; } else { snprintf(buf, NS_BUF_SIZE, "HTTP_%s", entry->param->name); @@ -672,8 +672,7 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D /* Create full Request-URI & Script-Name */ if (SG(request_info).request_uri) { - strncpy(buf, SG(request_info).request_uri, NS_BUF_SIZE); - buf[NS_BUF_SIZE]='\0'; + strlcpy(buf, SG(request_info).request_uri, NS_BUF_SIZE); if (SG(request_info).query_string) { p = strchr(buf, 0); snprintf(p, NS_BUF_SIZE-(p-buf), "?%s", SG(request_info).query_string); @@ -681,8 +680,7 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D } php_register_variable("REQUEST_URI", buf, track_vars_array TSRMLS_CC); - strncpy(buf, SG(request_info).request_uri, NS_BUF_SIZE); - buf[NS_BUF_SIZE]='\0'; + strlcpy(buf, SG(request_info).request_uri, NS_BUF_SIZE); if (rc->path_info) { pos = strlen(SG(request_info).request_uri) - strlen(rc->path_info); if (pos>=0 && pos<=NS_BUF_SIZE && rc->path_info) {