diff --git a/src/idempotency/client/client_channel.c b/src/idempotency/client/client_channel.c index f2a3109..118c937 100644 --- a/src/idempotency/client/client_channel.c +++ b/src/idempotency/client/client_channel.c @@ -174,6 +174,7 @@ static struct fast_task_info *alloc_channel_task(IdempotencyClientChannel *channel, const uint32_t hash_code, const FCCommunicationType comm_type, const char *server_ip, const uint16_t port, int *err_no) { + int len; struct fast_task_info *task; SFAddressFamilyHandler *fh; SFNetworkHandler *handler; @@ -194,7 +195,12 @@ static struct fast_task_info *alloc_channel_task(IdempotencyClientChannel return NULL; } - snprintf(task->server_ip, sizeof(task->server_ip), "%s", server_ip); + len = strlen(server_ip); + if (len >= sizeof(task->server_ip)) { + len = sizeof(task->server_ip) - 1; + } + memcpy(task->server_ip, server_ip, len); + *(task->server_ip + len) = '\0'; task->port = port; task->arg = channel; task->thread_data = g_sf_context.thread_data + @@ -255,7 +261,10 @@ struct idempotency_client_channel *idempotency_client_channel_get( IdempotencyClientChannel *current; IdempotencyClientChannel *channel; - key_len = snprintf(key, sizeof(key), "%s-%u", server_ip, server_port); + key_len = strlen(server_ip); + memcpy(key, server_ip, key_len); + *(key + key_len++) = '-'; + key_len += fc_itoa(server_port, key + key_len); hash_code = fc_simple_hash(key, key_len); bucket = channel_context.htable.buckets + hash_code % channel_context.htable.capacity; diff --git a/src/sf_binlog_index.c b/src/sf_binlog_index.c index 62c25c5..37b9942 100644 --- a/src/sf_binlog_index.c +++ b/src/sf_binlog_index.c @@ -186,9 +186,11 @@ static int save(SFBinlogIndexContext *ctx, const char *filename) result = 0; p = buff; bend = buff + sizeof(buff); - p += sprintf(p, "%d %"PRId64"\n", - ctx->index_array.count, - ctx->last_version); + + p += fc_itoa(ctx->index_array.count, p); + *p++ = ' '; + p += fc_itoa(ctx->last_version, p); + *p++ = '\n'; index = ctx->index_array.indexes; for (i=0; iindex_array.count; i++) { diff --git a/src/sf_global.c b/src/sf_global.c index c4ca912..03cb242 100644 --- a/src/sf_global.c +++ b/src/sf_global.c @@ -865,8 +865,7 @@ static void combine_bind_addr(char *bind_addr, const char *ip_addr) p = bind_addr + strlen(bind_addr); *p++ = ','; } - - sprintf(p, "%s", ip_addr); + strcpy(p, ip_addr); } static const char *get_address_family_caption(