Skip to content

Commit

Permalink
FIX: Fix node_name buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesecrust authored and jhpark816 committed Nov 5, 2024
1 parent c04c249 commit 27aed33
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cluster_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ static int compare_cont_item(const void *t1, const void *t2)

static int gen_node_continuum(struct cont_item *continuum, const char *node_name)
{
char buffer[MAX_NODE_NAME_LENGTH+1] = "";
char buffer[MAX_NODE_NAME_LENGTH+4] = "";
int length;
unsigned int hh, nn, pp;
unsigned char digest[16];
int duplicate = 0;

pp = 0;
for (hh=0; hh<NUM_OF_HASHES; hh++) {
length = snprintf(buffer, MAX_NODE_NAME_LENGTH, "%s-%u", node_name, hh);
length = snprintf(buffer, sizeof(buffer), "%s-%u", node_name, hh);
hash_md5(buffer, length, digest);
for (nn=0; nn<NUM_PER_HASH; nn++, pp++) {
continuum[pp].hpoint = ((uint32_t) (digest[3 + nn * NUM_PER_HASH] & 0xFF) << 24)
Expand Down

0 comments on commit 27aed33

Please sign in to comment.