diff options
author | Benny Prijono <bennylp@teluu.com> | 2010-01-13 13:09:45 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2010-01-13 13:09:45 +0000 |
commit | 8cc7aef25ecc698b6fdfa620877f72e6b8dd536f (patch) | |
tree | 40e3c7c8df20a5b26d95543285145348a18009db /pjlib/src/pj/guid_simple.c | |
parent | d4663d0cbfd495529f7ce486d9f9d36f7969bc50 (diff) |
Initial OpenBSD fixes (#994):
pjlib:
- Autoconf fixes in detecting header availability
- Undefined sched_get_priority_max() and sched_get_priority_min()
- protect with #ifdef _POSIX_PRIORITY_SCHEDULING, and
- return hardcoded (0, 31) if __OpenBSD__ macro is declared
- Better GUID generation
pjlib-test:
- Reduce the loop in PJILB activesock test
- Fixed bug in ioqueue unregistration test which caused assertion error in destroying mutex
pjlib-util-test:
- Fixed bug in pjlib-util resolver test
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3057 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/guid_simple.c')
-rw-r--r-- | pjlib/src/pj/guid_simple.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pjlib/src/pj/guid_simple.c b/pjlib/src/pj/guid_simple.c index 83870299..728d87e5 100644 --- a/pjlib/src/pj/guid_simple.c +++ b/pjlib/src/pj/guid_simple.c @@ -67,10 +67,12 @@ PJ_DEF(pj_str_t*) pj_generate_unique_string(pj_str_t *str) pj_assert(PJ_GUID_STRING_LENGTH % 2 == 0); for (p=str->ptr, end=p+PJ_GUID_STRING_LENGTH; p<end; ) { - /* Assumes rand() only has 16bit randomness */ - unsigned short val = pj_rand(); - *p++ = guid_chars[(val >> 8) & 63]; - *p++ = guid_chars[(val & 0xFF) & 63]; + pj_uint32_t rand_val = pj_rand(); + pj_uint32_t rand_idx = RAND_MAX; + + for ( ; rand_idx>0 && p<end; rand_idx>>=8, rand_val>>=8, p++) { + *p = guid_chars[(rand_val & 0xFF) & 63]; + } } str->slen = PJ_GUID_STRING_LENGTH; |