aports/community/rkward/format-security.patch

34 lines
2.1 KiB
Diff

Without this patch, rkward will fail to build from source due to -Werror=format-security.
The problem here is that Rf_warning and Rf_error expect a format string as the first
argument, however, here the first argument is the QByteArray returned by ::fromUtf8
which is implicitly converted to a char*.
We can fix this, by specifying a "%s" format string as the first argument and then
passing the QByteArray as a parameter for this format string.
diff -upr rkward-0.7.5.orig/rkward/rbackend/rkrbackend.cpp rkward-0.7.5/rkward/rbackend/rkrbackend.cpp
--- rkward-0.7.5.orig/rkward/rbackend/rkrbackend.cpp 2024-05-11 10:33:22.354687832 +0200
+++ rkward-0.7.5/rkward/rbackend/rkrbackend.cpp 2024-05-11 10:33:54.493177844 +0200
@@ -945,8 +945,8 @@ SEXP doSubstackCall (SEXP _call, SEXP _a
// For now, for simplicity, assume args are always strings, although possibly nested in lists
auto ret = RKRBackend::this_pointer->handleRequestWithSubcommands(call, RKRSupport::SEXPToNestedStrings(_args));
- if (!ret.warning.isEmpty()) Rf_warning(RKRBackend::fromUtf8(ret.warning)); // print warnings, first, as errors will cause a stop
- if (!ret.error.isEmpty()) Rf_error(RKRBackend::fromUtf8(ret.error));
+ if (!ret.warning.isEmpty()) Rf_warning("%s", RKRBackend::fromUtf8(ret.warning).data()); // print warnings, first, as errors will cause a stop
+ if (!ret.error.isEmpty()) Rf_error("%s", RKRBackend::fromUtf8(ret.error).data());
return RKRSupport::QVariantToSEXP(ret.ret);
}
@@ -957,8 +957,8 @@ SEXP doPlainGenericRequest (SEXP call, S
R_CheckUserInterrupt ();
auto ret = RKRBackend::this_pointer->handlePlainGenericRequest(RKRSupport::SEXPToStringList(call), RKRSupport::SEXPToInt(synchronous));
- if (!ret.warning.isEmpty()) Rf_warning(RKRBackend::fromUtf8(ret.warning)); // print warnings, first, as errors will cause a stop
- if (!ret.error.isEmpty()) Rf_error(RKRBackend::fromUtf8(ret.error));
+ if (!ret.warning.isEmpty()) Rf_warning("%s", RKRBackend::fromUtf8(ret.warning).data()); // print warnings, first, as errors will cause a stop
+ if (!ret.error.isEmpty()) Rf_error("%s", RKRBackend::fromUtf8(ret.error).data());
return RKRSupport::QVariantToSEXP(ret.ret);
}