summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-02-24 18:00:56 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-02-24 18:00:56 +0000
commit9783f5f1f3dd69e06fc5ede7fb6715957bc43955 (patch)
tree66a86692ce4db1eeb97a0b75685305462c55100b /ext
parent9651aeaf7862f6c1e161dcf23b4d506c103255bb (diff)
downloadphp-git-9783f5f1f3dd69e06fc5ede7fb6715957bc43955.tar.gz
strncpy() -> strlcpy()
Diffstat (limited to 'ext')
-rw-r--r--ext/dbase/dbf_head.c2
-rw-r--r--ext/dbase/dbf_rec.c3
-rw-r--r--ext/gd/libgd/gd_gif_in.c3
-rw-r--r--ext/interbase/ibase_query.c5
-rw-r--r--ext/pdo_firebird/firebird_statement.c3
-rw-r--r--ext/wddx/wddx.c5
6 files changed, 8 insertions, 13 deletions
diff --git a/ext/dbase/dbf_head.c b/ext/dbase/dbf_head.c
index 9c9363dfbb..0f9ad61461 100644
--- a/ext/dbase/dbf_head.c
+++ b/ext/dbase/dbf_head.c
@@ -184,7 +184,7 @@ int put_dbf_field(dbhead_t *dbh, dbfield_t *dbf)
/* build the on disk field info */
scp = dbf->db_fname; dcp = dbfield.dbf_name;
- strncpy(dbfield.dbf_name, dbf->db_fname, DBF_NAMELEN);
+ strlcpy(dbfield.dbf_name, dbf->db_fname, DBF_NAMELEN);
dbfield.dbf_type = dbf->db_type;
switch (dbf->db_type) {
diff --git a/ext/dbase/dbf_rec.c b/ext/dbase/dbf_rec.c
index 6e872d3fb7..86db498666 100644
--- a/ext/dbase/dbf_rec.c
+++ b/ext/dbase/dbf_rec.c
@@ -152,8 +152,7 @@ char *get_field_val(char *rp, dbfield_t *fldp, char *cp)
if ( !cp )
cp = (char *)malloc(flen + 1);
if ( cp ) {
- strncpy(cp, &rp[fldp->db_foffset], flen);
- cp[flen] = 0;
+ strlcpy(cp, &rp[fldp->db_foffset], flen + 1);
}
return cp;
}
diff --git a/ext/gd/libgd/gd_gif_in.c b/ext/gd/libgd/gd_gif_in.c
index e3d635b31f..a770e16893 100644
--- a/ext/gd/libgd/gd_gif_in.c
+++ b/ext/gd/libgd/gd_gif_in.c
@@ -133,8 +133,7 @@ gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */
if (strncmp((char *)buf,"GIF",3) != 0) {
return 0;
}
- strncpy(version, (char *)buf + 3, 3);
- version[3] = '\0';
+ strlcpy(version, (char *)buf + 3, sizeof(version));
if ((strcmp(version, "87a") != 0) && (strcmp(version, "89a") != 0)) {
return 0;
diff --git a/ext/interbase/ibase_query.c b/ext/interbase/ibase_query.c
index 3de5879688..bb2bfe6184 100644
--- a/ext/interbase/ibase_query.c
+++ b/ext/interbase/ibase_query.c
@@ -603,9 +603,8 @@ static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, /
break;
default:
convert_to_string(val);
- strncpy(buf, Z_STRVAL_P(val), array->el_size);
- buf[array->el_size-1] = '\0';
- }
+ strlcpy(buf, Z_STRVAL_P(val), buf_size);
+ }
}
}
return SUCCESS;
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index f7ab90f14a..667bd8227a 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -655,8 +655,7 @@ static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, long attr, zval *val TS
RECORD_ERROR(stmt);
return 0;
}
- strncpy(S->name, Z_STRVAL_P(val), sizeof(S->name));
- S->name[sizeof(S->name)] = 0;
+ strlcpy(S->name, Z_STRVAL_P(val), sizeof(S->name));
break;
}
return 1;
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index 4c883ded2c..6bdbb05ed3 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -1034,10 +1034,9 @@ static void php_wddx_process_data(void *user_data, const XML_Char *s, int len)
Z_STRVAL_P(ent->data) = estrndup(decoded, decoded_len);
Z_STRLEN_P(ent->data) = decoded_len;
} else {
- Z_STRVAL_P(ent->data) = erealloc(Z_STRVAL_P(ent->data),
- Z_STRLEN_P(ent->data) + decoded_len + 1);
- strncpy(Z_STRVAL_P(ent->data)+Z_STRLEN_P(ent->data), decoded, decoded_len);
Z_STRLEN_P(ent->data) += decoded_len;
+ Z_STRVAL_P(ent->data) = erealloc(Z_STRVAL_P(ent->data), Z_STRLEN_P(ent->data) + 1);
+ strlcpy(Z_STRVAL_P(ent->data) + Z_STRLEN_P(ent->data), decoded, Z_STRLEN_P(ent->data) + 1);
Z_STRVAL_P(ent->data)[Z_STRLEN_P(ent->data)] = '\0';
}