]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Check for NULL return from xlat_register() (CID #1507059) (#4721)
authorJames Jones <jejones3141@gmail.com>
Mon, 12 Sep 2022 23:30:52 +0000 (18:30 -0500)
committerGitHub <noreply@github.com>
Mon, 12 Sep 2022 23:30:52 +0000 (19:30 -0400)
Barring issues with args, xlat_func_args() will dereference the
xlat_t * handed it, and xlat_register()'s callers do check for
error return, so it makes sense to check what xlat_register()
returns and return error in that case.

src/lib/unlang/xlat_builtin.c

index d452a5f825441026cb44220d0e3c19d4c84e6e11..c623d7927857d2922e088e3726da19466ca87f45 100644 (file)
@@ -3850,6 +3850,7 @@ static int xlat_protocol_register(fr_dict_t const *dict)
                snprintf(buffer, sizeof(buffer), "decode.%s", name);
 
                xlat = xlat_register(NULL, buffer, protocol_decode_xlat, NULL);
+               if (!xlat) return -1;
                xlat_func_args(xlat, protocol_decode_xlat_args);
                /* coverity[suspicious_sizeof] */
                xlat_async_instantiate_set(xlat, protocol_xlat_instantiate, fr_test_point_pair_decode_t *, NULL, tp_decode);
@@ -3865,6 +3866,7 @@ static int xlat_protocol_register(fr_dict_t const *dict)
                snprintf(buffer, sizeof(buffer), "encode.%s", name);
 
                xlat = xlat_register(NULL, buffer, protocol_encode_xlat, NULL);
+               if (!xlat) return -1;
                xlat_func_args(xlat, protocol_encode_xlat_args);
                /* coverity[suspicious_sizeof] */
                xlat_async_instantiate_set(xlat, protocol_xlat_instantiate, fr_test_point_pair_encode_t *, NULL, tp_encode);