diff --git before/src/db.c after/src/db.c index 6675e19..375b220 100644 --- before/src/db.c +++ after/src/db.c @@ -374,18 +374,28 @@ db_line* db_char2line(char** ss, database* db){ num = 0; while (num < line->xattrs->num) { - byte *val = NULL; - size_t vsz = 0; - tval = strtok(NULL, ","); decode_string(tval); line->xattrs->ents[num].key = checked_strdup(tval); tval = strtok(NULL, ","); - val = base64tobyte(tval, strlen(tval), &vsz); - line->xattrs->ents[num].val = val; - line->xattrs->ents[num].vsz = vsz; - - ++num; + if (strcmp(tval,"0") != 0) { + line->xattrs->ents[num].val = decode_base64(tval, strlen(tval), &line->xattrs->ents[num].vsz); + } else { + line->xattrs->ents[num].val = checked_strdup(""); + line->xattrs->ents[num].vsz = 0; + } + if (line->xattrs->ents[num].val == NULL) { + LOG_DB_FORMAT_LINE(LOG_LEVEL_WARNING, "error while reading xattrs for '%s' from database (discarding extended attributes)", line->filename) + for (int j = num; j >= 0 ; --j) { + free(line->xattrs->ents[j].key); + line->xattrs->ents[j].key = NULL; + free(line->xattrs->ents[j].val); + line->xattrs->ents[j].val = NULL; + } + line->xattrs->num = 0; + } else { + ++num; + } } } #endif diff --git before/src/db_file.c after/src/db_file.c index e016e11..505f8af 100644 --- before/src/db_file.c +++ after/src/db_file.c @@ -377,7 +377,7 @@ static int str_xattr(char *str, int n, xattrs_type *xattrs) { enc_key = encode_string(xattr->key); } char *enc_value = encode_base64(xattr->val, xattr->vsz); - m += str_format(str, n + m, ",%s,%s", enc_key?enc_key:xattr->key, enc_value); + m += str_format(str, n + m, ",%s,%s", enc_key?enc_key:xattr->key, enc_value?enc_value:"0"); free(enc_key); free(enc_value); ++xattr; diff --git before/src/util.c after/src/util.c index 2df2c19..edc7453 100644 --- before/src/util.c +++ after/src/util.c @@ -48,7 +48,7 @@ #include "util.h" #include "errorcodes.h" -#define URL_UNSAFE " <>\"#%{}|\\^~[]`@:\033'" +#define URL_UNSAFE " <>\"#%{}|\\^~[]`@:\033'," #define ISPRINT(c) (isascii(c) && isprint(c)) pthread_mutex_t stderr_mutex = PTHREAD_MUTEX_INITIALIZER;