* [SEPOL] Ordering of ports in compare fn
@ 2006-01-04 21:10 Ivan Gyurdiev
0 siblings, 0 replies; only message in thread
From: Ivan Gyurdiev @ 2006-01-04 21:10 UTC (permalink / raw)
To: SELinux List; +Cc: Stephen Smalley
[-- Attachment #1: Type: text/plain, Size: 400 bytes --]
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
[-- Attachment #2: libsepol.ports_ordering.diff --]
[-- Type: text/x-patch, Size: 829 bytes --]
diff -Naurp --exclude man --exclude-from excludes old/libsepol/src/port_record.c new/libsepol/src/port_record.c
--- old/libsepol/src/port_record.c 2006-01-04 10:47:46.000000000 -0500
+++ new/libsepol/src/port_record.c 2006-01-04 16:05:31.000000000 -0500
@@ -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 */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-01-04 21:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-04 21:10 [SEPOL] Ordering of ports in compare fn Ivan Gyurdiev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.