Group :: System/Kernel and hardware
RPM: iptables
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: iptables-1.3.1-alt-modprobe.patch
Download
Download
--- iptables-1.3.1/iptables.c.modprobe 2005-02-19 22:19:17 +0300
+++ iptables-1.3.1/iptables.c 2005-03-15 23:34:29 +0300
@@ -1679,25 +1679,23 @@
{
int procfile;
char *ret;
+ int 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';
+ 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;
--- iptables-1.3.1/ip6tables.c.modprobe 2005-02-19 22:19:17 +0300
+++ iptables-1.3.1/ip6tables.c 2005-03-15 23:35:10 +0300
@@ -1583,25 +1583,23 @@
{
int procfile;
char *ret;
+ int count;
-#define PROCFILE_BUFSIZ 1024
procfile = open(PROC_SYS_MODPROBE, O_RDONLY);
if (procfile < 0)
return NULL;
- ret = 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';
+ 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;