Skip to content

Commit 573c0eb

Browse files
committed
nacm BUGFIX memory leak
The rule_name string is copied and must be properly freed, otherwise it causes a leak. I triggered it in sysrepo-cpp tests after wrapping sr_nacm_check_operation function in sysrepo-cpp. LSAN report follows: ==381000==ERROR: LeakSanitizer: detected memory leaks Direct leak of 2 byte(s) in 1 object(s) allocated from: #0 0x5d551e1cb56a in strdup (/build/sysrepo-cpp/build-clang-asan/test-session+0x1ae56a) (BuildId: d78ee32ce1fd55641090ef563448cfd2bd45b112) sysrepo#1 0x7606a2a071f5 in sr_nacm_check_op /build/sysrepo/src/utils/nacm.c:1785:36 sysrepo#2 0x7606a2a0c796 in sr_nacm_check_operation /build/sysrepo/src/utils/nacm.c:1809:21 sysrepo#3 0x7606a382b0b0 in sysrepo::Session::checkNacmOperation(libyang::DataNode const&) const /build/sysrepo-cpp/src/Session.cpp:727:16 sysrepo#4 0x5d551e2428fc in DOCTEST_ANON_FUNC_2() /build/sysrepo-cpp/tests/session.cpp:459:9 sysrepo#5 0x5d551e2bbc8e in doctest::Context::run() /build/build/prefixes/clang-asan/include/doctest/doctest.h:7007:21 sysrepo#6 0x5d551e2c0702 in main /build/build/prefixes/clang-asan/include/doctest/doctest.h:7085:71 sysrepo#7 0x7606a2c35487 in __libc_start_call_main /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h:58:16 sysrepo#8 0x7606a2c3554b in __libc_start_main /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:360:3 sysrepo#9 0x5d551e0de564 in _start (/build/sysrepo-cpp/build-clang-asan/test-session+0xc1564) (BuildId: d78ee32ce1fd55641090ef563448cfd2bd45b112) Fixes: 1382043 ("nacm UPDATE explicit func for op checking")
1 parent 3f74424 commit 573c0eb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/utils/nacm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,7 @@ sr_nacm_check_operation(sr_session_ctx_t *session, const struct lyd_node *op)
18261826
}
18271827

18281828
cleanup:
1829+
free(denied.rule_name);
18291830
return sr_api_ret(session, err_info);
18301831
}
18311832

0 commit comments

Comments
 (0)