X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/b348deae3ddbb25802a5b533d91e06832212b48a..1db8b61de7fd31b9c7b02918e6c194255979f030:/popt/poptconfig.c diff --git a/popt/poptconfig.c b/popt/poptconfig.c index 7a1a4c2b..eb769413 100644 --- 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) { - char * file, * chptr, * end; - char * buf, * dst; + char * file=NULL, * chptr, * end; + char * buf=NULL, * dst; 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); - file = alloca(fileLength + 1); + file = malloc(fileLength + 1); if (read(fd, file, fileLength) != fileLength) { rc = errno; close(fd); errno = rc; + if (file) free(file); return POPT_ERROR_ERRNO; } close(fd); - dst = buf = alloca(fileLength + 1); + dst = buf = malloc(fileLength + 1); chptr = file; end = (file + fileLength); @@ -111,6 +112,9 @@ int poptReadConfigFile(poptContext con, const char * fn) { } } + free(file); + free(buf); + return 0; } @@ -125,10 +129,11 @@ int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) { 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); + free(fn); if (rc) return rc; }