summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--util/src/platforms/unix/uuid_gen_unix.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/util/src/platforms/unix/uuid_gen_unix.c b/util/src/platforms/unix/uuid_gen_unix.c
index 1941207..467a051 100644
--- a/util/src/platforms/unix/uuid_gen_unix.c
+++ b/util/src/platforms/unix/uuid_gen_unix.c
@@ -51,6 +51,11 @@
#include <platforms/unix/axutil_uuid_gen_unix.h>
#include <platforms/axutil_platform_auto_sense.h>
+#ifdef AXIS2_SSL_ENABLED
+#include <openssl/rand.h>
+#endif
+
+
/* We need these static variables to track throughout the program execution */
static axis2_bool_t axutil_uuid_gen_is_first = AXIS2_TRUE;
static struct axutil_uuid_st axutil_uuid_static;
@@ -69,10 +74,19 @@ axutil_uuid_gen_v1()
if(AXIS2_TRUE == axutil_uuid_gen_is_first)
{
char *mac_addr = axutil_uuid_get_mac_addr();
- memcpy(axutil_uuid_static.mac, mac_addr, 6);
+ if (mac_addr) {
+ memcpy(axutil_uuid_static.mac, mac_addr, 6);
+ free(mac_addr);
+ } else {
+ /* Default value, not expected to go there */
+#ifdef AXIS2_SSL_ENABLED
+ RAND_bytes(axutil_uuid_static.mac, 6);
+#else
+ memset(axutil_uuid_static.mac, 0, 6);
+#endif
+ }
axutil_uuid_static.time_seq = 0;
axutil_uuid_static.clock = 0;
- free(mac_addr);
axutil_uuid_gen_is_first = AXIS2_FALSE;
}
/*