Blame SOURCES/0021-packet-add-sss_packet_set_body.patch

8ad293
From 3b0e48c33c6b43688ff46fed576266cfe6362595 Mon Sep 17 00:00:00 2001
8ad293
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
8ad293
Date: Thu, 8 Oct 2020 13:25:17 +0200
8ad293
Subject: [PATCH 21/27] packet: add sss_packet_set_body
8ad293
8ad293
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
8ad293
Reviewed-by: Sumit Bose <sbose@redhat.com>
8ad293
---
8ad293
 src/responder/common/responder_packet.c | 19 +++++++++++++++++++
8ad293
 src/responder/common/responder_packet.h |  5 +++++
8ad293
 2 files changed, 24 insertions(+)
8ad293
8ad293
diff --git a/src/responder/common/responder_packet.c b/src/responder/common/responder_packet.c
8ad293
index ab15b1dac..f56d92276 100644
8ad293
--- a/src/responder/common/responder_packet.c
8ad293
+++ b/src/responder/common/responder_packet.c
8ad293
@@ -302,6 +302,25 @@ void sss_packet_get_body(struct sss_packet *packet, uint8_t **body, size_t *blen
8ad293
     *blen = sss_packet_get_len(packet) - SSS_NSS_HEADER_SIZE;
8ad293
 }
8ad293
 
8ad293
+errno_t sss_packet_set_body(struct sss_packet *packet,
8ad293
+                            uint8_t *body,
8ad293
+                            size_t blen)
8ad293
+{
8ad293
+    uint8_t *pbody;
8ad293
+    size_t plen;
8ad293
+    errno_t ret;
8ad293
+
8ad293
+    ret = sss_packet_grow(packet, blen);
8ad293
+    if (ret != EOK) {
8ad293
+        return ret;
8ad293
+    }
8ad293
+
8ad293
+    sss_packet_get_body(packet, &pbody, &plen);
8ad293
+    memcpy(pbody, body, blen);
8ad293
+
8ad293
+    return EOK;
8ad293
+}
8ad293
+
8ad293
 void sss_packet_set_error(struct sss_packet *packet, int error)
8ad293
 {
8ad293
     SAFEALIGN_SETMEM_UINT32(packet->buffer + SSS_PACKET_ERR_OFFSET, error,
8ad293
diff --git a/src/responder/common/responder_packet.h b/src/responder/common/responder_packet.h
8ad293
index afceb4aae..509a22a9a 100644
8ad293
--- a/src/responder/common/responder_packet.h
8ad293
+++ b/src/responder/common/responder_packet.h
8ad293
@@ -42,4 +42,9 @@ uint32_t sss_packet_get_status(struct sss_packet *packet);
8ad293
 void sss_packet_get_body(struct sss_packet *packet, uint8_t **body, size_t *blen);
8ad293
 void sss_packet_set_error(struct sss_packet *packet, int error);
8ad293
 
8ad293
+/* Grow packet and set its body. */
8ad293
+errno_t sss_packet_set_body(struct sss_packet *packet,
8ad293
+                            uint8_t *body,
8ad293
+                            size_t blen);
8ad293
+
8ad293
 #endif /* __SSSSRV_PACKET_H__ */
8ad293
-- 
8ad293
2.21.3
8ad293