Ticket #42579: patch-daemon-gdm-session-worker.c.diff

File patch-daemon-gdm-session-worker.c.diff, 960 bytes (added by dbevans (David B. Evans), 11 years ago)

Patch from gdm showing replacement of strnlen() on 10.6 and earlier

  • daemon/gdm-session-worker.c

    old new  
    740740        return utf8;
    741741}
    742742
     743#ifdef __APPLE__
     744#include <Availability.h>
     745#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1060
     746static char * strndup (char const *s, size_t n);
     747static size_t strnlen (const char *string, size_t maxlen);
     748
     749static size_t
     750strnlen (const char *string, size_t maxlen)
     751{
     752  const char *end = memchr (string, '\0', maxlen);
     753  return end ? (size_t) (end - string) : maxlen;
     754}
     755
     756static char *
     757strndup (char const *s, size_t n)
     758{
     759  size_t len = strnlen (s, n);
     760  char *new = malloc (len + 1);
     761
     762  if (new == NULL)
     763    return NULL;
     764
     765  new[len] = '\0';
     766  return memcpy (new, s, len);
     767}
     768#endif
     769#endif
    743770static gboolean
    744771gdm_session_worker_process_pam_message (GdmSessionWorker          *worker,
    745772                                        const struct pam_message  *query,