OBS-URL: https://build.opensuse.org/package/show/network:telephony/libosmocore?expand=0&rev=4
50 lines
1.6 KiB
Diff
50 lines
1.6 KiB
Diff
From 6196f28b56b318ef312710dfa82d18a43ce6ae8e Mon Sep 17 00:00:00 2001
|
|
From: Jan Engelhardt <jengelh@inai.de>
|
|
Date: Mon, 3 Jun 2013 01:40:57 +0200
|
|
Subject: [PATCH 2/2] utils: avoid breaking strict aliasing
|
|
|
|
CC osmo-auc-gen.o
|
|
osmo-auc-gen.c: In function 'main':
|
|
osmo-auc-gen.c:217:3: warning: dereferencing type-punned
|
|
pointer will break strict-aliasing rules [-Wstrict-aliasing]
|
|
osmo-auc-gen.c:218:3: warning: dereferencing type-punned
|
|
pointer will break strict-aliasing rules [-Wstrict-aliasing]
|
|
osmo-auc-gen.c:219:3: warning: dereferencing type-punned
|
|
pointer will break strict-aliasing rules [-Wstrict-aliasing]
|
|
osmo-auc-gen.c:220:3: warning: dereferencing type-punned
|
|
pointer will break strict-aliasing rules [-Wstrict-aliasing]
|
|
---
|
|
utils/osmo-auc-gen.c | 14 ++++++++++----
|
|
1 file changed, 10 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c
|
|
index 47256ff..1618211 100644
|
|
--- a/utils/osmo-auc-gen.c
|
|
+++ b/utils/osmo-auc-gen.c
|
|
@@ -213,12 +213,18 @@ int main(int argc, char **argv)
|
|
}
|
|
|
|
if (!rand_is_set) {
|
|
+ int r;
|
|
+
|
|
printf("WARNING: We're using really weak random numbers!\n\n");
|
|
srand(time(NULL));
|
|
- *(uint32_t *)&_rand[0] = rand();
|
|
- *(uint32_t *)(&_rand[4]) = rand();
|
|
- *(uint32_t *)(&_rand[8]) = rand();
|
|
- *(uint32_t *)(&_rand[12]) = rand();
|
|
+ r = rand();
|
|
+ memcpy(_rand, &r, sizeof(r));
|
|
+ r = rand();
|
|
+ memcpy(_rand + 4, &r, sizeof(r));
|
|
+ r = rand();
|
|
+ memcpy(_rand + 8, &r, sizeof(r));
|
|
+ r = rand();
|
|
+ memcpy(_rand + 12, &r, sizeof(r));
|
|
}
|
|
|
|
if (test_aud.type == OSMO_AUTH_TYPE_NONE ||
|
|
--
|
|
1.8.2
|
|
|