libscrollkeeper/libscrollkeeper-0.3.14-fix-mkdir-segfault.patch

34 lines
1.2 KiB
Diff
Raw Normal View History

--- libs/database.c.orig 2005-03-17 14:11:01.000000000 -0500
+++ libs/database.c 2005-03-17 14:12:56.000000000 -0500
@@ -56,6 +56,7 @@ static int sk_mkdir(char *path, mode_t o
int sk_mkdir_with_parents(char *fullpath, mode_t options, char outputprefs)
{
char path[1024];
+ char path2[1024];
char slash[]="/";
char delim[]="/";
char *token, *pathcopy;
@@ -69,17 +70,18 @@ int sk_mkdir_with_parents(char *fullpath
delim[0]=slash[0];
while(token != NULL) {
if (strlen(path) == 0 || ((strlen(path) == 1) && (path[0] == slash[0]))) {
- sprintf(path, "%s%s", path, token);
+ sprintf(path2, "%s%s", path, token);
} else {
- sprintf(path, "%s/%s", path, token);
+ sprintf(path2, "%s/%s", path, token);
}
- if (stat(path, &buf) == -1) {
- if (sk_mkdir(path, options, outputprefs) != 0) {
+ if (stat(path2, &buf) == -1) {
+ if (sk_mkdir(path2, options, outputprefs) != 0) {
return 1;
}
}
delim[0]=slash[0];
token = strtok (NULL, delim);
+ strncpy (path, path2, sizeof (path));
}
return 0;