From: Ivan Gyurdiev <ivg2@cornell.edu>
To: SELinux List <SELinux@tycho.nsa.gov>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Subject: [SEPOL] Ordering of ports in compare fn
Date: Wed, 04 Jan 2006 16:10:31 -0500 [thread overview]
Message-ID: <43BC39C7.9030805@cornell.edu> (raw)
[-- 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 */
reply other threads:[~2006-01-04 21:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43BC39C7.9030805@cornell.edu \
--to=ivg2@cornell.edu \
--cc=SELinux@tycho.nsa.gov \
--cc=sds@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.