summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2014-11-04 21:58:44 -0800
committerStanislav Malyshev <stas@php.net>2014-11-11 16:33:02 -0800
commit1b143f4033d65141cdfc0615bd7e95d4b88b3f6f (patch)
treee021668f5f121fcffba67450132b92f3c657393a
parent4571cc2195dfba340c39952fa3cbb545c5d41f0e (diff)
downloadphp-git-1b143f4033d65141cdfc0615bd7e95d4b88b3f6f.tar.gz
fix loop - size_t is unsigned so can not be negative
-rw-r--r--ext/standard/ftp_fopen_wrapper.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
index d6eb3b8fbc..ab75da713c 100644
--- a/ext/standard/ftp_fopen_wrapper.c
+++ b/ext/standard/ftp_fopen_wrapper.c
@@ -644,11 +644,10 @@ static size_t php_ftp_dirstream_read(php_stream *stream, char *buf, size_t count
efree(basename);
/* Trim off trailing whitespace characters */
- tmp_len--;
- while (tmp_len >= 0 &&
- (ent->d_name[tmp_len] == '\n' || ent->d_name[tmp_len] == '\r' ||
- ent->d_name[tmp_len] == '\t' || ent->d_name[tmp_len] == ' ')) {
- ent->d_name[tmp_len--] = '\0';
+ while (tmp_len > 0 &&
+ (ent->d_name[tmp_len - 1] == '\n' || ent->d_name[tmp_len - 1] == '\r' ||
+ ent->d_name[tmp_len - 1] == '\t' || ent->d_name[tmp_len - 1] == ' ')) {
+ ent->d_name[--tmp_len] = '\0';
}
return sizeof(php_stream_dirent);