soc: qcom: pdr: Prefer strscpy over strcpy
strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy(). This is a previous step in the path to remove the strcpy() function entirely from the kernel. Signed-off-by: Len Baker <len.baker@gmx.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Link: https://lore.kernel.org/r/20210808125012.4715-2-len.baker@gmx.com
This commit is contained in:
parent
f69a91e376
commit
26bc7a6a0b
@ -131,7 +131,7 @@ static int pdr_register_listener(struct pdr_handle *pdr,
|
||||
return ret;
|
||||
|
||||
req.enable = enable;
|
||||
strcpy(req.service_path, pds->service_path);
|
||||
strscpy(req.service_path, pds->service_path, sizeof(req.service_path));
|
||||
|
||||
ret = qmi_send_request(&pdr->notifier_hdl, &pds->addr,
|
||||
&txn, SERVREG_REGISTER_LISTENER_REQ,
|
||||
@ -257,7 +257,7 @@ static int pdr_send_indack_msg(struct pdr_handle *pdr, struct pdr_service *pds,
|
||||
return ret;
|
||||
|
||||
req.transaction_id = tid;
|
||||
strcpy(req.service_path, pds->service_path);
|
||||
strscpy(req.service_path, pds->service_path, sizeof(req.service_path));
|
||||
|
||||
ret = qmi_send_request(&pdr->notifier_hdl, &pds->addr,
|
||||
&txn, SERVREG_SET_ACK_REQ,
|
||||
@ -406,7 +406,7 @@ static int pdr_locate_service(struct pdr_handle *pdr, struct pdr_service *pds)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Prepare req message */
|
||||
strcpy(req.service_name, pds->service_name);
|
||||
strscpy(req.service_name, pds->service_name, sizeof(req.service_name));
|
||||
req.domain_offset_valid = true;
|
||||
req.domain_offset = 0;
|
||||
|
||||
@ -531,8 +531,8 @@ struct pdr_service *pdr_add_lookup(struct pdr_handle *pdr,
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
pds->service = SERVREG_NOTIFIER_SERVICE;
|
||||
strcpy(pds->service_name, service_name);
|
||||
strcpy(pds->service_path, service_path);
|
||||
strscpy(pds->service_name, service_name, sizeof(pds->service_name));
|
||||
strscpy(pds->service_path, service_path, sizeof(pds->service_path));
|
||||
pds->need_locator_lookup = true;
|
||||
|
||||
mutex_lock(&pdr->list_lock);
|
||||
@ -587,7 +587,7 @@ int pdr_restart_pd(struct pdr_handle *pdr, struct pdr_service *pds)
|
||||
break;
|
||||
|
||||
/* Prepare req message */
|
||||
strcpy(req.service_path, pds->service_path);
|
||||
strscpy(req.service_path, pds->service_path, sizeof(req.service_path));
|
||||
addr = pds->addr;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user