|
|
380d7b |
commit e69d8f8cc7b6418fb290fef993d6c46858391c1e
|
|
|
380d7b |
Author: Paul Moore <pmoore@redhat.com>
|
|
|
380d7b |
Date: Wed Jan 15 09:49:18 2014 -0500
|
|
|
380d7b |
|
|
|
380d7b |
libnetlabel: check the return code of nla_put_nested()
|
|
|
380d7b |
|
|
|
380d7b |
In some cases nla_put_nested() was failing and not being caught by the
|
|
|
380d7b |
library which led to some odd error cases. This patch fixes this by
|
|
|
380d7b |
checking for errors and returning them to the caller.
|
|
|
380d7b |
|
|
|
380d7b |
Signed-off-by: Paul Moore <pmoore@redhat.com>
|
|
|
380d7b |
|
|
|
380d7b |
diff --git a/libnetlabel/mod_cipsov4.c b/libnetlabel/mod_cipsov4.c
|
|
|
380d7b |
index abc7cd6..3316118 100644
|
|
|
380d7b |
--- a/libnetlabel/mod_cipsov4.c
|
|
|
380d7b |
+++ b/libnetlabel/mod_cipsov4.c
|
|
|
380d7b |
@@ -302,7 +302,9 @@ int nlbl_cipsov4_add_trans(struct nlbl_handle *hndl,
|
|
|
380d7b |
if (ret_val != 0)
|
|
|
380d7b |
goto add_std_return;
|
|
|
380d7b |
}
|
|
|
380d7b |
- nla_put_nested(msg, NLBL_CIPSOV4_A_TAGLST, nest_msg_a);
|
|
|
380d7b |
+ ret_val = nla_put_nested(msg, NLBL_CIPSOV4_A_TAGLST, nest_msg_a);
|
|
|
380d7b |
+ if (ret_val != 0)
|
|
|
380d7b |
+ goto add_std_return;
|
|
|
380d7b |
nlbl_msg_free(nest_msg_a);
|
|
|
380d7b |
nest_msg_a = NULL;
|
|
|
380d7b |
|
|
|
380d7b |
@@ -327,11 +329,16 @@ int nlbl_cipsov4_add_trans(struct nlbl_handle *hndl,
|
|
|
380d7b |
lvls->array[iter * 2 + 1]);
|
|
|
380d7b |
if (ret_val != 0)
|
|
|
380d7b |
goto add_std_return;
|
|
|
380d7b |
- nla_put_nested(nest_msg_a, NLBL_CIPSOV4_A_MLSLVL, nest_msg_b);
|
|
|
380d7b |
+ ret_val = nla_put_nested(nest_msg_a, NLBL_CIPSOV4_A_MLSLVL,
|
|
|
380d7b |
+ nest_msg_b);
|
|
|
380d7b |
+ if (ret_val != 0)
|
|
|
380d7b |
+ goto add_std_return;
|
|
|
380d7b |
nlbl_msg_free(nest_msg_b);
|
|
|
380d7b |
nest_msg_b = NULL;
|
|
|
380d7b |
}
|
|
|
380d7b |
- nla_put_nested(msg, NLBL_CIPSOV4_A_MLSLVLLST, nest_msg_a);
|
|
|
380d7b |
+ ret_val = nla_put_nested(msg, NLBL_CIPSOV4_A_MLSLVLLST, nest_msg_a);
|
|
|
380d7b |
+ if (ret_val != 0)
|
|
|
380d7b |
+ goto add_std_return;
|
|
|
380d7b |
nlbl_msg_free(nest_msg_a);
|
|
|
380d7b |
nest_msg_a = NULL;
|
|
|
380d7b |
|
|
|
380d7b |
@@ -356,11 +363,16 @@ int nlbl_cipsov4_add_trans(struct nlbl_handle *hndl,
|
|
|
380d7b |
cats->array[iter * 2 + 1]);
|
|
|
380d7b |
if (ret_val != 0)
|
|
|
380d7b |
goto add_std_return;
|
|
|
380d7b |
- nla_put_nested(nest_msg_a, NLBL_CIPSOV4_A_MLSCAT, nest_msg_b);
|
|
|
380d7b |
+ ret_val = nla_put_nested(nest_msg_a, NLBL_CIPSOV4_A_MLSCAT,
|
|
|
380d7b |
+ nest_msg_b);
|
|
|
380d7b |
+ if (ret_val != 0)
|
|
|
380d7b |
+ goto add_std_return;
|
|
|
380d7b |
nlbl_msg_free(nest_msg_b);
|
|
|
380d7b |
nest_msg_b = NULL;
|
|
|
380d7b |
}
|
|
|
380d7b |
- nla_put_nested(msg, NLBL_CIPSOV4_A_MLSCATLST, nest_msg_a);
|
|
|
380d7b |
+ ret_val = nla_put_nested(msg, NLBL_CIPSOV4_A_MLSCATLST, nest_msg_a);
|
|
|
380d7b |
+ if (ret_val != 0)
|
|
|
380d7b |
+ goto add_std_return;
|
|
|
380d7b |
nlbl_msg_free(nest_msg_a);
|
|
|
380d7b |
nest_msg_a = NULL;
|
|
|
380d7b |
|
|
|
380d7b |
@@ -455,7 +467,9 @@ int nlbl_cipsov4_add_pass(struct nlbl_handle *hndl,
|
|
|
380d7b |
if (ret_val != 0)
|
|
|
380d7b |
goto add_pass_return;
|
|
|
380d7b |
}
|
|
|
380d7b |
- nla_put_nested(msg, NLBL_CIPSOV4_A_TAGLST, nest_msg);
|
|
|
380d7b |
+ ret_val = nla_put_nested(msg, NLBL_CIPSOV4_A_TAGLST, nest_msg);
|
|
|
380d7b |
+ if (ret_val != 0)
|
|
|
380d7b |
+ goto add_pass_return;
|
|
|
380d7b |
|
|
|
380d7b |
/* send the request */
|
|
|
380d7b |
ret_val = nlbl_comm_send(p_hndl, msg);
|
|
|
380d7b |
@@ -539,7 +553,9 @@ int nlbl_cipsov4_add_local(struct nlbl_handle *hndl, nlbl_cv4_doi doi)
|
|
|
380d7b |
ret_val = nla_put_u8(nest_msg, NLBL_CIPSOV4_A_TAG, 128);
|
|
|
380d7b |
if (ret_val != 0)
|
|
|
380d7b |
goto add_local_return;
|
|
|
380d7b |
- nla_put_nested(msg, NLBL_CIPSOV4_A_TAGLST, nest_msg);
|
|
|
380d7b |
+ ret_val = nla_put_nested(msg, NLBL_CIPSOV4_A_TAGLST, nest_msg);
|
|
|
380d7b |
+ if (ret_val != 0)
|
|
|
380d7b |
+ goto add_local_return;
|
|
|
380d7b |
|
|
|
380d7b |
/* send the request */
|
|
|
380d7b |
ret_val = nlbl_comm_send(p_hndl, msg);
|