Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37515644
en ru br
ALT Linux repos
S:1.8.7-alt1
5.0: 1.4.0-alt4
4.1: 1.4.0-alt0.M41.1
4.0: 1.3.7-alt1
3.0: 1.3.1-alt2

Group :: System/Kernel and hardware
RPM: iptables

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: iptables-1.4.0-alt-modprobe.patch
Download


--- iptables-1.4.0/xtables.c
+++ iptables-1.4.0/xtables.c
@@ -77,25 +77,26 @@ static char *get_modprobe(void)
 {
 	int procfile;
 	char *ret;
+	ssize_t count;
 
-#define PROCFILE_BUFSIZ	1024
 	procfile = open(PROC_SYS_MODPROBE, O_RDONLY);
 	if (procfile < 0)
 		return NULL;
 
-	ret = (char *) malloc(PROCFILE_BUFSIZ);
+	ret = malloc(PATH_MAX);
 	if (ret) {
-		memset(ret, 0, PROCFILE_BUFSIZ);
-		switch (read(procfile, ret, PROCFILE_BUFSIZ)) {
-		case -1: goto fail;
-		case PROCFILE_BUFSIZ: goto fail; /* Partial read.  Wierd */
+		count = read(procfile, ret, PATH_MAX);
+		if (count > 0 && count < PATH_MAX)
+		{
+			if (ret[count - 1] == '\n')
+				ret[count - 1] = '\0';
+			else
+				ret[count] = '\0';
+			close(procfile);
+			return ret;
 		}
-		if (ret[strlen(ret)-1]=='\n') 
-			ret[strlen(ret)-1]=0;
-		close(procfile);
-		return ret;
 	}
- fail:
+
 	free(ret);
 	close(procfile);
 	return NULL;
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin