New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GCC 8 format-truncation error #126
Comments
Hi This is also an issue for us on our development project, which has broken our CI an resulted in us pinning our repo manifests to get over the problem. Any escalation on priority to fix this would be much appreciated:
|
Hi, I don't have GCC 8.1.1 so I can't reproduce the issue (I'm running Ubuntu 16.04.4). I suspect increasing the size of |
Why 11? 255-246=9, which appears to assume that all preceding If needed, a Tumbleweed rootfs for chroot can be found here: https://download.opensuse.org/ports/aarch64/tumbleweed/images/openSUSE-Tumbleweed-ARM-JeOS.aarch64-rootfs.aarch64-Current.tar.xz (it may need a |
I should have said 10 = 266 - 256. Any chance you could try the following patch? diff --git a/libteec/src/teec_trace.c b/libteec/src/teec_trace.c
index 78b79d6..54a53ec 100644
--- a/libteec/src/teec_trace.c
+++ b/libteec/src/teec_trace.c
@@ -73,7 +73,7 @@ int _dprintf(const char *function, int flen, int line, int level,
const char *prefix, const char *fmt, ...)
{
char raw[MAX_PRINT_SIZE];
- char prefixed[MAX_PRINT_SIZE];
+ char prefixed[MAX_PRINT_SIZE + 10];
char *to_print = NULL;
const char *func;
int err; |
That will not fix this error. For our openSUSE purposes the problem is default for Werror, which I just disabled -> solved as warning only for us. |
@scarabeusiv do you have a patch that we could use? We could use it temporarily before (@jforissier) a better fix is tested. |
No, it's a sed script in the spec file: https://build.opensuse.org/package/view_file/hardware:boot/optee-client/optee-client.spec?expand=1 |
@jforissier, I tried the patch and it didn't work, because the old length was still being passed into snprintf. so this patch worked:
Of course, it's not nice to add 10 to two places, and saying as the define is MAX_PRINT_SIZE, we probably shouldn't be adding to it. This patch looked simpler to me:
However, 10 probably isn't the correct value anyway. The prefix string could potentially be longer than 10 characters. It's likely to be 13 or more characters, based on this format string But trace_level_strings can be 0 or 3 chars long; thread id is likely to be many characters long, potentially up to 11 character for a 32-bit int or 20 characters for a 64 bit int; prefix and func are be variable length strings passed in, so it might be better to use %{value}s to limit their length and take that into account; then there's the final line int, which again could be up to 20 characters long. That makes 3 + 20 + prefix string + func string + 20 + 3 spaces + 3 colons + 2 brackets == 51 + prefix string + func string. So how about this instead?
I'm happy to submit a patch if you tell me how you'd prefer to do it? |
Please find attached a fix for this problem. I can submit as PR if given an indication its acceptable. Its been through the following testing:
See also: 0001-Fix-for-teec_trace.c-snprintf-Werror-format-truncati.patch.txt |
Both Simon and my fixes build OK for me with GCC8 in my Yocto environment. As per xtest issue 296, xtest is giving a segmentation fault before outputting anything. I believe this is unrelated to either solution and both work fine when built with GCC 7. |
Thanks for the patches. I have chosen a more drastic approach in #128. Please check it out and let me know if it works for you. |
Fix for GCC 8.1, as described at OP-TEE/optee_client#126 Final fix to be provided via upstream and meta-linaro. Signed-off-by: Ricardo Salveti <ricardo@opensourcefoundries.com>
This commit applies a W/A patch from optee upstream to fix GCC 8 format-truncation errors. [1] OP-TEE/optee_client#126 Signed-off-by: Thuy Tran <thuy.tran.xh@renesas.com> Signed-off-by: Takamitsu Honda <takamitsu.honda.pv@renesas.com>
This commit applies a W/A patch from optee upstream to fix GCC 8 format-truncation errors. [1] OP-TEE/optee_client#126 Signed-off-by: Thuy Tran <thuy.tran.xh@renesas.com> Signed-off-by: Khang Nguyen <khang.nguyen.xw@renesas.com> Signed-off-by: Takamitsu Honda <takamitsu.honda.pv@renesas.com>
This commit applies a W/A patch from optee upstream to fix GCC 9 format-truncation errors. [1] OP-TEE/optee_client#126 Signed-off-by: Khang Nguyen <khang.nguyen.xw@renesas.com> Signed-off-by: Takamitsu Honda <takamitsu.honda.pv@renesas.com> Change-Id: Iafdda8934e315366d0d4546d37b63c5bdb4b5a3e
This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time. |
Building v3.1.0 on openSUSE Tumbleweed with its GCC 8.1.1 leads to the following build error:
The text was updated successfully, but these errors were encountered: