diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-07-29 20:29:24 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-07-29 20:29:24 +0000 |
commit | 8437d671f9c4c0fdd2d5d29f8741173391196e1c (patch) | |
tree | d3be6f832e41d7f49fabd8cd91996ddd1b392418 /pjlib/src | |
parent | dfc70260daca970cc1df362f26fd669d75812eb0 (diff) |
Another take at fixing 64bit problems. PJ_MAX_OBJ_NAME is increased to 32 chars (from 16), and check all those sprintf's especially the ones with "%p" format.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@635 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src')
-rw-r--r-- | pjlib/src/pj/except.c | 3 | ||||
-rw-r--r-- | pjlib/src/pj/guid_simple.c | 6 | ||||
-rw-r--r-- | pjlib/src/pj/os_core_linux_kernel.c | 9 | ||||
-rw-r--r-- | pjlib/src/pj/os_core_unix.c | 6 | ||||
-rw-r--r-- | pjlib/src/pj/os_core_win32.c | 6 | ||||
-rw-r--r-- | pjlib/src/pj/os_error_linux_kernel.c | 4 | ||||
-rw-r--r-- | pjlib/src/pj/pool.c | 3 |
7 files changed, 23 insertions, 14 deletions
diff --git a/pjlib/src/pj/except.c b/pjlib/src/pj/except.c index 06bdd68f..1074828f 100644 --- a/pjlib/src/pj/except.c +++ b/pjlib/src/pj/except.c @@ -126,7 +126,8 @@ PJ_DEF(const char*) pj_exception_id_name(pj_exception_id_t id) PJ_ASSERT_RETURN(id>0 && id<PJ_MAX_EXCEPTION_ID, "<Invalid ID>"); if (exception_id_names[id] == NULL) { - pj_ansi_sprintf(unknown_name, "exception %d", id); + pj_ansi_snprintf(unknown_name, sizeof(unknown_name), + "exception %d", id); return unknown_name; } diff --git a/pjlib/src/pj/guid_simple.c b/pjlib/src/pj/guid_simple.c index 9e179925..b4ad38af 100644 --- a/pjlib/src/pj/guid_simple.c +++ b/pjlib/src/pj/guid_simple.c @@ -36,9 +36,9 @@ PJ_DEF(pj_str_t*) pj_generate_unique_string(pj_str_t *str) { static int guid_initialized; static unsigned pid; - static char str_pid[5]; - static unsigned char mac_addr[6]; - static char str_mac_addr[16]; + static char str_pid[32]; + static unsigned char mac_addr[32]; + static char str_mac_addr[32]; static unsigned clock_seq; PJ_CHECK_STACK(); diff --git a/pjlib/src/pj/os_core_linux_kernel.c b/pjlib/src/pj/os_core_linux_kernel.c index ee0f3452..97d5fce5 100644 --- a/pjlib/src/pj/os_core_linux_kernel.c +++ b/pjlib/src/pj/os_core_linux_kernel.c @@ -138,8 +138,10 @@ static void thread_initialize( pj_thread_t *thread ) /* initialise termination flag */ thread->terminate = 0; - /* set name of this process (max 15 chars + 0 !) */ - thread->obj_name[15] = '\0'; + /* set name of this process (making sure obj_name is null + * terminated first) + */ + thread->obj_name[PJ_MAX_OBJ_NAME-1] = '\0'; sprintf(current->comm, thread->obj_name); /* tell the creator that we are ready and let him continue */ @@ -266,7 +268,8 @@ PJ_DEF(pj_status_t) pj_thread_register ( const char *cstr_thread_name, if(cstr_thread_name && pj_strlen(&thread_name) < sizeof(thread->obj_name)-1) pj_sprintf(thread->obj_name, cstr_thread_name, thread->thread); else - pj_sprintf(thread->obj_name, "thr%p", (void*)thread->thread); + pj_snprintf(thread->obj_name, sizeof(thread->obj_name), + "thr%p", (void*)thread->thread); /* Initialize. */ thread_initialize(thread); diff --git a/pjlib/src/pj/os_core_unix.c b/pjlib/src/pj/os_core_unix.c index b447e72c..1fa8d474 100644 --- a/pjlib/src/pj/os_core_unix.c +++ b/pjlib/src/pj/os_core_unix.c @@ -210,9 +210,11 @@ PJ_DEF(pj_status_t) pj_thread_register ( const char *cstr_thread_name, thread->thread = pthread_self(); if(cstr_thread_name && pj_strlen(&thread_name) < sizeof(thread->obj_name)-1) - pj_ansi_sprintf(thread->obj_name, cstr_thread_name, thread->thread); + pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name), + cstr_thread_name, thread->thread); else - pj_ansi_sprintf(thread->obj_name, "thr%p", (void*)thread->thread); + pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name), + "thr%p", (void*)thread->thread); rc = pj_thread_local_set(thread_tls_id, thread); if (rc != PJ_SUCCESS) diff --git a/pjlib/src/pj/os_core_win32.c b/pjlib/src/pj/os_core_win32.c index 726702b2..565efb3c 100644 --- a/pjlib/src/pj/os_core_win32.c +++ b/pjlib/src/pj/os_core_win32.c @@ -228,9 +228,11 @@ PJ_DEF(pj_status_t) pj_thread_register ( const char *cstr_thread_name, #endif if (cstr_thread_name && pj_strlen(&thread_name) < sizeof(thread->obj_name)-1) - pj_ansi_sprintf(thread->obj_name, cstr_thread_name, thread->idthread); + pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name), + cstr_thread_name, thread->idthread); else - pj_ansi_sprintf(thread->obj_name, "thr%p", (void*)thread->idthread); + pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name), + "thr%p", (void*)thread->idthread); rc = pj_thread_local_set(thread_tls_id, thread); if (rc != PJ_SUCCESS) diff --git a/pjlib/src/pj/os_error_linux_kernel.c b/pjlib/src/pj/os_error_linux_kernel.c index e9c7e2af..8294ae75 100644 --- a/pjlib/src/pj/os_error_linux_kernel.c +++ b/pjlib/src/pj/os_error_linux_kernel.c @@ -57,14 +57,14 @@ PJ_DEF(void) pj_set_netos_error(pj_status_t code) int platform_strerror( pj_os_err_type os_errcode, char *buf, pj_size_t bufsize) { - char errmsg[32]; + char errmsg[PJ_ERR_MSG_SIZE]; int len; /* Handle EINVAL as special case so that it'll pass errno test. */ if (os_errcode==EINVAL) strcpy(errmsg, "Invalid value"); else - sprintf(errmsg, "errno=%d", os_errcode); + snprintf(errmsg, sizeof(errmsg), "errno=%d", os_errcode); len = strlen(errmsg); diff --git a/pjlib/src/pj/pool.c b/pjlib/src/pj/pool.c index 513e9fac..06f1ebc8 100644 --- a/pjlib/src/pj/pool.c +++ b/pjlib/src/pj/pool.c @@ -150,7 +150,8 @@ PJ_DEF(void) pj_pool_init_int( pj_pool_t *pool, if (name) { if (strchr(name, '%') != NULL) { - pj_ansi_sprintf(pool->obj_name, name, pool); + pj_ansi_snprintf(pool->obj_name, sizeof(pool->obj_name), + name, pool); } else { pj_ansi_strncpy(pool->obj_name, name, PJ_MAX_OBJ_NAME); } |