From: Andrey Hristov Date: Tue, 8 Jan 2008 13:13:39 +0000 (+0000) Subject: strncpy->strlcpy X-Git-Tag: RELEASE_2_0_0a1~988 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a4f6015bbde756d1e87a153d715f8594b580db9;p=php strncpy->strlcpy --- diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index a0a13208b9..2ee2244b18 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -676,14 +676,14 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn, } else if (ok_packet.field_count == 0xFF) { if (ok_packet.sqlstate[0]) { if (!self_alloced) { - strncpy(conn->error_info.sqlstate, ok_packet.sqlstate, sizeof(conn->error_info.sqlstate)); + strlcpy(conn->error_info.sqlstate, ok_packet.sqlstate, sizeof(conn->error_info.sqlstate)); } DBG_ERR_FMT("ERROR:%d [SQLSTATE:%s] %s", ok_packet.error_no, ok_packet.sqlstate, ok_packet.error); } if (!self_alloced) { conn->error_info.error_no = ok_packet.error_no; - strncpy(conn->error_info.error, ok_packet.error, sizeof(conn->error_info.error)); + strlcpy(conn->error_info.error, ok_packet.error, sizeof(conn->error_info.error)); } } } else { diff --git a/ext/mysqlnd/mysqlnd_loaddata.c b/ext/mysqlnd/mysqlnd_loaddata.c index 5e4b508629..02166ca210 100644 --- a/ext/mysqlnd/mysqlnd_loaddata.c +++ b/ext/mysqlnd/mysqlnd_loaddata.c @@ -113,7 +113,7 @@ int mysqlnd_local_infile_error(void *ptr, char *error_buf, uint error_buf_len TS DBG_ENTER("mysqlnd_local_infile_error"); if (info) { - strncpy(error_buf, info->error_msg, error_buf_len); + strlcpy(error_buf, info->error_msg, error_buf_len); DBG_INF_FMT("have info, %d", info->error_no); DBG_RETURN(info->error_no); } diff --git a/ext/mysqlnd/mysqlnd_priv.h b/ext/mysqlnd/mysqlnd_priv.h index 3a206cb39c..cf6424e49f 100644 --- a/ext/mysqlnd/mysqlnd_priv.h +++ b/ext/mysqlnd/mysqlnd_priv.h @@ -143,7 +143,7 @@ { \ error_info.error_no = 0; \ error_info.error[0] = '\0'; \ - strncpy(error_info.sqlstate, "00000", sizeof("00000") - 1); \ + strlcpy(error_info.sqlstate, "00000", sizeof(error_info.sqlstate)); \ } #define SET_CLIENT_ERROR(error_info, a, b, c) \ diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index 8c119a769f..5f1ee54b88 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -698,7 +698,7 @@ size_t php_mysqlnd_auth_write(void *_packet, MYSQLND *conn TSRMLS_DC) p+= 23; len= strlen(packet->user); - strncpy(p, packet->user, len); + memcpy(p, packet->user, len); p+= len; *p++ = '\0';