Skip to contentSkip to conversation

patch for udev and selinux

PATCH Applied Harald Hoyer 2 participants 2 messages Dec 16, 2004

lore
Share & tools
lore
#0 lore raw

Attached patch fixes:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=142713

selinux.h renamed from selinux.h.media +26 -17
@@ -30,31 +30,40 @@
 	FILE *fp;
 	char buf[PATH_MAX];
 	char mediabuf[PATH_MAX];
+	int ret = -1;
 
 	*media = NULL;
 	if (!(mode && S_IFBLK)) {
 		return -1;
 	}
-	snprintf(buf,sizeof(buf), "/proc/ide/%s/media", basename(path));
+
+	snprintf(buf, sizeof(buf), "/proc/ide/%s/media", basename(path));
+
 	fp=fopen(buf,"r");
-	if (fp) {
-		if (fgets(mediabuf,sizeof(mediabuf), fp)) {
-			int size = strlen(mediabuf);
-			while (size-- > 0) {
-				if (isspace(mediabuf[size])) {
-					mediabuf[size]='\0';
-				} else {
-					break;
-				}
-			}
-			*media = strdup(mediabuf);
-			info("selinux_get_media(%s)->%s \n", path, *media);
+	if (!fp)
+		goto out;
+	
+	mediabuf[0] = '\0';
+
+	if (fgets(mediabuf, sizeof(mediabuf), fp) == NULL)
+		goto close_out;
+
+	int size = strlen(mediabuf);
+	while (size-- > 0) {
+		if (isspace(mediabuf[size])) {
+			mediabuf[size]='\0';
+		} else {
+			break;
 		}
-		fclose(fp);
-		return 0;
-	} else {
-		return -1;
 	}
+	*media = strdup(mediabuf);
+	info("selinux_get_media(%s)->%s \n", path, *media);
+	ret = 0;
+
+close_out:
+	fclose(fp);
+out:
+	return ret;
 }
 
 static inline void selinux_setfilecon(char *file, unsigned int mode)
Applied
#1 lore raw
Quoted 2 lines · Harald Hoyer

Attached patch fixes:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id2713

I've applied it to my tree.

Thanks,
Kay

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel