diff options
author | Marcus Boerger <helly@php.net> | 2007-02-24 16:25:58 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2007-02-24 16:25:58 +0000 |
commit | 20a40063c51b20c1ea5f48c109b69fea3964b446 (patch) | |
tree | 24d6bf7894cc8080ff86f16eb5efef9da1cdf9c7 /ext/dbase | |
parent | 10ffce328593ddda1fb31482ec5d19ce6e02556d (diff) | |
download | php-git-20a40063c51b20c1ea5f48c109b69fea3964b446.tar.gz |
- avoid sprintf
Diffstat (limited to 'ext/dbase')
-rw-r--r-- | ext/dbase/dbf_head.c | 8 | ||||
-rw-r--r-- | ext/dbase/dbf_misc.c | 7 |
2 files changed, 5 insertions, 10 deletions
diff --git a/ext/dbase/dbf_head.c b/ext/dbase/dbf_head.c index 42935c2ea4..9c9363dfbb 100644 --- a/ext/dbase/dbf_head.c +++ b/ext/dbase/dbf_head.c @@ -215,7 +215,7 @@ void put_dbf_info(dbhead_t *dbh) int fcnt; if ((cp = db_cur_date(NULL))) { - strncpy(dbh->db_date, cp, 8); + strlcpy(dbh->db_date, cp, 8); free(cp); } put_dbf_head(dbh); @@ -232,16 +232,16 @@ char *get_dbf_f_fmt(dbfield_t *dbf) /* build the field format for printf */ switch (dbf->db_type) { case 'C': - sprintf(format, "%%-%ds", dbf->db_flen); + snprintf(format, sizeof(format), "%%-%ds", dbf->db_flen); break; case 'N': case 'L': case 'D': case 'F': - sprintf(format, "%%%ds", dbf->db_flen); + snprintf(format, sizeof(format), "%%%ds", dbf->db_flen); break; case 'M': - strcpy(format, "%s"); + strlcpy(format, "%s", sizeof(format)); break; default: return NULL; diff --git a/ext/dbase/dbf_misc.c b/ext/dbase/dbf_misc.c index ad17bd4e3f..d572783964 100644 --- a/ext/dbase/dbf_misc.c +++ b/ext/dbase/dbf_misc.c @@ -114,12 +114,7 @@ void db_set_date(char *cp, int year, int month, int day) month = 0; if (day > 31) day = 0; - sprintf(cp, "%d", year); - cp[4] = month / 10 + '0'; - cp[5] = month % 10 + '0'; - cp[6] = day / 10 + '0'; - cp[7] = day % 10 + '0'; - cp[8] = 0; + snprintf(cp, 9, "%04d%02d%02d", year, month, day); } int db_date_year(char *cp) |