Hi comic, git-am tells me:
Applying: weston-launch: fix incorrect group read in weston_launch_allowed Using index info to reconstruct a base tree... error: patch failed: src/weston-launch.c:113 error: src/weston-launch.c: patch does not apply error: Did you hand edit your patch? It does not apply to blobs recorded in its index. Patch failed at 0001 weston-launch: fix incorrect group read in weston_launch_allowed On Fri, 18 Mar 2016 11:45:24 +0800 comic fans <comicfan...@gmail.com> wrote: > From 6f46060d55c206ba2b98634bff64e9b78b93f125 Mon Sep 17 00:00:00 2001 > From: comic fans <comicfan...@gmail.com> > Date: Fri, 18 Mar 2016 17:56:46 +0800 > Subject: [PATCH] weston-launch: fix incorrect group read in > weston_launch_allowed > > read_groups return array of n gid_t, not NULL terminated . Yes, this fix looks correct. The existing code is not comparing to NULL though, but to (gid_t)0. 0 is usually a valid group, too. > --- > src/weston-launch.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/src/weston-launch.c b/src/weston-launch.c > index b8dfb17..686f6bf 100644 > --- a/src/weston-launch.c > +++ b/src/weston-launch.c > @@ -113,23 +113,22 @@ struct weston_launch { > union cmsg_data { unsigned char b[4]; int fd; }; > > static gid_t * > -read_groups(void) > +read_groups(int * n) Don't add space after unary asterisk. > { > - int n; > gid_t *groups; > > - n = getgroups(0, NULL); > + *n = getgroups(0, NULL); > > - if (n < 0) { > + if (*n < 0) { > fprintf(stderr, "Unable to retrieve groups: %m\n"); > return NULL; > } > > - groups = malloc(n * sizeof(gid_t)); > + groups = malloc(*n * sizeof(gid_t)); > if (!groups) > return NULL; > > - if (getgroups(n, groups) < 0) { > + if (getgroups(*n, groups) < 0) { > fprintf(stderr, "Unable to retrieve groups: %m\n"); > free(groups); > return NULL; > @@ -143,6 +142,7 @@ weston_launch_allowed(struct weston_launch *wl) > struct group *gr; > gid_t *groups; > int i; > + int n; > #ifdef HAVE_SYSTEMD_LOGIN > char *session, *seat; > int err; > @@ -153,9 +153,9 @@ weston_launch_allowed(struct weston_launch *wl) > > gr = getgrnam("weston-launch"); > if (gr) { > - groups = read_groups(); > + groups = read_groups(&n); > if (groups) { > - for (i = 0; groups[i]; ++i) { > + for (i = 0; i<n; ++i) { Use spaces around binary operators. > if (groups[i] == gr->gr_gid) { > free(groups); > return true; Thanks, pq
pgp8SswFK5RxZ.pgp
Description: OpenPGP digital signature
_______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel