Skip to content

Commit

Permalink
Fix file size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Dave committed Jul 25, 2024
1 parent 29112ee commit f48a59f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/webu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,18 @@ void cls_webu::mhd_loadfile(std::string fname,std::string &filestr)
{
/* This needs conversion to c++ stream */
FILE *infile;
size_t file_size, read_size;
size_t read_size, file_size;
long retcd;
char *file_char;

filestr = "";
if (fname != "") {
infile = myfopen(fname.c_str() , "rbe");
if (infile != NULL) {
fseek(infile, 0, SEEK_END);
file_size = (size_t)(infile);
if (file_size > 0 ) {
retcd = ftell(infile);
if (retcd > 0 ) {
file_size = (size_t)retcd;
file_char = (char*)mymalloc(file_size +1);
fseek(infile, 0, SEEK_SET);
read_size = fread(file_char, file_size, 1, infile);
Expand Down Expand Up @@ -388,7 +390,7 @@ void cls_webu::start_daemon_port1()
mhdst->ipv6 = c_motapp->conf->webcontrol_ipv6;
mhdst->tls_use = c_motapp->conf->webcontrol_tls;

mhdst->mhd_ops =(struct MHD_OptionItem*)mymalloc(sizeof(struct MHD_OptionItem)*WEBUI_MHD_OPTS);
mhdst->mhd_ops =(struct MHD_OptionItem*)mymalloc(sizeof(struct MHD_OptionItem) * WEBUI_MHD_OPTS);
mhd_features();
mhd_opts();
mhd_flags();
Expand Down

0 comments on commit f48a59f

Please sign in to comment.