diff --git a/main.cpp b/main.cpp index b073893..187a418 100644 --- a/main.cpp +++ b/main.cpp @@ -234,7 +234,7 @@ int main() } else if (h.contains("Content-Length:")) { - file_size = atoi(h["Content-Length:"].c_str()); + file_size = atoi_newline(h["Content-Length:"].c_str()); } else if (line_str.contains(boundary) && boundary.contains("----")) { @@ -254,7 +254,8 @@ int main() auto h = parse_header(line_str); std::vector file_ = split(h.begin()->second, "; "); std::string filename = get_filename(file_.back()); - char *file_data = server.receive_data_ensured(user, file_size); + size_t size = file_size - (line_str.size() + std::string(line2).size() + std::string(line3).size() + (line_str2.size())); + char *file_data = server.receive_data_ensured(user, size); if (!file_data) throw std::runtime_error("Getting file data failed"); std::string final_boundary = std::format("\r\n--{}--", boundary); diff --git a/netlib b/netlib index a91be41..57b7a51 160000 --- a/netlib +++ b/netlib @@ -1 +1 @@ -Subproject commit a91be412a9a5b05911e0029241ce0ff6fd5c2d6b +Subproject commit 57b7a51ebbec052c421ecbab66884319faaad26f