From 199059d268d2c8a74376f2e82e38881b156cb0e6 Mon Sep 17 00:00:00 2001 From: Daniel Ottavio Date: Sun, 9 Oct 2005 22:24:12 +0000 Subject: [PATCH] * amd/info_nis.c (nis_search): Bug fix for bugzilla #428; make sure that sun_entry2amd() is not called when yp_match() returns an error, this is done by checking that 'res' is 0. Bug fix (same BZ#); free the output allocated by yp_match() instead of freeing the return value of sun_entry2amd(). * amd/sun_map.c (sun_entry2amd): Fix a comment. --- ChangeLog | 10 ++++++++++ amd/info_nis.c | 8 ++++++-- amd/sun_map.c | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3506b1..1f6c458 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-10-09 Daniel P. Ottavio + + * amd/info_nis.c (nis_search): Bug fix for bugzilla #428; make + sure that sun_entry2amd() is not called when yp_match() returns an + error, this is done by checking that 'res' is 0. Bug fix (same + BZ#); free the output allocated by yp_match() instead of freeing + the return value of sun_entry2amd(). + + * amd/sun_map.c (sun_entry2amd): Fix a comment. + 2005-10-09 Erez Zadok * README.sun2amd: place holder. diff --git a/amd/info_nis.c b/amd/info_nis.c index af17bab..fb93f3a 100644 --- a/amd/info_nis.c +++ b/amd/info_nis.c @@ -303,10 +303,14 @@ nis_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) * Lookup key */ res = yp_match(gopt.nis_domain, map, key, strlen(key), pval, &outlen); - if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) { + if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) && res == 0) { char *oldval = *pval; *pval = sun_entry2amd(key, oldval); - XFREE(*pval); /* yp_match malloc's *pval above */ + /* We always need to free the output of the yp_match call. */ + XFREE(oldval); + if (*pval == NULL) { + return -1; /* sun2amd parser error */ + } } /* diff --git a/amd/sun_map.c b/amd/sun_map.c index 846fff9..74ff644 100644 --- a/amd/sun_map.c +++ b/amd/sun_map.c @@ -519,7 +519,7 @@ sun_entry2amd(const char *key, const char *s_entry_str) int ws; struct sun_entry *s_entry = NULL; - /* For now the key should no be NULL. */ + /* The key should not be NULL. */ if (key == NULL) { plog(XLOG_ERROR,"Sun key value was null"); goto err; -- 2.43.0