Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
deferred_unlink: fix for very long filenames, fixes #3136
  • Loading branch information
perexg committed Oct 9, 2015
1 parent 69bc9b6 commit 1ffad11
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/utils.c
Expand Up @@ -702,13 +702,20 @@ deferred_unlink(const char *filename, const char *rootdir)
char *s;
size_t l;
int r;
long max;

l = strlen(filename);
s = malloc(l + 9 + 1);
if (s == NULL)
return -ENOMEM;
max = pathconf(filename, _PC_NAME_MAX);
strcpy(s, filename);
strcpy(s + l, ".removing");
if (l + 10 < max) {
s[0] = '.';
strcpy(s + l, ".removing");
} else {
memcpy(s, ".rm.", 4);
}
r = rename(filename, s);
if (r) {
r = -errno;
Expand Down

0 comments on commit 1ffad11

Please sign in to comment.