On Sat, 19 Dec 2009 04:28:52 +0100, Jordan Vaughan <jordan.vaug...@sun.com> 
wrote:

> I expanded my webrev to include my fix for
>
> 6910339 zonecfg coredumps with badly formed 'select net defrouter'
>
> I need someone to review my changes.  The webrev is still accessible via
>
> http://cr.opensolaris.org/~flippedb/onnv-zone2

Hey Jordan looks good to me modulo this in zonecfg_lookup_nwif()

         size_t addrspec;                /* nonzero if tabptr has IP addr */
         size_t physspec;                /* nonzero if tabptr has interface */
+        size_t defrouterspec;           /* nonzero if tabptr has def. router */
 
         if (tabptr == NULL)
                 return (Z_INVAL);
 
+         * zone_nwif_address, zone_nwif_physical, and zone_nwif_defrouter are
+         * arrays, so no NULL checks are necessary.
          */
         addrspec = strlen(tabptr->zone_nwif_address);
         physspec = strlen(tabptr->zone_nwif_physical);
-        assert(addrspec > 0 || physspec > 0);
+        defrouterspec = strlen(tabptr->zone_nwif_defrouter);
+        assert(addrspec != 0 || physspec != 0 || defrouterspec != 0);
 

so we do consider any of them being 0 a fault given the assert(), fine, but yet
we do check for this again inside the loop:

+                if (physspec != 0 && (fetchprop(cur, DTD_ATTR_PHYSICAL,
+                    physical, sizeof (physical)) != Z_OK ||
+                    strcmp(tabptr->zone_nwif_physical, physical) != 0))
+                        continue;
+                if (addrspec != 0 && (fetchprop(cur, DTD_ATTR_ADDRESS, address,
+                    sizeof (address)) != Z_OK ||
+                    !zonecfg_same_net_address(tabptr->zone_nwif_address,
+                    address)))
+                        continue;
+                if (defrouterspec != 0 && (fetchprop(cur, DTD_ATTR_DEFROUTER,
+                    address, sizeof (address)) != Z_OK ||
+                    !zonecfg_same_net_address(tabptr->zone_nwif_defrouter,
+                    address)))
+                        continue;

a good argument could probably be made to turn this assert into a real
check and return Z_INVAL for any of those 3 being 0 and get rid of
the checks inside the xml parsing loop ?

cheers
frankB

_______________________________________________
zones-discuss mailing list
zones-discuss@opensolaris.org

Reply via email to