Skip to content

Commit

Permalink
Eliminate snprintf usage at setDeferredAggregateLen (valkey-io#1234)
Browse files Browse the repository at this point in the history
to align with how we encode the length at `_addReplyLongLongWithPrefix`

Signed-off-by: Masahiro Ide <[email protected]>
Co-authored-by: Masahiro Ide <[email protected]>
  • Loading branch information
imasahiro and Masahiro Ide authored Oct 31, 2024
1 parent ab98f37 commit 91cbf77
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,11 @@ void setDeferredAggregateLen(client *c, void *node, long length, char prefix) {
}

char lenstr[128];
size_t lenstr_len = snprintf(lenstr, sizeof(lenstr), "%c%ld\r\n", prefix, length);
setDeferredReply(c, node, lenstr, lenstr_len);
lenstr[0] = prefix;
size_t lenstr_len = ll2string(lenstr + 1, sizeof(lenstr) - 1, length);
lenstr[lenstr_len + 1] = '\r';
lenstr[lenstr_len + 2] = '\n';
setDeferredReply(c, node, lenstr, lenstr_len + 3);
}

void setDeferredArrayLen(client *c, void *node, long length) {
Expand Down

0 comments on commit 91cbf77

Please sign in to comment.