Module: kamailio
Branch: master
Commit: be2d3bfe537a692efa8cdc2bd4e4441eed5d0840
URL: 
https://github.com/kamailio/kamailio/commit/be2d3bfe537a692efa8cdc2bd4e4441eed5d0840

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2024-11-29T09:13:49+01:00

lost: use buffer size for snprintf

---

Modified: src/modules/lost/utilities.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/be2d3bfe537a692efa8cdc2bd4e4441eed5d0840.diff
Patch: 
https://github.com/kamailio/kamailio/commit/be2d3bfe537a692efa8cdc2bd4e4441eed5d0840.patch

---

diff --git a/src/modules/lost/utilities.c b/src/modules/lost/utilities.c
index 6e3d9c43f06..ae1bed14fa3 100644
--- a/src/modules/lost/utilities.c
+++ b/src/modules/lost/utilities.c
@@ -1047,7 +1047,7 @@ int lost_parse_geo(xmlNodePtr node, p_lost_loc_t loc)
        if(loc->latitude == NULL)
                goto err;
 
-       snprintf(loc->latitude, len, "%s", (char *)bufLat);
+       snprintf(loc->latitude, len + 1, "%s", (char *)bufLat);
 
        /* logitude */
        len = strlen((char *)bufLon);
@@ -1057,7 +1057,7 @@ int lost_parse_geo(xmlNodePtr node, p_lost_loc_t loc)
                goto err;
        }
 
-       snprintf(loc->longitude, len, "%s", (char *)bufLon);
+       snprintf(loc->longitude, len + 1, "%s", (char *)bufLon);
 
        /* altitude */
        if(scan == 3) {
@@ -1071,13 +1071,13 @@ int lost_parse_geo(xmlNodePtr node, p_lost_loc_t loc)
                        goto err;
                }
                
-               snprintf(loc->altitude, len, "%s", (char *)bufAlt);
+               snprintf(loc->altitude, len + 1, "%s", (char *)bufAlt);
        }
 
        /* geolocation */
        len = strlen((char *)bufLat) + strlen((char *)bufLon) + 1;
        if((scan == 3) && (lost_geoloc_3d == 1)) {
-               len += strlen((char *)bufAlt);
+               len += strlen((char *)bufAlt) + 1;
        }
        loc->geodetic = (char *)pkg_malloc(len + 1);
        if(loc->geodetic == NULL) {
@@ -1089,9 +1089,9 @@ int lost_parse_geo(xmlNodePtr node, p_lost_loc_t loc)
        }
        if((scan == 3) && (lost_geoloc_3d == 1)) {
                s_profile = LOST_PRO_GEO3D;
-               snprintf(loc->geodetic, len, "%s %s %s", (char *)bufLat, (char 
*)bufLon, (char *)bufAlt);
+               snprintf(loc->geodetic, len + 1, "%s %s %s", (char *)bufLat, 
(char *)bufLon, (char *)bufAlt);
        } else {
-               snprintf(loc->geodetic, len, "%s %s", (char *)bufLat, (char 
*)bufLon);
+               snprintf(loc->geodetic, len + 1, "%s %s", (char *)bufLat, (char 
*)bufLon);
        }
 
        /* find <radius> element */

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to