*
* $Id$
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
*
* Based on "g_asn1.c" from:
*
#include <glib.h>
-#ifdef NEED_SNPRINTF_H
-# include "snprintf.h"
-#endif
-
#include <epan/tvbuff.h>
#include <epan/asn1.h>
+#include <epan/emem.h>
/*
* NAME: asn1_open [API]
gboolean *defp, guint *lenp)
{
int ret;
- guint def, len;
+ guint def, len = 0;
ret = asn1_id_decode (asn1, cls, con, tag);
if (ret != ASN1_ERR_NOERROR)
* but that's another matter; in any case, that would happen only
* if we had an immensely large tvbuff....)
*/
- if (enc_len != 0)
- tvb_ensure_bytes_exist(asn1->tvb, asn1->offset, enc_len);
+ if (enc_len < 1) {
+ *oid = NULL;
+ return ASN1_ERR_LENGTH_MISMATCH;
+ }
+ tvb_ensure_bytes_exist(asn1->tvb, asn1->offset, enc_len);
eoc = asn1->offset + enc_len;
/*
* NAME: asn1_err_to_str [API]
- * SYNOPSIS: char *asn1_err_to_str
+ * SYNOPSIS: const char *asn1_err_to_str
* (
* int err
* )
* err: the error code
* RETURNS: string for the error
*/
-char *
+const char *
asn1_err_to_str(int err)
{
- char *errstr;
+ const char *errstr;
char errstrbuf[14+1+1+11+1+1]; /* "Unknown error (%d)\0" */
switch (err) {
break;
default:
- snprintf(errstrbuf, sizeof errstrbuf, "Unknown error (%d)", err);
- errstr = errstrbuf;
+ g_snprintf(errstrbuf, sizeof errstrbuf, "Unknown error (%d)", err);
+ errstr = ep_strdup(errstrbuf);
break;
}
return errstr;