Skip to content

Commit 69b31b1

Browse files
fix: replace strcpy with strncpy for safer string operations in ggml-opt.cpp
Co-Authored-By: Jake Cosme <[email protected]>
1 parent a8309ca commit 69b31b1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ggml/src/ggml-opt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ static ggml_tensor * map_tensor(std::map<ggml_tensor *, ggml_tensor *> & tensor_
277277
}
278278
new_tensor->flags = tensor->flags;
279279
memcpy(new_tensor->op_params, tensor->op_params, sizeof(tensor->op_params));
280-
strcpy(new_tensor->name, tensor->name);
280+
strncpy(new_tensor->name, tensor->name, GGML_MAX_NAME - 1);
281+
new_tensor->name[GGML_MAX_NAME - 1] = '\0';
281282
new_tensor->data = tensor->data;
282283
new_tensor->buffer = tensor->buffer;
283284
new_tensor->extra = tensor->extra;

0 commit comments

Comments
 (0)