aboutsummaryrefslogtreecommitdiff
path: root/devel/libmsocket
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2010-03-11 06:15:42 +0000
committerBrooks Davis <brooks@FreeBSD.org>2010-03-11 06:15:42 +0000
commit16be93eb0af1173b83023d799b6c1834637ca1b0 (patch)
treeaa31ca5b27becd1d75b497df5f2a19ac1a99fad2 /devel/libmsocket
parent52b9d0798e733a8998bb321a3e8ab1be73020798 (diff)
downloadports-16be93eb0af1173b83023d799b6c1834637ca1b0.tar.gz
ports-16be93eb0af1173b83023d799b6c1834637ca1b0.zip
Dynamically size group arrays rather than using the soon to be removed
NGROUPS define. The previous code also under allocated space by a factor of 3 and probably lead to memory corruption.
Notes
Notes: svn path=/head/; revision=250883
Diffstat (limited to 'devel/libmsocket')
-rw-r--r--devel/libmsocket/Makefile1
-rw-r--r--devel/libmsocket/files/patch-file.c55
2 files changed, 56 insertions, 0 deletions
diff --git a/devel/libmsocket/Makefile b/devel/libmsocket/Makefile
index ba8ab4ce8f52..a60f03f34747 100644
--- a/devel/libmsocket/Makefile
+++ b/devel/libmsocket/Makefile
@@ -7,6 +7,7 @@
PORTNAME= libmsocket
PORTVERSION= 0.4
+PORTREVISION= 1
CATEGORIES= devel net
MASTER_SITES= SF/kageki/${PORTNAME}/${PORTNAME}-${PORTVERSION}
diff --git a/devel/libmsocket/files/patch-file.c b/devel/libmsocket/files/patch-file.c
new file mode 100644
index 000000000000..298dd90d06ce
--- /dev/null
+++ b/devel/libmsocket/files/patch-file.c
@@ -0,0 +1,55 @@
+
+$FreeBSD$
+
+--- file.c.orig
++++ file.c
+@@ -171,6 +171,7 @@
+ gid_t l;
+ register unsigned int i;
+ int grpcnt;
++ long ngroups_max;
+
+ if (!fs)
+ {
+@@ -212,13 +213,14 @@
+ return(1);
+ }
+
+- glist = (gid_t *)malloc(NGROUPS + 1);
++ ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1;
++ glist = (gid_t *)malloc(sizeof(gid_t) * ngroups_max);
+ if (!glist)
+ {
+ return(-1);
+ }
+
+- if ((grpcnt = getgroups((NGROUPS + 1), glist)) < 0)
++ if ((grpcnt = getgroups(ngroups_max, glist)) < 0)
+ {
+ free(glist);
+ return(-1);
+@@ -257,6 +259,7 @@
+ gid_t l;
+ register unsigned int i;
+ int grpcnt;
++ long ngroups_max;
+
+ if (!fs)
+ {
+@@ -298,13 +301,14 @@
+ return(1);
+ }
+
+- glist = (gid_t *)malloc(NGROUPS + 1);
++ ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1;
++ glist = (gid_t *)malloc(sizeof(gid_t) * ngroups_max);
+ if (!glist)
+ {
+ return(-1);
+ }
+
+- if ((grpcnt = getgroups((NGROUPS + 1), glist)) < 0)
++ if ((grpcnt = getgroups(ngroups_max, glist)) < 0)
+ {
+ free(glist);
+ return(-1);