fix: init data buffer before using
This commit is contained in:
parent
3be2056c21
commit
70b760c0f8
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2024-08-09 22:28+0300\n"
|
"POT-Creation-Date: 2024-08-10 00:05+0300\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -3,11 +3,12 @@
|
|||||||
#include "../../include/util.h"
|
#include "../../include/util.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <string.h>
|
||||||
#include <error.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <error.h>
|
||||||
|
|
||||||
bool lm_mptp_sendfile(int sock, char *path, lm_mptp_transfer_callback_t callback, void *data){
|
bool lm_mptp_sendfile(int sock, char *path, lm_mptp_transfer_callback_t callback, void *data){
|
||||||
if (NULL == path){
|
if (NULL == path){
|
||||||
@ -41,9 +42,9 @@ bool lm_mptp_sendfile(int sock, char *path, lm_mptp_transfer_callback_t callback
|
|||||||
total = st.st_size;
|
total = st.st_size;
|
||||||
|
|
||||||
lm_mptp_new(&packet, false, MPTP_S2C_COOL, false);
|
lm_mptp_new(&packet, false, MPTP_S2C_COOL, false);
|
||||||
lm_mptp_set_data(&packet, NULL, digits(st.st_size));
|
lm_mptp_set_data(&packet, NULL, digits(total));
|
||||||
|
|
||||||
if((size = snprintf(packet.data, MPTP_DATA_MAX, "%lu", st.st_size)) <= 0){
|
if((size = snprintf(packet.data, MPTP_DATA_MAX, "%lu", total)) <= 0){
|
||||||
pdebug(__func__, "snprintf for stat size failed: %s", path);
|
pdebug(__func__, "snprintf for stat size failed: %s", path);
|
||||||
lm_error_set(LM_ERR_SendSnprintfFail);
|
lm_error_set(LM_ERR_SendSnprintfFail);
|
||||||
goto end_1;
|
goto end_1;
|
||||||
@ -74,7 +75,9 @@ bool lm_mptp_sendfile(int sock, char *path, lm_mptp_transfer_callback_t callback
|
|||||||
goto end_1;
|
goto end_1;
|
||||||
|
|
||||||
lm_mptp_free(&packet);
|
lm_mptp_free(&packet);
|
||||||
|
|
||||||
lm_mptp_new(&packet, false, MPTP_S2C_COOL, false);
|
lm_mptp_new(&packet, false, MPTP_S2C_COOL, false);
|
||||||
|
lm_mptp_set_data(&packet, NULL, MPTP_DATA_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current != total){
|
if(current != total){
|
||||||
|
Loading…
Reference in New Issue
Block a user