Skip to content
Snippets Groups Projects
Commit f92a14cd authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fix issue with the import message commands introduced in previous commit

The fread() usage here did not need "addressing" (Commit 1b56dc96).

This caused messages posted via smbutil to be short (e.g. 0 or 1 bytes
in length). Reported by Accession via Idle Relay Chat.

Also, don't call strlen() on msgtxt which could be NULL, causing segfault
in final printf() callin in postmsg().
parent 37d8d708
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2142 passed
......@@ -207,7 +207,7 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
/* Read message text from stream (file or stdin) */
msgtxtlen=0;
while(!feof(fp)) {
i=fread(buf,sizeof(buf),1,fp);
i=fread(buf,1,sizeof(buf),fp);
if(i<1)
break;
if((msgtxt = realloc(msgtxt,msgtxtlen+i+1))==NULL) {
......@@ -369,7 +369,7 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
smb_freemsgmem(&msg);
// MSVC can't do %zu for size_t until MSVC 2017 it seems...
fprintf(statfp, "Message (%" PRIu64 " bytes) added to %s successfully\n", (uint64_t)strlen((char *)msgtxt), smb.file);
fprintf(statfp, "Message (%ld bytes) added to %s successfully\n", msgtxtlen, smb.file);
FREE_AND_NULL(msgtxt);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment