diff mbox series

IPC: Add bounds check for SET_UPDATE_STATE IPC call

Message ID 20200922092415.27770-1-christian.storm@siemens.com
State Accepted
Headers show
Series IPC: Add bounds check for SET_UPDATE_STATE IPC call | expand

Commit Message

Storm, Christian Sept. 22, 2020, 9:24 a.m. UTC
Add a check to assert that the SET_UPDATE_STATE IPC call
was issued with valid values from update_state_t.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 core/network_thread.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Stefano Babic Sept. 22, 2020, 10:40 a.m. UTC | #1
On 22.09.20 11:24, Christian Storm wrote:
> Add a check to assert that the SET_UPDATE_STATE IPC call
> was issued with valid values from update_state_t.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  core/network_thread.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/core/network_thread.c b/core/network_thread.c
> index 7b2d796..57d65bb 100644
> --- a/core/network_thread.c
> +++ b/core/network_thread.c
> @@ -408,8 +408,10 @@ void *network_thread (void *data)
>  				break;
>  			case SET_UPDATE_STATE:
>  				value = *(update_state_t *)msg.data.msg;
> -				ret = save_state((char *)STATE_KEY, value);
> -				msg.type = (ret == 0) ? ACK : NACK;
> +				msg.type = (is_valid_state(value) &&
> +					    save_state((char *)STATE_KEY, value) == SERVER_OK)
> +					       ? ACK
> +					       : NACK;
>  				break;
>  			default:
>  				msg.type = NACK;
> 

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/core/network_thread.c b/core/network_thread.c
index 7b2d796..57d65bb 100644
--- a/core/network_thread.c
+++ b/core/network_thread.c
@@ -408,8 +408,10 @@  void *network_thread (void *data)
 				break;
 			case SET_UPDATE_STATE:
 				value = *(update_state_t *)msg.data.msg;
-				ret = save_state((char *)STATE_KEY, value);
-				msg.type = (ret == 0) ? ACK : NACK;
+				msg.type = (is_valid_state(value) &&
+					    save_state((char *)STATE_KEY, value) == SERVER_OK)
+					       ? ACK
+					       : NACK;
 				break;
 			default:
 				msg.type = NACK;