]> granicus.if.org Git - php/commitdiff
strncpy() -> strlcpy()
authorIlia Alshanetsky <iliaa@php.net>
Sat, 24 Feb 2007 18:00:56 +0000 (18:00 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sat, 24 Feb 2007 18:00:56 +0000 (18:00 +0000)
ext/dbase/dbf_head.c
ext/dbase/dbf_rec.c
ext/gd/libgd/gd_gif_in.c
ext/interbase/ibase_query.c
ext/pdo_firebird/firebird_statement.c
ext/wddx/wddx.c

index 9c9363dfbbe31ebe3754d88cebde5a4005516a60..0f9ad61461ebe5424eb2922d373bb5d12f4d70f0 100644 (file)
@@ -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) {
index 6e872d3fb7eec28f8039c4ea7ddecdcf0e154ef4..86db49866672cbfbf53c40253f897beeb05f3b74 100644 (file)
@@ -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;
 }
index e3d635b31f5014018dda20d4e57e8e32748145a8..a770e168937320627ffaacb3148e2e8b0a38b49e 100644 (file)
@@ -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;
index 3de5879688a644e71fb0f350877db65c29fe8c95..bb2bfe6184cc16d165f315a5f959e29cbdf13c35 100644 (file)
@@ -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;
index f7ab90f14aa95a1b85de2ffd9636093b3f5f76f0..667bd8227a295735963db618e328e457e65ca827 100644 (file)
@@ -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;
index 4c883ded2cc359c4b8c0879495e5c41bd37a549b..6bdbb05ed3cffc3054bc6cc15383502d8a3fd8ac 100644 (file)
@@ -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';
                                }