[gdm/wip/multi-seat-2-30] Use strndup rather than strdup.



commit 1993e35b8202b30762f76a34c1a9afc24bc4076d
Author: Brian Cameron <brian cameron oracle com>
Date:   Thu Jun 21 20:22:09 2012 -0500

    Use strndup rather than strdup.

 daemon/gdm-session-worker.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 13a470b..51bf38c 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -843,11 +843,12 @@ gdm_session_worker_process_pam_message (GdmSessionWorker          *worker,
         }
 
         if (user_answer != NULL) {
-                /* we strdup and g_free to make sure we return malloc'd
-                 * instead of g_malloc'd memory
+                /* we strndup and g_free to make sure we return malloc'd
+                 * instead of g_malloc'd memory.  PAM_MAX_RESP_SIZE includes
+                 * the '\0' terminating character, thus the "-1".
                  */
                 if (res && response_text != NULL) {
-                        *response_text = strdup (user_answer);
+                        *response_text = strndup (user_answer, PAM_MAX_RESP_SIZE-1);
                 }
 
                 memset (user_answer, '\0', strlen (user_answer));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]