Blame SOURCES/0013-negcache_files-got-rid-of-large-array-on-stack.patch

5fca41
From 921a949f6aa8170f851483e4d5763b3e8fb5d5c9 Mon Sep 17 00:00:00 2001
5fca41
From: Alexey Tikhonov <atikhono@redhat.com>
5fca41
Date: Fri, 22 Mar 2019 14:21:00 +0100
5fca41
Subject: [PATCH 13/15] negcache_files: got rid of large array on stack
5fca41
5fca41
Removed large buffer from function stack.
5fca41
It is safe to use single (static) global buffer since:
5fca41
1) Responders are single threaded
5fca41
2) Code doesn't use content of this buffer anyway
5fca41
5fca41
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
5fca41
(cherry picked from commit 8e6656c974ac05bb52607014bb4c30b87f4abd8b)
5fca41
5fca41
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
5fca41
---
5fca41
 src/responder/common/negcache_files.c | 13 +++++--------
5fca41
 1 file changed, 5 insertions(+), 8 deletions(-)
5fca41
5fca41
diff --git a/src/responder/common/negcache_files.c b/src/responder/common/negcache_files.c
5fca41
index 85a7065a4..f22796a0c 100644
5fca41
--- a/src/responder/common/negcache_files.c
5fca41
+++ b/src/responder/common/negcache_files.c
5fca41
@@ -24,12 +24,12 @@
5fca41
 #include "responder/common/negcache_files.h"
5fca41
 
5fca41
 #define BUFFER_SIZE 16384
5fca41
+static char s_nss_buffer[BUFFER_SIZE];
5fca41
 
5fca41
 bool is_user_local_by_name(const struct sss_nss_ops *ops, const char *name)
5fca41
 {
5fca41
     struct passwd pwd = { 0 };
5fca41
     int errnop;
5fca41
-    char buffer[BUFFER_SIZE];
5fca41
     enum nss_status ret;
5fca41
     char *shortname = NULL;
5fca41
     int parse_ret;
5fca41
@@ -39,7 +39,7 @@ bool is_user_local_by_name(const struct sss_nss_ops *ops, const char *name)
5fca41
         return false;
5fca41
     }
5fca41
 
5fca41
-    ret = ops->getpwnam_r(shortname, &pwd, buffer, BUFFER_SIZE, &errnop);
5fca41
+    ret = ops->getpwnam_r(shortname, &pwd, s_nss_buffer, BUFFER_SIZE, &errnop);
5fca41
     talloc_free(shortname);
5fca41
     if (ret == NSS_STATUS_SUCCESS) {
5fca41
         DEBUG(SSSDBG_TRACE_FUNC, "User %s is a local user\n", name);
5fca41
@@ -53,10 +53,9 @@ bool is_user_local_by_uid(const struct sss_nss_ops *ops, uid_t uid)
5fca41
 {
5fca41
     struct passwd pwd = { 0 };
5fca41
     int errnop;
5fca41
-    char buffer[BUFFER_SIZE];
5fca41
     enum nss_status ret;
5fca41
 
5fca41
-    ret = ops->getpwuid_r(uid, &pwd, buffer, BUFFER_SIZE, &errnop);
5fca41
+    ret = ops->getpwuid_r(uid, &pwd, s_nss_buffer, BUFFER_SIZE, &errnop);
5fca41
     if (ret == NSS_STATUS_SUCCESS) {
5fca41
         DEBUG(SSSDBG_TRACE_FUNC,
5fca41
               "User with UID %"SPRIuid" is a local user\n", uid);
5fca41
@@ -70,7 +69,6 @@ bool is_group_local_by_name(const struct sss_nss_ops *ops, const char *name)
5fca41
 {
5fca41
     struct group grp = { 0 };
5fca41
     int errnop;
5fca41
-    char buffer[BUFFER_SIZE];
5fca41
     enum nss_status ret;
5fca41
     char *shortname = NULL;
5fca41
     int parse_ret;
5fca41
@@ -80,7 +78,7 @@ bool is_group_local_by_name(const struct sss_nss_ops *ops, const char *name)
5fca41
         return false;
5fca41
     }
5fca41
 
5fca41
-    ret = ops->getgrnam_r(shortname, &grp, buffer, BUFFER_SIZE, &errnop);
5fca41
+    ret = ops->getgrnam_r(shortname, &grp, s_nss_buffer, BUFFER_SIZE, &errnop);
5fca41
     talloc_free(shortname);
5fca41
     if (ret == NSS_STATUS_SUCCESS) {
5fca41
         DEBUG(SSSDBG_TRACE_FUNC, "Group %s is a local group\n", name);
5fca41
@@ -94,10 +92,9 @@ bool is_group_local_by_gid(const struct sss_nss_ops *ops, uid_t gid)
5fca41
 {
5fca41
     struct group grp = { 0 };
5fca41
     int errnop;
5fca41
-    char buffer[BUFFER_SIZE];
5fca41
     enum nss_status ret;
5fca41
 
5fca41
-    ret = ops->getgrgid_r(gid, &grp, buffer, BUFFER_SIZE, &errnop);
5fca41
+    ret = ops->getgrgid_r(gid, &grp, s_nss_buffer, BUFFER_SIZE, &errnop);
5fca41
     if (ret == NSS_STATUS_SUCCESS) {
5fca41
         DEBUG(SSSDBG_TRACE_FUNC,
5fca41
               "Group with GID %"SPRIgid" is a local group\n", gid);
5fca41
-- 
5fca41
2.19.1
5fca41