fix: init data buffer before using
This commit is contained in:
@ -3,11 +3,12 @@
|
||||
#include "../../include/util.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <error.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.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){
|
||||
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;
|
||||
|
||||
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);
|
||||
lm_error_set(LM_ERR_SendSnprintfFail);
|
||||
goto end_1;
|
||||
@ -74,7 +75,9 @@ bool lm_mptp_sendfile(int sock, char *path, lm_mptp_transfer_callback_t callback
|
||||
goto end_1;
|
||||
|
||||
lm_mptp_free(&packet);
|
||||
|
||||
lm_mptp_new(&packet, false, MPTP_S2C_COOL, false);
|
||||
lm_mptp_set_data(&packet, NULL, MPTP_DATA_MAX);
|
||||
}
|
||||
|
||||
if(current != total){
|
||||
|
Reference in New Issue
Block a user