typedef gid_t (*__libc_getegid)(void);
typedef int (*__libc_getgroups)(int size, gid_t list[]);
+#ifdef HAVE___GETGROUPS_CHK
+typedef int (*__libc___getgroups_chk)(int size, gid_t list[], size_t listlen);
+#endif
typedef int (*__libc_setgroups)(size_t size, const gid_t *list);
#endif
UWRAP_SYMBOL_ENTRY(getegid);
UWRAP_SYMBOL_ENTRY(getgroups);
+#ifdef HAVE___GETGROUPS_CHK
+ UWRAP_SYMBOL_ENTRY(__getgroups_chk);
+#endif
UWRAP_SYMBOL_ENTRY(setgroups);
#ifdef HAVE_SYSCALL
UWRAP_SYMBOL_ENTRY(syscall);
return uwrap.libc.symbols._libc_getgroups.f(size, list);
}
+#ifdef HAVE___GETGROUPS_CHK
+static int libc___getgroups_chk(int size, gid_t list[], size_t listlen)
+{
+ uwrap_bind_symbol_libc(__getgroups_chk);
+
+ return uwrap.libc.symbols._libc___getgroups_chk.f(size,
+ list,
+ listlen);
+}
+#endif /* HAVE___GETGROUPS_CHK */
+
static int libc_setgroups(size_t size, const gid_t *list)
{
uwrap_bind_symbol_libc(setgroups);
return uwrap_getgroups(size, list);
}
+#ifdef HAVE___GETGROUPS_CHK
+static int uwrap___getgroups_chk(int size, gid_t *list, size_t listlen)
+{
+ if (size * sizeof(gid_t) > listlen) {
+ UWRAP_LOG(UWRAP_LOG_DEBUG, "Buffer overflow detected");
+ abort();
+ }
+
+ return uwrap_getgroups(size, list);
+}
+
+int __getgroups_chk(int size, gid_t *list, size_t listlen);
+
+int __getgroups_chk(int size, gid_t *list, size_t listlen)
+{
+ if (!uid_wrapper_enabled()) {
+ return libc___getgroups_chk(size, list, listlen);
+ }
+
+ uwrap_init();
+ return uwrap___getgroups_chk(size, list, listlen);
+}
+#endif /* HAVE___GETGROUPS_CHK */
+
#if (defined(HAVE_SYS_SYSCALL_H) || defined(HAVE_SYSCALL_H)) \
&& (defined(SYS_setreuid) || defined(SYS_setreuid32))
static long int uwrap_syscall (long int sysno, va_list vp)