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

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