diff options
author | Simon Buttgereit <simon.buttgereit@gmail.com> | 2017-02-06 17:45:12 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-02-27 15:43:48 (GMT) |
commit | 55490ceea57a0e9f1fef28ee90121e0bd76ef5b5 (patch) | |
tree | e1128ccf81b584b9889a9f5ec16ccc288a67549a /lib | |
parent | 0704cd93f5d314a598def8b28732e145d0ebf85a (diff) | |
download | libnl-55490ceea57a0e9f1fef28ee90121e0bd76ef5b5.zip libnl-55490ceea57a0e9f1fef28ee90121e0bd76ef5b5.tar.gz libnl-55490ceea57a0e9f1fef28ee90121e0bd76ef5b5.tar.bz2 |
fix xfrmnl_sp_set_sec_ctx length attributes
Fixed xfrmnl_sp->sec_ctx length parameters in xfrmnl_sp_set_sec_ctx,
because former use of only one value wasn't right.
Therefore parameter len is unsued and could be removed.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/xfrm/sp.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/xfrm/sp.c b/lib/xfrm/sp.c index 87b4abe..df4f7a2 100644 --- a/lib/xfrm/sp.c +++ b/lib/xfrm/sp.c @@ -1172,21 +1172,33 @@ int xfrmnl_sp_get_sec_ctx (struct xfrmnl_sp* sp, unsigned int* len, unsigned int return 0; } - -int xfrmnl_sp_set_sec_ctx (struct xfrmnl_sp* sp, unsigned int len, unsigned int exttype, unsigned int alg, unsigned int doi, unsigned int ctx_len, char* ctx_str) +/** + * @brief Set security context (ctx_str) for XFRM Polixy. + * + * @param sp XFRM Policy + * @param[in] len !!! depricated unused parameter !!! + * @param[in] exttype netlink message attribute - probably XFRMA_SEC_CTX + * @param[in] alg security context algorithm + * @param[in] doi security context domain interpretation + * @param[in] ctx_len Length of the context string. + * @param ctx_str The context string. + * + * @return 0 if sucessfull, else -1 + */ +int xfrmnl_sp_set_sec_ctx (struct xfrmnl_sp* sp, unsigned int len __attribute__((unused)), unsigned int exttype, unsigned int alg, unsigned int doi, unsigned int ctx_len, char* ctx_str) { /* Free up the old context string and allocate new one */ if (sp->sec_ctx) free (sp->sec_ctx); - if ((sp->sec_ctx = calloc (1, sizeof (struct xfrmnl_user_sec_ctx) + (sizeof (uint8_t) * ctx_len))) == NULL) + if ((sp->sec_ctx = calloc (1, sizeof(struct xfrmnl_user_sec_ctx) + ctx_len)) == NULL) return -1; /* Save the new info */ - sp->sec_ctx->len = len; + sp->sec_ctx->len = sizeof (struct xfrmnl_user_sec_ctx) + ctx_len; sp->sec_ctx->exttype = exttype; sp->sec_ctx->ctx_alg = alg; sp->sec_ctx->ctx_doi = doi; - sp->sec_ctx->ctx_len = len; + sp->sec_ctx->ctx_len = ctx_len; memcpy ((void *)sp->sec_ctx->ctx, (void *)ctx_str, sizeof (uint8_t) * ctx_len); sp->ce_mask |= XFRM_SP_ATTR_SECCTX; |