* amd/info_nis.c (nis_search): Bug fix for bugzilla #428; make
authorDaniel Ottavio <ottavio@fsl.cs.sunysb.edu>
Sun, 9 Oct 2005 22:24:12 +0000 (22:24 +0000)
committerDaniel Ottavio <ottavio@fsl.cs.sunysb.edu>
Sun, 9 Oct 2005 22:24:12 +0000 (22:24 +0000)
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
amd/info_nis.c
amd/sun_map.c

index f3506b10ce0cb81532c567946e386906ca496ab2..1f6c45859930695469ca9c965f1d649f489d60a3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-10-09  Daniel P. Ottavio  <dottavio@ic.sunysb.edu>
+
+       * 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  <ezk@cs.sunysb.edu>
 
        * README.sun2amd: place holder.
index af17bab71fcffb8cfdd058a5380047ece70c4d06..fb93f3a7661106d9e84c387a3a5f3e9d3949e060 100644 (file)
@@ -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 */
+    }
   }
 
   /*
index 846fff94b1f515658169a40f2b8c46b4247cd8df..74ff64491f0537c03a114043b4b0c89aafaa5f62 100644 (file)
@@ -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;