Skip to content

Commit

Permalink
snprintf函数第二个参数应该为buf_len + 1 (oceanbase#290)
Browse files Browse the repository at this point in the history
### What problem were solved in this pull request?
计算程序名称时,snprintf函数第二个参数应该为buf_len + 1
  • Loading branch information
haibaoo authored Oct 16, 2023
1 parent 09fe80d commit 2e3394c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deps/common/os/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ std::string get_process_name(const char *prog_name)
std::cerr << "Failed to alloc memory for program name." << SYS_OUTPUT_FILE_POS << SYS_OUTPUT_ERROR << std::endl;
return "";
}
snprintf(buf, buf_len, "%s", prog_name);
snprintf(buf, buf_len + 1, "%s", prog_name);//第二个参数需为buf_len + 1

process_name = basename(buf);

Expand Down

0 comments on commit 2e3394c

Please sign in to comment.