Signed-off-by: Stephen Smalley <sds@xxxxxxxxxxxxx> --- libsepol/src/services.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/libsepol/src/services.c b/libsepol/src/services.c index 665fcaa..d2b80b4 100644 --- a/libsepol/src/services.c +++ b/libsepol/src/services.c @@ -1152,22 +1152,16 @@ int hidden sepol_compute_av(sepol_security_id_t ssid, int hidden sepol_string_to_security_class(const char *class_name, sepol_security_class_t *tclass) { - char *class = NULL; - sepol_security_class_t id; - - for (id = 1; id <= policydb->p_classes.nprim; id++) { - class = policydb->p_class_val_to_name[id - 1]; - if (class == NULL) { - ERR(NULL, "could not convert %s to class id", class_name); - return STATUS_ERR; - } - if ((strcmp(class, class_name)) == 0) { - *tclass = id; - return STATUS_SUCCESS; - } + class_datum_t *tclass_datum; + + tclass_datum = hashtab_search(policydb->p_classes.table, + (hashtab_key_t) class_name); + if (!tclass_datum) { + ERR(NULL, "unrecognized class %s", class_name); + return STATUS_ERR; } - ERR(NULL, "unrecognized class %s", class_name); - return -EINVAL; + *tclass = tclass_datum->s.value; + return STATUS_SUCCESS; } /* -- 2.5.5 _______________________________________________ Selinux mailing list Selinux@xxxxxxxxxxxxx To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx. To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.