44 lines
1.7 KiB
Diff
44 lines
1.7 KiB
Diff
From 1b64c54b8a7f3a0ada0cc52fc74d800a55318112 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Wed, 16 Apr 2025 13:19:17 +0100
|
|
Subject: [PATCH] generator: Fix implementation of FUUID for OCaml functions
|
|
|
|
This was implemented wrongly. In the XDR protocol, UUIDs are fixed
|
|
buffers of length 32. We can just use memcpy to copy from the OCaml
|
|
string to the UUID, but we have to ensure the string length returned
|
|
by OCaml is correct (if not we just assert, it's an internal error).
|
|
|
|
(It didn't even compile before, so we know it was never used).
|
|
|
|
(cherry picked from commit bcd6b3ec3a1038d840e832732b3910f939566436)
|
|
---
|
|
generator/daemon.ml | 6 +++++-
|
|
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/generator/daemon.ml b/generator/daemon.ml
|
|
index 0baa7708..91decf40 100644
|
|
--- a/generator/daemon.ml
|
|
+++ b/generator/daemon.ml
|
|
@@ -606,6 +606,7 @@ let generate_daemon_caml_stubs () =
|
|
#include <string.h>
|
|
#include <inttypes.h>
|
|
#include <errno.h>
|
|
+#include <assert.h>
|
|
|
|
#include <caml/alloc.h>
|
|
#include <caml/callback.h>
|
|
@@ -641,9 +642,12 @@ let generate_daemon_caml_stubs () =
|
|
fun i ->
|
|
pr " v = Field (retv, %d);\n" i;
|
|
function
|
|
- | n, (FString|FDevice|FUUID) ->
|
|
+ | n, (FString|FDevice) ->
|
|
pr " ret->%s = strdup (String_val (v));\n" n;
|
|
pr " if (ret->%s == NULL) return NULL;\n" n
|
|
+ | n, FUUID ->
|
|
+ pr " assert (caml_string_length (v) == sizeof ret->%s);\n" n;
|
|
+ pr " memcpy (ret->%s, String_val (v), sizeof ret->%s);\n" n n
|
|
| n, FBuffer ->
|
|
pr " ret->%s_len = caml_string_length (v);\n" n;
|
|
pr " ret->%s = strdup (String_val (v));\n" n;
|