Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
sandbox: provide a default handler for PKG_EVENT_SANDBOX_GET_STRING
Baptiste Daroussin committed 1 month ago
commit 5151477a45b22001638563753df7fa180e230126
parent 95a90f1
3 files changed +14 -6
modified libpkg/pkg_event.c
@@ -1018,7 +1018,9 @@ int
pkg_emit_sandbox_get_string(pkg_sandbox_cb call, void *ud, char **str, int64_t *len)
{
	struct pkg_event ev;
-
	int ret;
+

+
	if (_cb == NULL)
+
		return (pkg_handle_sandboxed_get_string(call, str, len, ud));

	ev.type = PKG_EVENT_SANDBOX_GET_STRING;
	ev.e_sandbox_call_str.call = call;
@@ -1026,23 +1028,23 @@ pkg_emit_sandbox_get_string(pkg_sandbox_cb call, void *ud, char **str, int64_t *
	ev.e_sandbox_call_str.result = str;
	ev.e_sandbox_call_str.len = len;

-
	ret = pkg_emit_event(&ev);
-
	return ret;
+
	return (pkg_emit_event(&ev));
}

int
pkg_emit_sandbox_call(pkg_sandbox_cb call, int fd, void *ud)
{
	struct pkg_event ev;
-
	int ret;
+

+
	if (_cb == NULL)
+
		return (pkg_handle_sandboxed_call(call, fd, ud));

	ev.type = PKG_EVENT_SANDBOX_CALL;
	ev.e_sandbox_call.call = call;
	ev.e_sandbox_call.fd = fd;
	ev.e_sandbox_call.userdata = ud;

-
	ret = pkg_emit_event(&ev);
-
	return ret;
+
	return (pkg_emit_event(&ev));
}

void
modified libpkg/pkg_sandbox.c
@@ -161,6 +161,11 @@ pkg_handle_sandboxed_get_string(pkg_sandbox_cb func, char **result, int64_t *len
		} while (r > 0);

		/* Fill the result buffer */
+
		if (off >= allocated_len) {
+
			allocated_len = off + 1;
+
			buf = xrealloc(buf, allocated_len);
+
		}
+
		buf[off] = '\0';
		*len = off;
		*result = buf;
		if (*result == NULL) {
modified tests/Kyuafile.in
@@ -10,5 +10,6 @@ atf_test_program{name='merge'}
atf_test_program{name='checksum'}
atf_test_program{name='deps_formula'}
atf_test_program{name='pkg_jobs_dryrun'}
+
atf_test_program{name='pkg_sandbox'}

include('frontend/Kyuafile')