summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2018-01-24 11:38:59 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2018-01-24 11:38:59 +0100
commite16b1811d62b7493133093205d498a30b6f04dae (patch)
treeb3a3a491859fa95e8dcc101a4953ffc5e5fd474d
parent5b3447122c12aafca71f6d61be87eb0dac19d0fb (diff)
downloaduca-net-e16b1811d62b7493133093205d498a30b6f04dae.tar.gz
uca-net-e16b1811d62b7493133093205d498a30b6f04dae.tar.bz2
uca-net-e16b1811d62b7493133093205d498a30b6f04dae.tar.xz
uca-net-e16b1811d62b7493133093205d498a30b6f04dae.zip
Raise enum value name length and issue warning
-rw-r--r--uca-net-protocol.h2
-rw-r--r--ucad.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/uca-net-protocol.h b/uca-net-protocol.h
index ee10b72..5a7611c 100644
--- a/uca-net-protocol.h
+++ b/uca-net-protocol.h
@@ -4,7 +4,7 @@
#include <gio/gio.h>
#define UCA_NET_MAX_ENUM_LENGTH 32
-#define UCA_NET_MAX_ENUM_NAME_LENGTH 32
+#define UCA_NET_MAX_ENUM_NAME_LENGTH 128
typedef enum {
UCA_NET_MESSAGE_INVALID = 0,
diff --git a/ucad.c b/ucad.c
index 6e401b1..ec0f7d2 100644
--- a/ucad.c
+++ b/ucad.c
@@ -135,6 +135,10 @@ serialize_param_spec (GParamSpec *pspec, UcaNetMessageProperty *prop)
for (guint i = 0; i < MIN (enum_class->n_values, UCA_NET_MAX_ENUM_LENGTH); i++) {
prop->spec.genum.values[i] = enum_class->values[i].value;
+
+ if (strlen (enum_class->values[i].value_name) > UCA_NET_MAX_ENUM_NAME_LENGTH)
+ g_warning ("Enum value name too long, expect serious problems");
+
strncpy (prop->spec.genum.value_names[i], enum_class->values[i].value_name,
UCA_NET_MAX_ENUM_NAME_LENGTH);
}