diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2014-05-16 14:53:43 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2014-05-16 14:54:14 +0000 |
commit | fb23dc2bdafa793b62348813297aa29c563556d9 (patch) | |
tree | 78bad5b79c8a0d8c76bdac6bcddd70280006fb9d /testing/motion/get_current_dir_name.patch | |
parent | 7d3675c98f4433dd1248815e52f2a4fc9d80918a (diff) | |
download | aports-fb23dc2bdafa793b62348813297aa29c563556d9.tar.bz2 aports-fb23dc2bdafa793b62348813297aa29c563556d9.tar.xz |
main/motion: fix various segfaults
Diffstat (limited to 'testing/motion/get_current_dir_name.patch')
-rw-r--r-- | testing/motion/get_current_dir_name.patch | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/motion/get_current_dir_name.patch b/testing/motion/get_current_dir_name.patch new file mode 100644 index 0000000000..d7e3816c2f --- /dev/null +++ b/testing/motion/get_current_dir_name.patch @@ -0,0 +1,46 @@ +The check for get_current_dir_name appears to be broken. you need +set _GNU_SOURCE for it. + +But that triggered other issue with broken ifdefs so we simply avoid +using get_current_dir_name alltogether. + +--- ./conf.c.orig ++++ ./conf.c +@@ -32,16 +32,6 @@ + #include "video.h" + #endif /* BSD */ + +-#ifndef HAVE_GET_CURRENT_DIR_NAME +-char *get_current_dir_name(void) +-{ +- char *buf = malloc(MAXPATHLEN); +- getwd(buf); +- return buf; +-} +-#endif +- +- + #define stripnewline(x) {if ((x)[strlen(x)-1]=='\n') (x)[strlen(x) - 1] = 0;} + + +@@ -1645,18 +1635,17 @@ + } + + if (!fp) { /* Commandline didn't work, try current dir */ +- char *path = NULL; ++ char path[PATH_MAX]; + if (cnt[0]->conf_filename[0]) + motion_log(-1, 1, "Configfile %s not found - trying defaults.", filename); + +- if ((path = get_current_dir_name()) == NULL) { ++ if (getcwd(path, PATH_MAX) == NULL) { + motion_log(LOG_ERR, 1, "Error get_current_dir_name"); + exit(-1); + } + + snprintf(filename, PATH_MAX, "%s/motion.conf", path); + fp = fopen (filename, "r"); +- free(path); + } + + if (!fp) { /* specified file does not exist... try default file */ |