Commit d09d48f4 authored by Vivek Kumar Dutta's avatar Vivek Kumar Dutta
Browse files

Fix string len

parent aa94767e
Pipeline #19514 passed with stages
in 7 minutes and 7 seconds
......@@ -290,7 +290,7 @@ int http_digest_auth_fail_response(FILE *fp, const char *http_method, const char
{
char header[hlen + 1];
snprintf(header, sizeof(header), "Digest realm=\"%s\",qop=\"auth\",nonce=\"%s\",opaque=\"%s\"%s", realm, nonce, opaque, signal_stale ? ",stale=\"true\"" : "");
snprintf(header, hlen + 1, "Digest realm=\"%s\",qop=\"auth\",nonce=\"%s\",opaque=\"%s\"%s", realm, nonce, opaque, signal_stale ? ",stale=\"true\"" : "");
DD(DEBUG, "%s: header: %s", __FUNCTION__, header);
......
......@@ -72,7 +72,7 @@ static void kernel_api_cwmp_value_change_listener(struct sk_buff *skb)
nlh = nlmsg_put(skb_out, 0, 0, NLMSG_DONE, msg_size, 0);
NETLINK_CB(skb_out).dst_group = 0; /* not in mcast group */
snprintf(nlmsg_data(nlh), msg_size, "%s", msg);
snprintf(nlmsg_data(nlh), msg_size + 1, "%s", msg);
res = nlmsg_unicast(nl_sk, skb_out, pid);
if (i < kernel_cwmp_input.argc) {
......@@ -133,11 +133,11 @@ int kernel_api_cwmp_value_change_call(int count, ...)
if (s == NULL) {
s = NETLINK_NULL;
}
kernel_cwmp_input.argv[i] = kmalloc(strlen(s), GFP_KERNEL);
kernel_cwmp_input.argv[i] = kmalloc(strlen(s + 1), GFP_KERNEL);
if (kernel_cwmp_input.argv[i] == NULL) {
goto kernel_api_cwmp_error;
}
snprintf(kernel_cwmp_input.argv[i], sizeof(kernel_cwmp_input.argv[i]), "%s", s);
snprintf(kernel_cwmp_input.argv[i], strlen(s) + 1, "%s", s);
kernel_cwmp_input.argc++;
}
va_end(args);
......
......@@ -42,9 +42,9 @@ int log_set_severity_idx(char *value)
int log_set_log_file_name(char *value)
{
if (value != NULL) {
snprintf(log_file_name, strlen(value), "%s", value);
snprintf(log_file_name, sizeof(log_file_name), "%s", value);
} else {
snprintf(log_file_name, strlen(DEFAULT_LOG_FILE_NAME), "%s", DEFAULT_LOG_FILE_NAME);
snprintf(log_file_name, sizeof(log_file_name), "%s", DEFAULT_LOG_FILE_NAME);
}
return 1;
}
......@@ -121,7 +121,7 @@ void puts_log(int severity, const char *fmt, ...)
Tm = localtime(&tv.tv_sec);
i = snprintf(buf, sizeof(buf), "%02d-%02d-%4d, %02d:%02d:%02d %s ", Tm->tm_mday, Tm->tm_mon + 1, Tm->tm_year + 1900, Tm->tm_hour, Tm->tm_min, Tm->tm_sec, SEVERITY_NAMES[severity]);
if (strlen(log_file_name) == 0) {
snprintf(log_file_name, strlen(DEFAULT_LOG_FILE_NAME), "%s", DEFAULT_LOG_FILE_NAME);
snprintf(log_file_name, sizeof(log_file_name), "%s", DEFAULT_LOG_FILE_NAME);
}
if (enable_log_file) {
if (stat(log_file_name, &st) == 0) {
......@@ -138,7 +138,7 @@ void puts_log(int severity, const char *fmt, ...)
va_start(args, fmt);
i += vsprintf(buf + i, (const char *)fmt, args);
if (enable_log_file) {
snprintf(buf_file, sizeof(buf), "%s\n", buf);
snprintf(buf_file, sizeof(buf_file), "%s\n", buf);
fputs(buf_file, pLog);
}
va_end(args);
......@@ -181,7 +181,7 @@ void puts_log_xmlmsg(int severity, char *msg, int msgtype)
Tm = localtime(&tv.tv_sec);
snprintf(buf, sizeof(buf), "%02d-%02d-%4d, %02d:%02d:%02d %s ", Tm->tm_mday, Tm->tm_mon + 1, Tm->tm_year + 1900, Tm->tm_hour, Tm->tm_min, Tm->tm_sec, SEVERITY_NAMES[severity]);
if (strlen(log_file_name) == 0) {
snprintf(log_file_name, strlen(DEFAULT_LOG_FILE_NAME), "%s", DEFAULT_LOG_FILE_NAME);
snprintf(log_file_name, sizeof(log_file_name), "%s", DEFAULT_LOG_FILE_NAME);
}
if (msgtype == XML_MSG_IN) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment