diff options
author | brooks <brooks@FreeBSD.org> | 2010-03-11 14:15:42 +0800 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2010-03-11 14:15:42 +0800 |
commit | 5de3103a06c4c0d27f8283d5ce9f77d391d62a93 (patch) | |
tree | 69094ac4f5f6cc91b259daa8f098578860a86b21 /devel/libmsocket | |
parent | 0fdbeaef1b033dade7de097b5b6294beb76a0cee (diff) | |
download | freebsd-ports-gnome-5de3103a06c4c0d27f8283d5ce9f77d391d62a93.tar.gz freebsd-ports-gnome-5de3103a06c4c0d27f8283d5ce9f77d391d62a93.tar.zst freebsd-ports-gnome-5de3103a06c4c0d27f8283d5ce9f77d391d62a93.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.
Diffstat (limited to 'devel/libmsocket')
-rw-r--r-- | devel/libmsocket/Makefile | 1 | ||||
-rw-r--r-- | devel/libmsocket/files/patch-file.c | 55 |
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); |