如何通过 dbus 调用 varargs 函数?

发布于 2024-11-27 19:00:52 字数 161 浏览 3 评论 0原文

如何通过 dbus 调用 varargs 函数,例如 printf?

服务器是用C语言编写的,客户端是用Python编写的。

我的问题是如何编写 XML 规范文件?以及如何编写我的GObject?

提前致谢。

[我使用 DBus-GLib。]

How to call a varargs function via dbus, like printf?

The server is written in C, the client is written in Python.

My questions are how to write the XML spec file? And how to write my GObject?

Thanks in advance.

[I use DBus-GLib.]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

万劫不复 2024-12-04 19:00:52

无法以编程方式使用不同数量和类型的参数调用可变参数函数。您可以使用相应的“v”函数(vprintf 等),但无法使 va_list 从外部代码传递给它们并通过 DBus 传递。

无论如何,您确实需要重新考虑您的设计。使用不是 100% 由程序控制的格式字符串调用 printf 是不安全的。传递客户端提供的格式字符串是一个灾难性的公式,因为如果格式字符串与参数不匹配,printf 就会调用未定义的行为。在几乎所有现实情况下,这将意味着特权提升漏洞

There is no way to call a variadic function programmatically with varying number and type of arguments. You could use the corresponding "v" functions (vprintf etc.) but there's no way to make the va_list to pass to them from foreign code and pass it over DBus.

In any case you really need to rethink your design. It's unsafe to call printf with a format string that's not 100% controlled by your program. Passing a client-provided format string is a formula for disaster, because printf invokes undefined behavior if the format string does not match the arguments. In nearly all real-world situations, this will mean privilege elevation vulns!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文