Ordering of ports in compare fn
That's strange - I clearly remember writing this patch before, and somehow it got lost. Anyway, it implements an ordered compare function for ports.
Please don't miss the other patches in the two threads above, namely:
- fix for single ports parser (whitespace assert issue)
- fix for the dbase add function (toggle modified flag)
- reorder swig included headers and add missing booleans_active.h
libsepol/src/port_record.c +17 -3
@@ -84,14 +84,28 @@ int sepol_port_compare( sepol_port_t* port, sepol_port_key_t* key) { -/* FIXME: needs to support ordering of ports (-1, 0, 1) */ -if ((port->low == key->low) && (port->high == key->high) && (port->proto == key->proto))return 0 ; -return 1 ; +if (port->low < key->low) +return -1 ; + +else if (key->low < port->low) +return 1 ; + +else if (port->high < key->high) +return -1 ; + +else if (key->high < port->high) +return 1 ; + +else if (port->proto < key->proto) +return -1 ; + +else +return 1 ; }/* Port */