summaryrefslogtreecommitdiffstats
path: root/debian/patches/0003-Use-get_current_dir_name-over-PATHMAX.patch
blob: 50aff3d9d14e9f43f4a37c683ddf9dd8d3b3f9f3 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
From: Chris Lamb <lamby@debian.org>
Date: Wed, 24 Jan 2018 22:06:35 +1100
Subject: Use get_current_dir_name over PATHMAX, etc.

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

diff --git a/src/rdb.c b/src/rdb.c
index ed30b65..a2d8aec 100644
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -1443,7 +1443,6 @@ werr: /* Write error. */
 }
 
 static int rdbSaveInternal(int req, const char *filename, rdbSaveInfo *rsi, int rdbflags) {
-    char cwd[MAXPATHLEN]; /* Current working dir path for error messages. */
     rio rdb;
     int error = 0;
     int saved_errno;
@@ -1453,7 +1452,7 @@ static int rdbSaveInternal(int req, const char *filename, rdbSaveInfo *rsi, int
     if (!fp) {
         saved_errno = errno;
         char *str_err = strerror(errno);
-        char *cwdp = getcwd(cwd,MAXPATHLEN);
+        char *cwdp = get_current_dir_name();
         serverLog(LL_WARNING,
             "Failed opening the temp RDB file %s (in server root dir %s) "
             "for saving: %s",
@@ -1515,7 +1514,6 @@ int rdbSaveToFile(const char *filename) {
 /* 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_NONE);
     snprintf(tmpfile,256,"temp-%d.rdb", (int) getpid());
@@ -1529,7 +1527,7 @@ int rdbSave(int req, char *filename, rdbSaveInfo *rsi, int rdbflags) {
      * if the generate DB file is ok. */
     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",