summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup/cmodule.c
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2003-08-26 22:38:58 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2003-08-26 22:38:58 +0000
commitd37c8d059875ac2b87dcfcb4e884d33095e8ff1e (patch)
treeeb0ecb2a2122fcc400d213c569e5acd737b1a6b4 /rdiff-backup/rdiff_backup/cmodule.c
parentedc4d8b221b9c056e153af9309ffd3647d3b1fab (diff)
downloadrdiff-backup-d37c8d059875ac2b87dcfcb4e884d33095e8ff1e.tar.gz
Fixed bug in Gruenbach's code and added test for it
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@405 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/cmodule.c')
-rw-r--r--rdiff-backup/rdiff_backup/cmodule.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/rdiff-backup/rdiff_backup/cmodule.c b/rdiff-backup/rdiff_backup/cmodule.c
index a5f1c65..6fafde7 100644
--- a/rdiff-backup/rdiff_backup/cmodule.c
+++ b/rdiff-backup/rdiff_backup/cmodule.c
@@ -283,23 +283,25 @@ int high_water_alloc(void **buf, size_t *bufsize, size_t newsize)
const char *quote(const char *str)
{
- static char *quoted_str;
- static size_t quoted_str_len;
+ static char *quoted_str = NULL;
+ static size_t quoted_str_len = 0;
const unsigned char *s;
char *q;
- size_t nonpr;
+ size_t nonpr, total_len;
if (!str)
return str;
- for (nonpr = 0, s = (unsigned char *)str; *s != '\0'; s++)
- if (!isprint(*s) || isspace(*s) || *s == '\\' || *s == '=')
- nonpr++;
+ for (nonpr = 0, s = (unsigned char *)str, total_len = 0;
+ *s != '\0'; s++, total_len++) {
+ if (!isprint(*s) || isspace(*s) || *s == '\\' || *s == '=')
+ nonpr++;
+ }
if (nonpr == 0)
return str;
if (high_water_alloc((void **)&quoted_str, &quoted_str_len,
- nonpr * 3 + 1))
+ nonpr * 3 + total_len + 1))
return NULL;
for (s = (unsigned char *)str, q = quoted_str; *s != '\0'; s++) {
if (!isprint(*s) || isspace(*s) || *s == '\\' || *s == '=') {