diff --git a/debian/patches/series b/debian/patches/series index 623df1f7..100feec5 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -41,3 +41,4 @@ sipwise/db_reg_agent_auth_header.patch sipwise/skip_outbound_auth_if_credentials_empty.patch sipwise/add_support_for_peering_outbound_registration.patch sipwise/cpslimit_detect_emergency_calls_and_let_them_pass.patch +sipwise/dsm_modutils_fix_utils_get_count_files.patch diff --git a/debian/patches/sipwise/dsm_modutils_fix_utils_get_count_files.patch b/debian/patches/sipwise/dsm_modutils_fix_utils_get_count_files.patch new file mode 100644 index 00000000..9d6a858a --- /dev/null +++ b/debian/patches/sipwise/dsm_modutils_fix_utils_get_count_files.patch @@ -0,0 +1,54 @@ +--- a/apps/dsm/mods/mod_utils/ModUtils.cpp ++++ b/apps/dsm/mods/mod_utils/ModUtils.cpp +@@ -72,20 +72,32 @@ vector utils_get_count_files(DSM + + vector res; + ++ unsigned int number = cnt; ++ unsigned int n = log10(number) + 1; ++ const int max = 9; ++ ++ string full_number = std::to_string(number); ++ string remainder; /* what remains after 9 digits, if remains */ ++ bool remainder_exists = false; ++ + if (cnt <= 20) { + res.push_back(basedir+int2str(cnt)+suffix); + return res; + } +- +- for (int i=9;i>1;i--) { +- div_t num = div(cnt, (int)pow(10.,i)); +- if (num.quot) { +- res.push_back(basedir+int2str(int(num.quot * pow(10.,i)))+suffix); +- } +- cnt = num.rem; ++ ++ if (n > max) { ++ remainder_exists = true; ++ remainder = full_number.substr(max); ++ cnt = std::stoi(remainder); ++ } ++ ++ for (int i = n; i > 0; i--) { ++ int num = (int)((number % (unsigned int)pow(10, i)) / pow(10, i - 1)); ++ if ( (n - i) < max ) ++ res.push_back(basedir+int2str(num)+suffix); /* only push until max amount here */ + } + +- if (!cnt) ++ if (!remainder_exists) + return res; + + if ((cnt <= 20) || (!(cnt%10))) { +--- a/apps/dsm/mods/mod_utils/ModUtils.h ++++ b/apps/dsm/mods/mod_utils/ModUtils.h +@@ -31,6 +31,8 @@ + #include "AmRingTone.h" + #include "DSMSession.h" + ++#include ++ + #define MOD_CLS_NAME SCUtilsModule + + DECLARE_MODULE(MOD_CLS_NAME);