mirror of
https://github.com/redis/redis.git
synced 2026-06-08 16:24:26 -04:00
Fix garbled "source node not found" error in atomic slot migration (#15284)
asmSyncWithSource() built the error with sdscatfmt() and a "%.40s" specifier. sdscatfmt() is not printf: it parses only the single byte after '%' and ignores width/precision, so "%.40s" emits a literal '.', consumes no argument, and task->source is never printed. The message rendered as "Source node .40s was not found", dropping the node name. task->source is a CLUSTER_NAMELEN (40) byte, non-NUL-terminated buffer (filled via memcpy and always read with an explicit length elsewhere), so simply switching to sdscatfmt's "%s" would strlen() past the buffer. Use sdscatprintf(), which honors the "%.40s" precision and bounds the read to 40 bytes -- matching the sibling error paths in this function that already use sdscatprintf().
This commit is contained in:
parent
8fcf3dc866
commit
7f532eacdf
1 changed files with 1 additions and 1 deletions
|
|
@ -1628,7 +1628,7 @@ void asmSyncWithSource(connection *conn) {
|
|||
/* Create RDB channel connection */
|
||||
clusterNode *source_node = clusterLookupNode(task->source, CLUSTER_NAMELEN);
|
||||
if (!source_node) {
|
||||
task_error_msg = sdscatfmt(sdsempty(), "Source node %.40s was not found", task->source);
|
||||
task_error_msg = sdscatprintf(sdsempty(), "Source node %.40s was not found", task->source);
|
||||
goto error;
|
||||
}
|
||||
char *ip = clusterNodeIp(source_node);
|
||||
|
|
|
|||
Loading…
Reference in a new issue