diff options
author | Marcus Boerger <helly@php.net> | 2007-02-24 02:17:47 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2007-02-24 02:17:47 +0000 |
commit | 50ea26760da4e0fcf4980e739e1d0ed520de8d59 (patch) | |
tree | 888a32ce58864f5318a7f1072f8526c6a99212f9 /ext/zip/lib/zip_error_strerror.c | |
parent | 3e262bd36989898ac01224f0a987e79f44d25b31 (diff) | |
download | php-git-50ea26760da4e0fcf4980e739e1d0ed520de8d59.tar.gz |
- Avoid sprintf, even when checked copy'n'paste or changes lead to errors
Diffstat (limited to 'ext/zip/lib/zip_error_strerror.c')
-rw-r--r-- | ext/zip/lib/zip_error_strerror.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/zip/lib/zip_error_strerror.c b/ext/zip/lib/zip_error_strerror.c index f14f7190e6..e6eee081df 100644 --- a/ext/zip/lib/zip_error_strerror.c +++ b/ext/zip/lib/zip_error_strerror.c @@ -54,7 +54,7 @@ _zip_error_strerror(struct zip_error *err) _zip_error_fini(err); if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) { - sprintf(buf, "Unknown error %d", err->zip_err); + snprintf(buf, sizeof(buf), "Unknown error %d", err->zip_err); zs = NULL; ss = buf; } @@ -78,11 +78,11 @@ _zip_error_strerror(struct zip_error *err) if (ss == NULL) return zs; else { - if ((s=(char *)malloc(strlen(ss) - + (zs ? strlen(zs)+2 : 0) + 1)) == NULL) + int l = strlen(ss) + (zs ? strlen(zs)+2 : 0) + 1; + if ((s=(char *)malloc(l)) == NULL) return _zip_err_str[ZIP_ER_MEMORY]; - sprintf(s, "%s%s%s", + snprintf(s, l, "%s%s%s", (zs ? zs : ""), (zs ? ": " : ""), ss); |