- sort_host_length= (size_t) snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
- "/%s:%u-%u",
- list[host_index].hostname,
- (uint32_t)list[host_index].port,
- pointer_index);
+ sort_host_length= snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+ "/%s:%u-%u",
+ list[host_index].hostname,
+ (uint32_t)list[host_index].port,
+ pointer_index);
+
+ if (sort_host_length >= MEMCACHED_MAX_HOST_SORT_LENGTH || sort_host_length < 0)
+ {
+ return MEMCACHED_FAILURE;
+ }