File: 0002-Use-get_current_dir_name-over-PATHMAX.patch

package info (click to toggle)
redict 7.3.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 14,896 kB
  • sloc: ansic: 129,309; tcl: 46,053; makefile: 930; python: 815; ruby: 572; sh: 482; javascript: 30
file content (35 lines) | stat: -rw-r--r-- 1,144 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From: Chris Lamb <lamby@debian.org>
Date: Wed, 24 Jan 2018 22:06:35 +1100
Subject: Use get_current_dir_name over PATHMAX, etc.
Forwarded: not-needed

---
 src/rdb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/src/rdb.c
+++ b/src/rdb.c
@@ -1505,7 +1505,6 @@
 /* Save the DB on disk. Return C_ERR on error, C_OK on success. */
 int rdbSave(int req, char *filename, rdbSaveInfo *rsi, int rdbflags) {
     char tmpfile[256];
-    char cwd[MAXPATHLEN]; /* Current working dir path for error messages. */

     startSaving(rdbflags);
     snprintf(tmpfile,256,"temp-%d.rdb", (int) getpid());
@@ -1520,6 +1520,6 @@
     if (rename(tmpfile,filename) == -1) {
         char *str_err = strerror(errno);
-        char *cwdp = getcwd(cwd,MAXPATHLEN);
+        char *cwdp = get_current_dir_name();
         serverLog(LL_WARNING,
             "Error moving temp DB file %s on the final "
             "destination %s (in server root dir %s): %s",
@@ -1529,6 +1528,7 @@
             str_err);
         unlink(tmpfile);
         stopSaving(0);
+        zfree(cwdp);
         return C_ERR;
     }
     if (fsyncFileDir(filename) != 0) {