From 70b760c0f8cef3b8ac0426a39f5005868bed5803 Mon Sep 17 00:00:00 2001 From: ngn Date: Sat, 10 Aug 2024 00:06:42 +0300 Subject: [PATCH] fix: init data buffer before using --- locale/tr/LC_MESSAGES/libmp.po | 2 +- src/mptp/util.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/locale/tr/LC_MESSAGES/libmp.po b/locale/tr/LC_MESSAGES/libmp.po index ab97e3c..27d7f54 100644 --- a/locale/tr/LC_MESSAGES/libmp.po +++ b/locale/tr/LC_MESSAGES/libmp.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/mptp/util.c b/src/mptp/util.c index c83bfca..9b6bb5b 100644 --- a/src/mptp/util.c +++ b/src/mptp/util.c @@ -3,11 +3,12 @@ #include "../../include/util.h" #include -#include -#include -#include +#include #include #include +#include +#include +#include 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){