diff options
author | Theodore Tso <tytso@mit.edu> | 1999-01-02 06:38:49 +0000 |
---|---|---|
committer | Theodore Tso <tytso@mit.edu> | 1999-01-02 06:38:49 +0000 |
commit | 760476bccf98912ae811cab3ccad2d173d62c940 (patch) | |
tree | 8f7578be7f0a5bf600093c9ecd1f95c0748a7942 /src/util/profile | |
parent | 684ac5c334c03708895ab38e9a5969ef2f10ef15 (diff) | |
download | krb5-760476bccf98912ae811cab3ccad2d173d62c940.tar.gz krb5-760476bccf98912ae811cab3ccad2d173d62c940.tar.xz krb5-760476bccf98912ae811cab3ccad2d173d62c940.zip |
prof_tree.c (profile_node_iterator): Make sure the pointer to the
iterator function is non-NULL before checking the magic value.
prof_file.c (profile_open_file): Add ability to parse filenames that
begin with "~/" and substitute it with "$HOME/".
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11096 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/profile')
-rw-r--r-- | src/util/profile/ChangeLog | 11 | ||||
-rw-r--r-- | src/util/profile/prof_file.c | 16 | ||||
-rw-r--r-- | src/util/profile/prof_tree.c | 2 |
3 files changed, 26 insertions, 3 deletions
diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index 554357a58..035911559 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,14 @@ +1998-12-31 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * prof_tree.c (profile_node_iterator): Make sure the pointer to + the iterator function is non-NULL before checking the + magic value. + +1998-12-15 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * prof_file.c (profile_open_file): Add ability to parse filenames + that begin with "~/" and substitute it with "$HOME/". + 1998-12-04 Theodore Ts'o <tytso@rsts-11.mit.edu> * prof_get.c: Add new public profile_iterator functions for diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c index 070cbeffc..fde687482 100644 --- a/src/util/profile/prof_file.c +++ b/src/util/profile/prof_file.c @@ -29,17 +29,29 @@ errcode_t profile_open_file(filename, ret_prof) { prf_file_t prf; errcode_t retval; + char *home_env = 0; + int len; prf = malloc(sizeof(struct _prf_file_t)); if (!prf) return ENOMEM; memset(prf, 0, sizeof(struct _prf_file_t)); - prf->filename = malloc(strlen(filename)+1); + len = strlen(filename)+1; + if (filename[0] == '~' && filename[1] == '/') { + home_env = getenv("HOME"); + if (home_env) + len += strlen(home_env); + } + prf->filename = malloc(len); if (!prf->filename) { free(prf); return ENOMEM; } - strcpy(prf->filename, filename); + if (home_env) { + strcpy(prf->filename, home_env); + strcat(prf->filename, filename+1); + } else + strcpy(prf->filename, filename); prf->magic = PROF_MAGIC_FILE; retval = profile_update_file(prf); diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index ddfa08f44..e8257c826 100644 --- a/src/util/profile/prof_tree.c +++ b/src/util/profile/prof_tree.c @@ -441,7 +441,7 @@ errcode_t profile_node_iterator(iter_p, ret_node, ret_name, ret_value) errcode_t retval; int skip_num = 0; - if (iter->magic != PROF_MAGIC_ITERATOR) + if (!iter || iter->magic != PROF_MAGIC_ITERATOR) return PROF_MAGIC_ITERATOR; /* * If the file has changed, then the node pointer is invalid, |