如何通过 dbus 调用 varargs 函数?
如何通过 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无法以编程方式使用不同数量和类型的参数调用可变参数函数。您可以使用相应的“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 theva_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, becauseprintf
invokes undefined behavior if the format string does not match the arguments. In nearly all real-world situations, this will mean privilege elevation vulns!