Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge modified --with-rsh patch: we now determine the default
[rsync/rsync.git]
/
popt
/
poptconfig.c
diff --git
a/popt/poptconfig.c
b/popt/poptconfig.c
index
7a1a4c2
..
eb76941
100644
(file)
--- a/
popt/poptconfig.c
+++ b/
popt/poptconfig.c
@@
-55,8
+55,8
@@
static void configLine(poptContext con, char * line) {
}
int poptReadConfigFile(poptContext con, const char * fn) {
}
int poptReadConfigFile(poptContext con, const char * fn) {
- char * file, * chptr, * end;
- char * buf, * dst;
+ char * file
=NULL
, * chptr, * end;
+ char * buf
=NULL
, * dst;
int fd, rc;
int fileLength;
int fd, rc;
int fileLength;
@@
-71,16
+71,17
@@
int poptReadConfigFile(poptContext con, const char * fn) {
fileLength = lseek(fd, 0, SEEK_END);
(void) lseek(fd, 0, 0);
fileLength = lseek(fd, 0, SEEK_END);
(void) lseek(fd, 0, 0);
- file =
alloca
(fileLength + 1);
+ file =
malloc
(fileLength + 1);
if (read(fd, file, fileLength) != fileLength) {
rc = errno;
close(fd);
errno = rc;
if (read(fd, file, fileLength) != fileLength) {
rc = errno;
close(fd);
errno = rc;
+ if (file) free(file);
return POPT_ERROR_ERRNO;
}
close(fd);
return POPT_ERROR_ERRNO;
}
close(fd);
- dst = buf =
alloca
(fileLength + 1);
+ dst = buf =
malloc
(fileLength + 1);
chptr = file;
end = (file + fileLength);
chptr = file;
end = (file + fileLength);
@@
-111,6
+112,9
@@
int poptReadConfigFile(poptContext con, const char * fn) {
}
}
}
}
+ free(file);
+ free(buf);
+
return 0;
}
return 0;
}
@@
-125,10
+129,11
@@
int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) {
if (getuid() != geteuid()) return 0;
if ((home = getenv("HOME"))) {
if (getuid() != geteuid()) return 0;
if ((home = getenv("HOME"))) {
- fn =
alloca
(strlen(home) + 20);
+ fn =
malloc
(strlen(home) + 20);
strcpy(fn, home);
strcat(fn, "/.popt");
rc = poptReadConfigFile(con, fn);
strcpy(fn, home);
strcat(fn, "/.popt");
rc = poptReadConfigFile(con, fn);
+ free(fn);
if (rc) return rc;
}
if (rc) return rc;
}