All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Gyurdiev <ivg2@cornell.edu>
To: SELinux List <SELinux@tycho.nsa.gov>
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
	Joshua Brindle <jbrindle@tresys.com>
Subject: [SEMANAGE] Fix parse_optional_ch
Date: Fri, 10 Feb 2006 16:39:48 -0500	[thread overview]
Message-ID: <43ED0824.4020104@cornell.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 1082 bytes --]

 > Method ivg2: it appears that an seuser with no mls field causes a 
segfault
 > ivg2 how so?
 > ivg2 trace?
 > ivg2 should not happen
 > Method #0  0x00379ad9 in parse_skip_space (handle=0x99336c0, 
info=0xa0526b0) at parse_utils.c:96
 > Method #1  0x00380abd in seuser_parse (handle=0x99336c0, 
info=0xa0526b0, seuser=0xa052638) at seusers_file.c:84
 > Method #2  0x00371d22 in dbase_file_cache (handle=0x99336c0, 
dbase=0x9938198) at database_file.c:101
 > Method #3  0x0037aa6e in semanage_base_merge_components 
(handle=0x99336c0) at policy_components.c:164
 > Method #4  0x00375df9 in semanage_direct_commit (sh=0x99336c0) at 
direct_api.c:512
 > Method #5  0x00378424 in semanage_commit (sh=0x99336c0) at handle.c:227
 > Method #6  0x08049b13 in main (argc=6, argv=0xbff199d4) at semodule.c:361

Joshua please try to reproduce with the following patch applied.
Changelog:
- handle NULL as no match in parse_optional_ch
- do not advance a NULL pointer in parse_optional_ch - that breaks NULL 
check later
- remove NULL check in parse_optional_str - doesn't seem necessary.



[-- Attachment #2: libsemanage.parse_optional_fix.diff --]
[-- Type: text/x-patch, Size: 939 bytes --]

diff -Naurp --exclude-from excludes old/libsemanage/src/parse_utils.c new/libsemanage/src/parse_utils.c
--- old/libsemanage/src/parse_utils.c	2006-01-05 12:49:15.000000000 -0500
+++ new/libsemanage/src/parse_utils.c	2006-02-10 16:33:29.000000000 -0500
@@ -217,23 +217,24 @@ int parse_assert_str(
 }
 
 int parse_optional_ch(parse_info_t* info, const char ch) {
-	if (info->ptr && (*(info->ptr) != ch))
+
+	if (!info->ptr)
 		return STATUS_NODATA;
-	else {
-		info->ptr++;
-		return STATUS_SUCCESS;
-	}
+	if (*(info->ptr) != ch)
+		return STATUS_NODATA;
+		
+	info->ptr++;
+	return STATUS_SUCCESS;
 }
 
 int parse_optional_str(parse_info_t* info, const char* str) {
 	size_t len = strlen(str);
 
-	if (info->ptr && strncmp(info->ptr, str, len))
+	if (strncmp(info->ptr, str, len))
 		return STATUS_NODATA;
-	else {
-		info->ptr += len;
-		return STATUS_SUCCESS;
-	}
+
+	info->ptr += len;
+	return STATUS_SUCCESS;
 }
 
 int parse_fetch_int(

             reply	other threads:[~2006-02-10 21:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-10 21:39 Ivan Gyurdiev [this message]
2006-02-13 15:33 ` [SEMANAGE] Fix parse_optional_ch Stephen Smalley

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=43ED0824.4020104@cornell.edu \
    --to=ivg2@cornell.edu \
    --cc=SELinux@tycho.nsa.gov \
    --cc=jbrindle@tresys.com \
    --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.