summaryrefslogtreecommitdiffstats
path: root/lib/xfrm/sa.c
Commit message (Collapse)AuthorAgeFilesLines
* xfrm: remove redundant check in xfrm_sa_update_cache()Thomas Haller2024-09-121-1/+1
|
* xfrm: use the new _nl_auto_nl_object helperJonas Gorski2024-09-121-3/+1
| | | | | | | | Analogue to the change for cache_include(), use the new helper for nl_objects and initialize old to NULL since we do not use it for other messages than XFRM_MSG_EXPIRE. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
* all: use defines for attributesThomas Haller2024-04-221-2/+2
| | | | We have those defines. Use them throughout.
* xfrm: return -NLE_MISSING_ATTR from xfrmnl_sa_get_auth_params()Thomas Haller2023-12-041-13/+10
| | | | | | Don't return -1, that is not an error code. Also, return early from function.
* xfrm: refactor error handling in XFRM parsingThomas Haller2023-11-291-73/+37
| | | | Use cleanup attribute and return-early.
* xfrm: fix crashes in case of ENOMEMThomas Haller2023-11-291-8/+26
|
* xfrm: refactor nl_addr_build() calls in XFRM codeThomas Haller2023-11-291-30/+8
| | | | Use _nl_addr_build() helper. No need for all this redundant code.
* xfrm: use cleanup attribute for nl_addr in XFRM parsingThomas Haller2023-11-291-13/+11
|
* lib/xfrm: use thread-safe gmtime_r() instead of gmtime()Thomas Haller2023-08-181-2/+3
|
* include: drop "netlink-private/netlink.h" and move declarationsThomas Haller2023-08-021-2/+2
|
* all: cleanup includes and use "nm-default.h"Thomas Haller2023-08-021-1/+2
|
* include: split and drop "netlink-private/types.h"Thomas Haller2023-08-021-2/+77
| | | | | Move all the declarations from "netlink-private/types.h" to places closer to where they are used.
* base: move "netlink-private/utils.h" to "base/nl-base-utils.h"Thomas Haller2023-07-311-1/+1
| | | | | | | | | | "base/nl-base-utils.h" (formerly "netlink-private/utils.h") contains no libnl3 specific references, just a bunch of C helpers. It's also a header-only "library", so it can be freely used by all our C-code. Move it to a separate directory, to make that clear.
* all: rework ATTR_DIFF() macros to not generate attribute namesThomas Haller2023-07-281-46/+57
| | | | | | | | | | I find macros that stitch together names like "FAMILY_ATTR_##ATTR" very confusing, because we no longer see where a certain name is used. It breaks grepping for symbols, and it breaks cscope. Yes, it's more verbose to not do that. If you really think that those names are too verbose, then maybe they should get a shorter name. And not use macros to make them palatable.
* xfrm/sa: fix reference counters of sa selector addressesNeil Horman2022-04-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | valgrind reported this memory leak to me in testing an application that I'm building: ==1807969== 24 bytes in 1 blocks are definitely lost in loss record 2 of 12 ==1807969== at 0x4849464: calloc (vg_replace_malloc.c:1328) ==1807969== by 0x160F2F: nl_addr_alloc (addr.c:184) ==1807969== by 0x160F2F: nl_addr_build (addr.c:215) ==1807969== by 0x15CEF1: xfrmnl_sa_parse (sa.c:693) ==1807969== by 0x18F95D: parse_sa (xfrm_monitor.c:82) ==1807969== by 0x18FC5A: parse_nlmsg (xfrm_monitor.c:170) ==1807969== by 0x18FC5A: xfrm_cb (xfrm_monitor.c:181) ==1807969== by 0x169D21: nl_cb_call (netlink.h:138) ==1807969== by 0x169D21: recvmsgs (nl.c:868) ==1807969== by 0x16A42C: nl_recvmsgs_report (nl.c:1051) ==1807969== by 0x16A42C: nl_recvmsgs (nl.c:1075) ==1807969== by 0x16A42C: nl_recvmsgs_default (nl.c:1089) ==1807969== by 0x18FD6F: monitor_xfrm (xfrm_monitor.c:233) ==1807969== by 0x49D8B19: start_thread (pthread_create.c:443) ==1807969== by 0x4A5C8F3: clone (clone.S:100) when calling xfrmnl_sa_parse, we accidentally get a refcount of 2 on the selector source and destination addresses. The nl_addr_build calls for these addresses set the count to one, and the subsequent calls to xfrmnl_sel_set_[s|d]addr increase the reference count to two. One of the references is dropped when we call xfrmnl_sa_put, which calls down through xfrmnl_sa_free_data->xfrmnl_sel_put->nl_addr_put(), but the other reference count is leaked, leading to the above leak of both the saddr and daddr pointers. Not sure if this is the ideal fix, but it works for me, we just drop the refrence count incremented by the call to set_[s|d]addr. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> https://github.com/thom311/libnl/pull/312
* all: fix "-Wformat" warnings for nl_dump*()Thomas Haller2022-04-221-6/+15
|
* lib: make nl_object_clone() out-of-memory safeThomas Haller2022-03-161-0/+14
| | | | | | | | | | | | | | | | | nl_object_clone() first does a shallow copy using memcpy(). That is useful, because it can correctly copy simple fields (like numbers). For pointer values, we need to implement oo_clone() to fixup the pointers and get the deep-copy correct. Now, oo_clone() must always follow through, to un-alias the copied pointer. In particular also in the error case. The oo_clone() implementations sometimes fail (with ENOMEM) and just return. In those cases, we must make sure that we don't leave the wrong pointers there. The pointers must be cleared first. Otherwise, any failure (which basically are ENOMEM) leave the object in an inconsistent state, and we double-free/use-after-free the pointers.
* xfrm/sa: clone user_offload in xfrm_sa_clone()Thomas Haller2022-03-161-0/+6
|
* xfrm/sa: style cleanup xfrm_sa_clone()Thomas Haller2022-03-161-14/+7
|
* xfrm: ensure minlen in policy for XFRMA_OFFLOAD_DEVThomas Haller2022-03-031-0/+1
| | | | | | Otherwise, we cannot just access the netlink attribute and be sure it has the right size. Add the length to the policy, so it gets validated.
* xfrm: Add support for xfrm user offloadingThomas Egerer2022-03-031-0/+86
| | | | Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
* zero stack allocated memory in xfrmnl_build_sa_delete_requestNeil Horman2022-03-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running valgrind on an application that uses xfrmnl_build_sa_delete_request, it reports the following error: ==783216== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s) ==783216== at 0x4DF771D: sendmsg (in /usr/lib64/libpthread-2.33.so) ==783216== by 0x48627D9: nl_sendmsg (nl.c:336) ==783216== by 0x4862993: nl_send_iovec (nl.c:401) ==783216== by 0x48629F9: nl_send (nl.c:453) ==783216== by 0x48629F9: nl_send (nl.c:441) ==783216== by 0x4931B89: xfrmnl_sa_delete (sa.c:1379) ==783216== by 0x40A390: delete_associated_state (net-api.c:88) ==783216== by 0x40C191: del_tunnel (net-api.c:883) ==783216== by 0x414EB0: net_api_test_tunnel (net-api_test.c:181) ==783216== by 0x4DD763A: ??? (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x4DD79C0: ??? (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x4DD8966: CU_run_all_tests (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x422E13: RunAllTests (test.c:87) ==783216== by 0x422FA9: main (test.c:150) ==783216== Address 0x5217394 is 20 bytes inside a block of size 4,096 alloc'd ==783216== at 0x4845464: calloc (vg_replace_malloc.c:1117) ==783216== by 0x4860CF5: __nlmsg_alloc (msg.c:269) ==783216== by 0x4860FFE: nlmsg_inherit (msg.c:321) ==783216== by 0x4861091: nlmsg_alloc_simple (msg.c:352) ==783216== by 0x4931AA5: build_xfrm_sa_delete_message (sa.c:1340) ==783216== by 0x4931AA5: xfrmnl_sa_build_delete_request (sa.c:1367) ==783216== by 0x4931B58: xfrmnl_sa_delete (sa.c:1375) ==783216== by 0x40A390: delete_associated_state (net-api.c:88) ==783216== by 0x40C191: del_tunnel (net-api.c:883) ==783216== by 0x414EB0: net_api_test_tunnel (net-api_test.c:181) ==783216== by 0x4DD763A: ??? (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x4DD79C0: ??? (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x4DD8966: CU_run_all_tests (in /usr/lib64/libcunit.so.1.0.1) ==783216== by 0x422E13: RunAllTests (test.c:87) ==783216== by 0x422FA9: main (test.c:150) ==783216== Uninitialised value was created by a stack allocation ==783216== at 0x492DA10: ??? (in /home/nhorman/git/privafy/microedge-c/external_libs/install/lib/libnl-xfrm-3.so.200.26.0) It occurs because the sa_id value thats allocated on the stack isn't completely initalized (if you're using ipv4, the daddr winds up with garbage in the extra bytes). Its not critical, but it would be nice to avoid sending that garbage into the kernel, and it would silence the valgrind error. Easy fix, just memset the sa_id before copying it into the nlmsg. Signed-off-by: Neil Horman <nhorman@gmail.com> https://github.com/thom311/libnl/pull/297
* xfrm: remove superfluous xfrm_usersa_id from dump requestThomas Egerer2020-04-161-5/+1
| | | | | | | | | | | | | | | When being used with the dump flag, the kernel dispatches the request to xfrm_dump_sa. This function does not expect the netlink message to contain a struct xfrm_usersa_id as data payload of the netlink message. Instead it interprets this payload as xfrm attributes. With the current implementation, due to the sa_id being memset to zero, it causes the kernel to complain about '24 bytes leftover after parsing attributes [...]'. This patch removes payload to get rid of the kernel complaint. Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com> https://github.com/thom311/libnl/pull/233
* lib: use _nl_strncpy*() instead of plain strncpy()Thomas Haller2020-04-151-2/+1
| | | | | | | | | | | | | | | | There wasn't really a bug previously, but it's ugly and raises questions about the correct use of strncpy(). For example, void genl_family_set_name(struct genl_family *family, const char *name) { strncpy(family->gf_name, name, GENL_NAMSIZ-1); was in fact correct, because family->gf_name will (presumably) always have a NUL character as last position. Still use _nl_strncpy*() wrappers, to avoid raising such questions.
* all: Avoid pointer arithmetic on `void *`Michael Forney2019-08-161-1/+1
| | | | | | | ISO C requires that the pointer operand to the binary + operator be to a complete object type[0]. [0] http://port70.net/~nsz/c/c11/n1570.html#6.5.6p2
* dbg: Use __func__ instead of __PRETTY_FUNCTION__Michael Forney2019-08-161-1/+1
| | | | | | | | These behave the same, except when used at top-level. This can't happen since the macro body is a statement. __func__ is standardized since C99, while __PRETTY_FUNCTION__ is a GNU extension.
* Add SPDX identifiersYegor Yefremov2019-08-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Software Package Data Exchange identifiers help to detect source file licenses and hence simplify the FOSS compliance process. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> https://github.com/thom311/libnl/pull/219 --- FILES=( lib/addr.c lib/attr.c lib/cache.c lib/cache_mngr.c lib/cache_mngt.c lib/data.c lib/error.c lib/fib_lookup/lookup.c lib/fib_lookup/request.c lib/genl/ctrl.c lib/genl/family.c lib/genl/genl.c lib/genl/mngt.c lib/handlers.c lib/hash.c lib/hashtable.c lib/idiag/idiag.c lib/idiag/idiag_meminfo_obj.c lib/idiag/idiag_msg_obj.c lib/idiag/idiag_req_obj.c lib/idiag/idiag_vegasinfo_obj.c lib/mpls.c lib/msg.c lib/netfilter/ct.c lib/netfilter/ct_obj.c lib/netfilter/exp.c lib/netfilter/exp_obj.c lib/netfilter/log.c lib/netfilter/log_msg.c lib/netfilter/log_msg_obj.c lib/netfilter/log_obj.c lib/netfilter/netfilter.c lib/netfilter/nfnl.c lib/netfilter/queue.c lib/netfilter/queue_msg.c lib/netfilter/queue_msg_obj.c lib/netfilter/queue_obj.c lib/nl.c lib/object.c lib/route/act.c lib/route/addr.c lib/route/class.c lib/route/classid.c lib/route/cls.c lib/route/link.c lib/route/neigh.c lib/route/neightbl.c lib/route/netconf.c lib/route/nexthop.c lib/route/nexthop_encap.c lib/route/nh_encap_mpls.c lib/route/pktloc.c lib/route/qdisc.c lib/route/route.c lib/route/route_obj.c lib/route/route_utils.c lib/route/rtnl.c lib/route/rule.c lib/route/tc.c lib/socket.c lib/utils.c lib/version.c lib/xfrm/ae.c lib/xfrm/lifetime.c lib/xfrm/sa.c lib/xfrm/selector.c lib/xfrm/sp.c lib/xfrm/template.c src/genl-ctrl-list.c src/idiag-socket-details.c src/lib/addr.c src/lib/class.c src/lib/cls.c src/lib/ct.c src/lib/exp.c src/lib/link.c src/lib/neigh.c src/lib/qdisc.c src/lib/route.c src/lib/rule.c src/lib/tc.c src/lib/utils.c src/nf-ct-add.c src/nf-ct-events.c src/nf-ct-list.c src/nf-exp-add.c src/nf-exp-delete.c src/nf-exp-list.c src/nf-log.c src/nf-monitor.c src/nf-queue.c src/nl-addr-add.c src/nl-addr-delete.c src/nl-addr-list.c src/nl-class-add.c src/nl-class-delete.c src/nl-class-list.c src/nl-classid-lookup.c src/nl-cls-add.c src/nl-cls-delete.c src/nl-cls-list.c src/nl-fib-lookup.c src/nl-link-enslave.c src/nl-link-ifindex2name.c src/nl-link-list.c src/nl-link-name2ifindex.c src/nl-link-release.c src/nl-link-set.c src/nl-link-stats.c src/nl-list-caches.c src/nl-list-sockets.c src/nl-monitor.c src/nl-neigh-add.c src/nl-neigh-delete.c src/nl-neigh-list.c src/nl-neightbl-list.c src/nl-pktloc-lookup.c src/nl-qdisc-add.c src/nl-qdisc-delete.c src/nl-qdisc-list.c src/nl-route-add.c src/nl-route-delete.c src/nl-route-get.c src/nl-route-list.c src/nl-rule-list.c src/nl-tctree-list.c src/nl-util-addr.c ) sed '1s#^#/* SPDX-License-Identifier: LGPL-2.1-only */\n#' "${FILES[@]}" -i
* xfrm: fix memory corruption (dangling pointer) when when setting xfrmnl_saThomas Haller2019-08-091-71/+74
| | | | | | | | | | | | | | | | | | | | | | The follow leaves a dangling pointer when the name argument is too long: xfrmnl_sa_set_aead_params: if (sa->aead) free (sa->aead); if ( strlen (alg_name) >= sizeof (sa->aead->alg_name) || (sa->aead = calloc (1, newlen)) == NULL) return -1; Fix that, but do more: - ensure that we don't modify the object when the setter is going to fail. That means, first check whether we can succeed with all the steps that are requested, and (in case we cannot) fail without modifing the target object. - bonus points for making the setter self-assignment safe by reordering the setting and freeing of the memory.
* route: fix strncpy() warning from coverity about unterminated stringThomas Haller2019-08-081-0/+1
| | | | | | | | | | | | | | | | | | | | Coverity says: Error: BUFFER_SIZE_WARNING (CWE-120): [#def1] libnl-3.4.0/lib/route/cls/ematch/text.c:94: buffer_size_warning: Calling strncpy with a maximum size argument of 16 bytes on destination array "t->cfg.algo" of size 16 bytes might leave the destination string unterminated. # 92| struct text_data *t = rtnl_ematch_data(e); # 93| # 94|-> strncpy(t->cfg.algo, algo, sizeof(t->cfg.algo)); # 95| } # 96| Error: BUFFER_SIZE_WARNING (CWE-120): [#def11] libnl-3.4.0/lib/xfrm/sa.c:1192: buffer_size_warning: Calling strncpy with a maximum size argument of 64 bytes on destination array "auth->alg_name" of size 64 bytes might leave the destination string unterminated. # 1190| } # 1191| # 1192|-> strncpy(auth->alg_name, tmpl->auth->alg_name, sizeof(auth->alg_name)); # 1193| auth->alg_key_len = tmpl->auth->alg_key_len; # 1194| memcpy(auth->alg_key, tmpl->auth->alg_key, (tmpl->auth->alg_key_len + 7) / 8);
* xfrm: NUL terminate the ctx_str buffer in xfrmnl_sa_set_sec_ctx()Thomas Haller2017-02-271-1/+2
| | | | | | | and xfrmnl_sp_set_sec_ctx(). The user already must pass a NUL terminated string, where the NUL is included in ctx_len. Just allocate one more by and ensure the buffer is '\0' terminated.
* xfrm/sa: Include own public header for function prototypesTobias Klauser2017-01-201-0/+1
| | | | | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings. Also adjust the function prototype of xfrmnl_sa_get_sec_ctx() to match the definition. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* cache_mngr: add include callback v2Tobias Jungel2016-12-011-7/+24
| | | | | | | | | | | | | | | | | | | | | This patch adds change_func_v2_t to add a more detailed callback in case of a cache change. The change function is registered using the new nl_cache_mngr_add_cache_v2. In case the new change function is set, nl_cache_include_v2 and thus cache_include_v2 will be used to perform the cache inclusion. The parameter of change_func_v2_t are the following: * struct nl_cache * => cache * struct nl_object * => the old/deleted nl_object * struct nl_object * => the new nl_object * uint64_t => the result of nl_object_diff64 in case of a change * int => NL_ACT_* * void * => data https://github.com/thom311/libnl/issues/71 http://lists.infradead.org/pipermail/libnl/2016-September/002214.html http://lists.infradead.org/pipermail/libnl/2016-October/002229.html http://lists.infradead.org/pipermail/libnl/2016-November/002250.html
* xfrm: add capability reference to xfrmnl_sa_set_*Thomas Egerer2016-11-061-0/+8
| | | | | | | Just for consistency(tm)'s sake: add the reference to what capability introduced the modified API. Signed-off-by: Thomas Egerer <hakke_007@gmx.de>
* xfrm: fix xfrm security context managementThomas Egerer2016-11-061-19/+56
| | | | | | | | | | | | | | | | The data structure of choice when adding/processing a security context for xfrm is struct xfrm(nl)_user_sec_ctx. The previous code did however use the (also exported) struct xfrm(nl)_sec_ctx. While sizeof(struct xfrm(nl)_*sec_ctx) yields the same result, the interpretation of one of the data structures as the other one messes up the contents. With this fix, the wrong data structure has been replaced with the correct one. Also -- since the size of the context string is not known -- one can now call xfrmnl_sa_get_sec_ctx with ctx_str being NULL, thus retrieving the length of the context string. A new capability has been introduced, to test whether libnl3 supports the modified semantics of this function. Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
* xfrm: fix memleak in another error path of build_xfrm_sa_messagePeter Wu2016-08-141-1/+4
| | | | | Signed-off-by: Peter Wu <peter@lekensteyn.nl> Signed-off-by: Thomas Haller <thaller@redhat.com>
* trivial: whitespace-only fixes for src and libPeter Wu2016-08-121-2/+2
| | | | | | | | | | | Fixes alignment, lines with just whitespace and mixed tab/space indentation. Searched, reviewed and optionally fixed in vim using regex ^\t* [\t ]*\([^*us ]\|$\)\|\t\+$ http://lists.infradead.org/pipermail/libnl/2016-August/002183.html Signed-off-by: Peter Wu <peter@lekensteyn.nl> Signed-off-by: Thomas Haller <thaller@redhat.com>
* xfrm: allow avoiding buffer overflow for key in xfrmnl_sa_get_*_params()Thomas Haller2016-06-291-14/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous API of xfrmnl_sa_get_*_params() would always require a @key buffer, but it was not possible to avoid buffer overflow because the required size was unknown. That is not really fixable, because the old API is broken. Now, allow omitting the @key argument to only request the @key_size. That allows the caller to ask beforehand how large the @key buffer must be: ((@key_size + 7) / 8). Unfortunately, omitting the key against previous versions of libnl leads to a crash. And passing a key against older versions makes it impossible to avoid buffer-overflow. Another option would be to add functions like xfrmnl_sa_get_crypto_params_keylen() so the user can query the required buffer size by calling that instead of xfrmnl_sa_get_crypto_params(). However, then the user also requires a backport of the new API and this will not be possible against older libnl3 versions either. Thus, if the user already requires the fix, he can just as well require a backport of this patch and then safely call xfrmnl_sa_get_crypto_params() without @key argument. This way has the advantage/disadvantage, that it can detect the presence of the patch at runtime. The cumbersome way to get it right would be: unsiged key_len; char *key; int r; if (!nl_has_capability(17 /*NL_CAPABILITY_XFRM_SA_KEY_SIZE*/)) { /* no way to use this API safely. Abort. */ return -NLE_OPNOTSUPP; } r = xfrmnl_sa_get_crypto_params(sa, NULL, &key_len, NULL); if (r < 0) return r; key = malloc((key_len + 7) / 8); if (!key) return -NLE_NOMEM; r = xfrmnl_sa_get_crypto_params(sa, NULL, &key_len, &key); if (r < 0) { free(key); return r; } ... http://lists.infradead.org/pipermail/libnl/2016-June/002155.html Signed-off-by: Thomas Haller <thaller@redhat.com>
* xfrm: fix memleak in build_xfrm_sa_message() error-pathThomas Haller2016-06-251-1/+3
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* xfrm: attach only one xfrm alg attribute to netlink messageThomas Egerer2016-06-251-14/+19
| | | | | | | | | | | | | The kernel only uses the xfrm alg auth attribute if the xfrm alg auth truncated attribute is not present. Hence sending both attributes in one message does not make sense. This piece of code also removes the call to nla_reserve in favor of the NLA_PUT macro. Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com> Signed-off-by: Thomas Haller <thaller@redhat.com> http://lists.infradead.org/pipermail/libnl/2016-June/002139.html
* xfrm: fix memory leak for encap original addressThomas Egerer2016-06-251-2/+5
| | | | | | | Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com> Signed-off-by: Thomas Haller <thaller@redhat.com> http://lists.infradead.org/pipermail/libnl/2016-June/002141.html
* xfrm: reuse encap data in xfrmnl_sa_set_encap_tmpl()Thomas Haller2016-06-251-3/+2
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* xfrm: fix segfault when using encapsulation templatesThomas Egerer2016-06-251-3/+8
| | | | | | | Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com> Signed-off-by: Thomas Haller <thaller@redhat.com> http://lists.infradead.org/pipermail/libnl/2016-June/002140.html
* xfrm: make character pointers in setters constThomas Egerer2016-06-251-10/+10
| | | | | | | | | | | | All of these pointers are either strcpy'd or memcpy'd and usually const in a calling application. Changing them to const in the header does not break the compatibility and allows for users with const pointers to use the library without compiler warnings. Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com> Signed-off-by: Thomas Haller <thaller@redhat.com> http://lists.infradead.org/pipermail/libnl/2016-June/002137.html
* xfrm: check length of alg_name before strcpying itThomas Egerer2016-06-251-4/+4
| | | | | | | | | | | | | | | If the parameter alg_name points to a string longer then what libnl accepts as alg_name, the call to strcpy may write far beyond the particular data structure. Instead of truncating the string (using strncpy) this patch adds a check and returns -1 for strings being longer than 63 bytes. Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com> Signed-off-by: Thomas Haller <thaller@redhat.com> Fixes: 917154470895520a77f527343f3a0cc1605934b0 http://lists.infradead.org/pipermail/libnl/2016-May/002133.html
* xfrm: fix buffer overflow when copying keysThomas Egerer2016-06-251-8/+12
| | | | | | | | | | | | | | | A colleague of mine came to notice that -- when adding keys to the xfrm-part of libnl -- memcpy is given newlen, which copies sizeof(struct xfrmnl_...) plus keysize instead of only the keysize. This patch uses a keysize parameter to only copy the required number of bytes. Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com> Signed-off-by: Thomas Haller <thaller@redhat.com> Fixes: 917154470895520a77f527343f3a0cc1605934b0 http://lists.infradead.org/pipermail/libnl/2016-May/002132.html
* lib: update ce-mask to uint64_tDavid Ahern2016-02-121-2/+3
| | | | | | | | | | | | | | | | | | | | lib/route/link.c already defines 32 attributes which fills the current uint32_t used for ce_mask. To accommodate more attributes the mask needs to be expanded. This patch updates the definition to uint64_t. The nl_object_diff API is maintained for ABI with existing users. A new nl_object_diff64 API is added for the expanded attribute list. The MSB of the 32-bit API is used to indicate if higher order attributes had a mismatch. (Suggested by Thomas). Note that LINK_ATTR_LINK_NETNSID changes. But since the attribute flags are not public API it shouldn't be a problem. http://lists.infradead.org/pipermail/libnl/2015-December/002078.html http://lists.infradead.org/pipermail/libnl/2015-December/002083.html Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* xfrm: trival refactoring initialization of stack-allocated arguments to ↵Thomas Haller2015-05-121-3/+4
| | | | | | nl_send_simple() Signed-off-by: Thomas Haller <thaller@redhat.com>
* xfrm: fix xfrm_sa_msg_parser() to return the value from the callbackNicolas PLANEL2014-08-271-1/+1
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* xfrm: Remove unused variable sp_id and sa_idThomas Graf2014-08-261-2/+0
| | | | | | Cc: Sruthi Yellamraju <ysruthi@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* style: require comma after __ADD() macroThomas Haller2014-07-271-40/+40
| | | | | | | $ sed -i 's/^\([\t ]\+\<__ADD\> \?([^)]\+)\) *$/\1,/' `git grep -w -l __ADD` Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>