Skip to content

Commit 082cd64

Browse files
fix(geographiclib): CVE-2025-60751
Fix stack-based buffer overflow in DMS::InternalDecode function. The vulnerability existed because the code used a fixed-size array (3 elements) for ipieces and fpieces but didn't properly validate that the input string didn't contain more than 3 components. Upstream: geographiclib/geographiclib@aec521d Generated-By: glm-5.1 Co-Authored-By: hudeng <hudeng@deepin.org>
1 parent 6b55b70 commit 082cd64

3 files changed

Lines changed: 75 additions & 0 deletions

File tree

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
geographiclib (2.5-1deepin1) unstable; urgency=medium
2+
3+
* Fix CVE-2025-60751: stack-based buffer overflow in DMS.cpp
4+
5+
-- deepin-ci-robot <packages@deepin.org> Sat, 25 Apr 2026 04:21:15 +0800
6+
17
geographiclib (2.5-1) unstable; urgency=medium
28

39
* New upstream release.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Description: Fix CVE-2025-60751: stack-based buffer overflow in DMS.cpp
2+
Fix buffer overflow in DMS::InternalDecode function by adding bounds checking
3+
for the number of components in DMS (degrees/minutes/seconds) string parsing.
4+
.
5+
The vulnerability existed because the code used a fixed-size array (3 elements)
6+
for ipieces and fpieces but didn't properly validate that the input string
7+
didn't contain more than 3 components, potentially leading to a buffer overflow.
8+
Author: Charles Karney <karney@alum.mit.edu>
9+
Origin: upstream, https://github.com/geographiclib/geographiclib/commit/aec521dff5ec0757cdefa018b152fffcfbca3eac
10+
Bug: https://security-tracker.debian.org/tracker/CVE-2025-60751
11+
Forwarded: not-needed
12+
---
13+
src/DMS.cpp | 14 ++++++++++----
14+
1 file changed, 10 insertions(+), 4 deletions(-)
15+
16+
diff --git a/src/DMS.cpp b/src/DMS.cpp
17+
index 8a30340f..d9c552a1 100644
18+
--- a/src/DMS.cpp
19+
+++ b/src/DMS.cpp
20+
@@ -190,6 +190,7 @@ namespace GeographicLib {
21+
}
22+
23+
Math::real DMS::InternalDecode(const string& dmsa, flag& ind) {
24+
+ const int maxcomponents = 3;
25+
string errormsg;
26+
do { // Executed once (provides the ability to break)
27+
int sign = 1;
28+
@@ -232,8 +233,8 @@ namespace GeographicLib {
29+
errormsg = "Empty or incomplete DMS string " + dmsa;
30+
break;
31+
}
32+
- real ipieces[] = {0, 0, 0};
33+
- real fpieces[] = {0, 0, 0};
34+
+ real ipieces[maxcomponents] = {0, 0, 0};
35+
+ real fpieces[maxcomponents] = {0, 0, 0};
36+
unsigned npiece = 0;
37+
real icurrent = 0;
38+
real fcurrent = 0;
39+
@@ -259,7 +260,7 @@ namespace GeographicLib {
40+
pointseen = true;
41+
digcount = 1;
42+
} else if ((k = Utility::lookup(dmsindicators_, x)) >= 0) {
43+
- if (k >= 3) {
44+
+ if (k >= maxcomponents) {
45+
if (p == end) {
46+
errormsg = "Illegal for : to appear at the end of " +
47+
dmsa.substr(beg, end - beg);
48+
@@ -292,6 +293,11 @@ namespace GeographicLib {
49+
fpieces[k] = icurrent + fcurrent;
50+
if (p < end) {
51+
npiece = k + 1;
52+
+ if (npiece >= maxcomponents) {
53+
+ errormsg = "More than 3 DMS components in "
54+
+ + dmsa.substr(beg, end - beg);
55+
+ break;
56+
+ }
57+
icurrent = fcurrent = 0;
58+
ncurrent = digcount = intcount = 0;
59+
}
60+
@@ -308,7 +314,7 @@ namespace GeographicLib {
61+
if (!errormsg.empty())
62+
break;
63+
if (Utility::lookup(dmsindicators_, dmsa[p - 1]) < 0) {
64+
- if (npiece >= 3) {
65+
+ if (npiece >= maxcomponents) {
66+
errormsg = "Extra text following seconds in DMS string "
67+
+ dmsa.substr(beg, end - beg);
68+
break;

debian/patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
css.patch
22
privacy.patch
33
reproducible-build.patch
4+
cve_2025_60751.patch

0 commit comments

Comments
 (0)