8000 [Issue #364] correctly set null-termination char during tablespace_ma… · postgrespro/pg_probackup@b1442f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit b1442f4

Browse files
committed
[Issue #364] correctly set null-termination char during tablespace_map parsing
1 parent 34741de commit b144
8000
2f4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/dir.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,9 +1160,10 @@ read_tablespace_map(parray *links, const char *backup_dir)
11601160

11611161
path = buf + n;
11621162

1163-
/* Remove newline character at the end of string */
1164-
i = strlen(path) - 1;
1165-
path[i] = '\0';
1163+
/* Remove newline character at the end of string if any */
1164+
i = strcspn(path, "\n");
1165+
if (strlen(path) > i)
1166+
path[i] = '\0';
11661167

11671168
file = pgut_new(pgFile);
11681169
memset(file, 0, sizeof(pgFile));

0 commit comments

Comments
 (0)
0