cf-serverd: Fix format-truncation warning#5735
Conversation
|
Thanks @btriller 🚀 Could you elaborate a little bit on the warning you got? Was it in server_common.c:AbortTransfer? |
Yes, I got Should I include the location in the commit message? |
|
I wonder if that warning would disappear if you added a check to the returned value of static void AbortTransfer(ConnectionInfo *connection, char *filename)
{
Log(LOG_LEVEL_VERBOSE, "Aborting transfer of file due to source changes");
char sendbuffer[CF_BUFSIZE];
int ret = snprintf(sendbuffer, CF_BUFSIZE, "%s%s: %s",
CF_CHANGEDSTR1, CF_CHANGEDSTR2, filename);
if (ret < 0 || (size_t) ret >= CF_BUFSIZE)
{
Log(LOG_LEVEL_WARNING,
"Error message truncated in abort transfer transaction: "
"Filename too long");
}
if (SendTransaction(connection, sendbuffer, 0, CF_DONE) == -1)
{
Log(LOG_LEVEL_VERBOSE, "Send failed in GetFile. (send: %s)",
GetErrorStr());
}
}I don't think a potential truncation of the filename is that critical. The only important part (as far as I know) is that the transaction starts with Could you try that? |
|
If that does not work. Maybe you could add a comment next to the hard coded value, explaining why it is there? |
Yes, that works too. |
|
@cf-bottom Jenkins please :) |
|
Alright, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/11919/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-11919/ |
craigcomstock
left a comment
There was a problem hiding this comment.
The change seems OK.
The commits should be squashed for sure.
Can you describe more about what the original "problem" was? Like an example, log snippet?
No description provided.