代码拉取完成,页面将自动刷新
同步操作将从 ChendongSun/myfun 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
int check_sha256(const char *data, size_t len, const char *sha256_str)
{
unsigned char sha256[SHA256_DIGEST_LENGTH];
char sha256_hex[2 * SHA256_DIGEST_LENGTH + 1];
int i;
// Compute SHA-256 of the input data
SHA256((const unsigned char *)data, len, sha256);
// Convert SHA-256 to hexadecimal string
for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
sprintf(&sha256_hex[2 * i], "%02x", sha256[i]);
}
sha256_hex[2 * SHA256_DIGEST_LENGTH] = '\0';
// Compare the computed SHA-256 with the given SHA-256 string
return strcmp(sha256_hex, sha256_str) == 0;
}
int main()
{
const char *data = "Hello, world!";
const char *sha256_str = "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9";
if (check_sha256(data, strlen(data), sha256_str)) {
printf("SHA-256 check passed!\n");
} else {
printf("SHA-256 check failed!\n");
}
return 0;
}
#######################
int64_t qmp_guest_exec_cmd(const char *filetype,
const char *filename,
const char *arg,
const char *sha256,
Error **errp)
{
int iRet = 0;
int dwRet = 0;
int exit = -1;
char pszCommand[BUFFER_SIZE] = {0};
iRet = CheckArg(filetype, filename, arg, sha256);
/*For security reasons, the command parameters are not printed.*/
slog(SLOG_INFO, "try guest-exec-cmd: %s, %s, %s", filetype, filename, sha256);
if(EXEC_ARG_OK == iRet)
{
if(snprintf(pszCommand, BUFFER_SIZE, "timeout 30 %s %s%s %s",
filetype, GUEST_CMD_FILE_PATH, filename, arg) < 0)
{
PERROR("snprintf_s failed.");
return EXEC_FAILED;
}
exit = system(pszCommand);
dwRet = WEXITSTATUS(exit);
if (SHELL_TIMEOUT_RET == dwRet)
{
/* timeout return 124 */
PERROR("execmd %s timeout.", pszCommand);
iRet = EXEC_CMD_TIME_OUT;
}
else if (dwRet)
{
PERROR("execmd %s, ret %d.", pszCommand, dwRet);
iRet = EXEC_FAILED;
}
else
{
iRet = EXEC_DONE;
}
}
return iRet;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。