Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pam/internal/gdm/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ func (msg *jsonProtoMessage) release() {
return
}

C.free(unsafe.Pointer(msg.json))
C.free(unsafe.Pointer(msg))
C.gdm_custom_json_request_free((*C.GdmPamExtensionJSONProtocol)(msg))
}

func (msg *jsonProtoMessage) protoName() string {
Expand Down
6 changes: 6 additions & 0 deletions pam/internal/gdm/extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ gdm_custom_json_request_is_valid_authd (GdmPamExtensionJSONProtocol *request)

return strncmp (request->protocol_name, JSON_PROTO_NAME, sizeof (request->protocol_name)) == 0;
}

static inline void
gdm_custom_json_request_free (GdmPamExtensionJSONProtocol *message)
{
GDM_PAM_EXTENSION_CUSTOM_JSON_RESPONSE_FREE (message);
}
9 changes: 9 additions & 0 deletions pam/internal/gdm/extensions/gdm-custom-json-pam-extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,12 @@ typedef struct {

#define GDM_PAM_EXTENSION_REPLY_TO_CUSTOM_JSON_RESPONSE(reply) \
((GdmPamExtensionJSONProtocol *) (void *) reply->resp)

#define GDM_PAM_EXTENSION_CUSTOM_JSON_RESPONSE_FREE(response) \
{ \
if ((response)->json != NULL) { \
gdm_pam_extension_zero_buffer ((response)->json, strlen ((response)->json)); \
free ((response)->json); \
} \
free (response); \
}
Comment on lines +67 to +74
21 changes: 21 additions & 0 deletions pam/internal/gdm/extensions/gdm-pam-extensions-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,31 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <limits.h>
Comment on lines 29 to 32

#include <security/pam_appl.h>

#if (defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25)) && \
(defined(_GNU_SOURCE) || defined(_DEFAULT_SOURCE))) || \
defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)

#define gdm_pam_extension_zero_buffer(s, n) do { \
explicit_bzero((s), (n)); \
} while(0)

#else

#define gdm_pam_extension_zero_buffer(s, n) do { \
memset((s), 0, (n)); \
/* Memory barrier to prevent the compiler from erasing the memset */ \
__asm__ __volatile__ ("" : : "r"(s) : "memory"); \
} while(0)

#endif

typedef struct {
uint32_t length;

Expand Down
Loading