aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2017-07-30 00:44:14 +0200
committerMichael Mann <mmann78@netscape.net>2017-07-30 00:30:01 +0000
commitc50945989daa47802e30851b543ab5c69005a343 (patch)
treec9f2dad631d76aeb19a74ac9654f0a6d48b13f7e /epan
parent76762d69b55065af69df075ca8bd3425b5b3ca84 (diff)
DNS: Apply LOC record angle cap
The LOC records LATITUDE and LONGITUDE angle values may become too large. Find these and stop conversion into invalid values. Bug: 13914 Change-Id: Ia01ac1ecf5080350454f06536c9be1cf758d6f3c Reviewed-on: https://code.wireshark.org/review/22847 Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl> Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-dns.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c
index 4309c97b41..01bfa1227d 100644
--- a/epan/dissectors/packet-dns.c
+++ b/epan/dissectors/packet-dns.c
@@ -1352,29 +1352,38 @@ rfc1867_size(tvbuff_t *tvb, int offset)
}
static char *
-rfc1867_angle(tvbuff_t *tvb, int offset, const char *nsew)
+rfc1867_angle(tvbuff_t *tvb, int offset, gboolean longitude)
{
guint32 angle;
char direction;
guint32 degrees, minutes, secs, tsecs;
/* "%u deg %u min %u.%03u sec %c" */
static char buf[10+1+3+1 + 2+1+3+1 + 2+1+3+1+3+1 + 1 + 1];
+ static char *nsew = "NSEW";
angle = tvb_get_ntohl(tvb, offset);
if (angle < 0x80000000U) {
angle = 0x80000000U - angle;
- direction = nsew[1];
+ direction = nsew[1 + longitude ? 2 : 0];
} else {
angle = angle - 0x80000000U;
- direction = nsew[0];
+ direction = nsew[longitude ? 2 : 0];
}
+
+ if (longitude ? (angle > 648000000) : (angle > 324000000))
+ {
+ g_snprintf(buf, sizeof(buf), "Value out of range");
+ return buf;
+ }
+
tsecs = angle % 1000;
angle = angle / 1000;
secs = angle % 60;
angle = angle / 60;
minutes = angle % 60;
degrees = angle / 60;
+
g_snprintf(buf, sizeof(buf), "%u deg %u min %u.%03u sec %c", degrees, minutes, secs,
tsecs, direction);
return buf;
@@ -2399,11 +2408,11 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
cur_offset++;
ti = proto_tree_add_item(rr_tree, hf_dns_loc_latitude, tvb, cur_offset, 4, ENC_BIG_ENDIAN);
- proto_item_append_text(ti, " (%s)", rfc1867_angle(tvb, cur_offset, "NS"));
+ proto_item_append_text(ti, " (%s)", rfc1867_angle(tvb, cur_offset, FALSE));
cur_offset += 4;
ti = proto_tree_add_item(rr_tree, hf_dns_loc_longitude, tvb, cur_offset, 4, ENC_BIG_ENDIAN);
- proto_item_append_text(ti, " (%s)", rfc1867_angle(tvb, cur_offset, "EW"));
+ proto_item_append_text(ti, " (%s)", rfc1867_angle(tvb, cur_offset, TRUE));
cur_offset += 4;
ti = proto_tree_add_item(rr_tree, hf_dns_loc_altitude, tvb, cur_offset, 4, ENC_BIG_ENDIAN);