aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2005-01-10 18:48:45 +0000
committerJason Woodward2005-01-10 18:48:45 +0000
commitb8aad8541ef7b9bf204062341607f5b23244ce46 (patch)
treec2f3a47f43c13b923b056fab3d4a89e722350bfe /src
parent0caa2dba786f829c440e3d14dfbfabf1ee76b56e (diff)
downloadslapt-get-b8aad8541ef7b9bf204062341607f5b23244ce46.tar.gz
fortified getenv call
Diffstat (limited to 'src')
-rw-r--r--src/package.c4
-rw-r--r--src/package.h1
2 files changed, 4 insertions, 1 deletions
diff --git a/src/package.c b/src/package.c
index 21de938..a85d31d 100644
--- a/src/package.c
+++ b/src/package.c
@@ -441,7 +441,9 @@ struct pkg_list *get_installed_pkgs(void){
init_regex(&uncompressed_size_reg,PKG_LOG_SIZEU_PATTERN);
/* Generate package log directory using ROOT env variable if set */
- root_env_entry = getenv(ROOT_ENV_NAME);
+ if( getenv(ROOT_ENV_NAME) && strlen(getenv(ROOT_ENV_NAME)) < ROOT_ENV_LEN ){
+ root_env_entry = getenv(ROOT_ENV_NAME);
+ }
pkg_log_dirname = calloc(
strlen(PKG_LOG_DIR)+
(root_env_entry ? strlen(root_env_entry) : 0) + 1 ,
diff --git a/src/package.h b/src/package.h
index caf3a05..f8c148c 100644
--- a/src/package.h
+++ b/src/package.h
@@ -28,6 +28,7 @@
#define PKG_LOG_SIZEU_PATTERN "^UNCOMPRESSED PACKAGE SIZE:[ ]{1,}([0-9]{1,}) K$"
#define PKG_LOG_DIR "/var/log/packages"
#define ROOT_ENV_NAME "ROOT"
+#define ROOT_ENV_LEN 255
#define PKG_LOG_PATTERN "^(.*{1,})\\-(.*[\\.\\-].*[\\.\\-].*)"
#define MD5SUM_REGEX "([a-zA-Z0-9]{1,})[ ]{1,}([a-zA-Z0-9\\/._\\-]{1,})\\/(.*{1,})\\-(.*[\\.\\-].*[\\.\\-].*).tgz$"
#define REQUIRED_REGEX "^[ ]{0,}([a-zA-Z0-9\\+_\\-]+)[ ]{0,}([\\<\\=\\>]+){0,}[ ]{0,}([a-zA-Z0-9\\.\\_\\-]+){0,}[ ]{0,}$"