aboutsummaryrefslogtreecommitdiffstats
path: root/epan/to_str.c
diff options
context:
space:
mode:
authorlego <lego@f5534014-38df-0310-8fa8-9805f1628bb7>2007-08-25 17:29:55 +0000
committerlego <lego@f5534014-38df-0310-8fa8-9805f1628bb7>2007-08-25 17:29:55 +0000
commitcccb78b51386817ba76b402b44afbc0a41784564 (patch)
tree16dfc22040ccda35eeb235e06955c929032cbca3 /epan/to_str.c
parent8e50b84e932b3a6b689e7891c5bd297fa11e8e9a (diff)
replace oid_to_str_buf() and oid_to_str()
fix a potential buffer overflow due to a very liberal estimate by oid_repr_len() git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@22659 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/to_str.c')
-rw-r--r--epan/to_str.c43
1 files changed, 0 insertions, 43 deletions
diff --git a/epan/to_str.c b/epan/to_str.c
index 4555b0d64b..0f05fc62a8 100644
--- a/epan/to_str.c
+++ b/epan/to_str.c
@@ -931,49 +931,6 @@ address_to_str_buf(const address *addr, gchar *buf, int buf_len)
}
}
-gchar* oid_to_str(const guint8 *oid, gint oid_len) {
- gchar *buf;
-
- buf=ep_alloc(MAX_OID_STR_LEN);
- return oid_to_str_buf(oid, oid_len, buf, MAX_OID_STR_LEN);
-}
-
-#define OID_STR_LIMIT (1 + 10 + 4 + 1) /* "." + 10 digits + ".>>>" + '\0' */
-gchar* oid_to_str_buf(const guint8 *oid, gint oid_len, gchar *buf, int buf_len) {
- gint i;
- guint8 byte;
- guint32 subid0, subid;
- gboolean is_first;
- gchar *bufp;
-
- bufp = buf; subid = 0; is_first = TRUE;
- for (i=0; i<oid_len; i++){
- byte = oid[i];
- if ((bufp - buf) > (buf_len - OID_STR_LIMIT)) {
- bufp += g_snprintf(bufp, buf_len-(bufp-buf), ".>>>");
- break;
- }
- subid <<= 7;
- subid |= byte & 0x7F;
- if (byte & 0x80) {
- continue;
- }
- if (is_first) {
- subid0 = 0;
- if (subid >= 40) { subid0++; subid-=40; }
- if (subid >= 40) { subid0++; subid-=40; }
- bufp += g_snprintf(bufp, buf_len-(bufp-buf), "%u.%u", subid0, subid);
- is_first = FALSE;
- } else {
- bufp += g_snprintf(bufp, buf_len-(bufp-buf), ".%u", subid);
- }
- subid = 0;
- }
- *bufp = '\0';
-
- return buf;
-}
-
gchar* guid_to_str(const e_guid_t *guid) {
gchar *buf;