summaryrefslogtreecommitdiff
path: root/ext/zip/lib/zip_set_file_comment.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2013-12-15 16:55:29 +0800
committerXinchen Hui <laruence@gmail.com>2013-12-15 16:55:29 +0800
commit5eb8d9d70009c0bf9bfbbf511f2713e64dc8ee83 (patch)
tree2480a26e79d85b4b7f2eacb5a2187eb13f029094 /ext/zip/lib/zip_set_file_comment.c
parent10964b78548a5878254f5aa75f4cfdcedb0543bc (diff)
parent904721189ff949c67795ec418f04b67951cbd57b (diff)
downloadphp-git-5eb8d9d70009c0bf9bfbbf511f2713e64dc8ee83.tar.gz
Merge branch 'PHP-5.6' of https://git.php.net/push/php-src into PHP-5.6
Diffstat (limited to 'ext/zip/lib/zip_set_file_comment.c')
-rw-r--r--ext/zip/lib/zip_set_file_comment.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/ext/zip/lib/zip_set_file_comment.c b/ext/zip/lib/zip_set_file_comment.c
index 5e63dc2730..7acd0eb36d 100644
--- a/ext/zip/lib/zip_set_file_comment.c
+++ b/ext/zip/lib/zip_set_file_comment.c
@@ -1,6 +1,6 @@
/*
zip_set_file_comment.c -- set comment for file in archive
- Copyright (C) 2006-2009 Dieter Baron and Thomas Klausner
+ Copyright (C) 2006-2012 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <libzip@nih.at>
@@ -35,38 +35,17 @@
#include <stdlib.h>
+#define _ZIP_COMPILING_DEPRECATED
#include "zipint.h"
-ZIP_EXTERN(int)
-zip_set_file_comment(struct zip *za, zip_uint64_t idx,
- const char *comment, int len)
+ZIP_EXTERN int
+zip_set_file_comment(struct zip *za, zip_uint64_t idx, const char *comment, int len)
{
- char *tmpcom;
-
- if (idx >= za->nentry
- || len < 0 || len > MAXCOMLEN
- || (len > 0 && comment == NULL)) {
- _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
- return -1;
- }
-
- if (ZIP_IS_RDONLY(za)) {
- _zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
- return -1;
+ if (len < 0 || len > ZIP_UINT16_MAX) {
+ _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
+ return -1;
}
-
- if (len > 0) {
- if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL)
- return -1;
- }
- else
- tmpcom = NULL;
-
- free(za->entry[idx].ch_comment);
- za->entry[idx].ch_comment = tmpcom;
- za->entry[idx].ch_comment_len = len;
-
- return 0;
+ return zip_file_set_comment(za, idx, comment, (zip_uint16_t)len, 0);
}