From 5314e3fc061040d21343036dcecbda701beb4874 Mon Sep 17 00:00:00 2001 From: Giridhar Prasath R Date: Tue, 9 Jul 2024 11:56:29 -0400 Subject: [PATCH] Review comment fixes --- librz/arch/analysis.c | 2 +- librz/core/cmd/cmd_search_rop.c | 6 ++---- librz/include/rz_rop.h | 7 ++++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/librz/arch/analysis.c b/librz/arch/analysis.c index 990497c256c..cc5814a4488 100644 --- a/librz/arch/analysis.c +++ b/librz/arch/analysis.c @@ -253,7 +253,7 @@ RZ_API char *rz_analysis_get_reg_profile(RzAnalysis *analysis) { * in the register profile of the given RzAnalysis. */ RZ_API bool rz_analysis_is_reg_in_profile(RzAnalysis *analysis, const char *str) { - rz_return_val_if_fail(analysis, false); + rz_return_val_if_fail(analysis && str, false); char *reg_prof = rz_analysis_get_reg_profile(analysis); if (!reg_prof) { diff --git a/librz/core/cmd/cmd_search_rop.c b/librz/core/cmd/cmd_search_rop.c index d35003ba0ae..3b1a7f13c43 100644 --- a/librz/core/cmd/cmd_search_rop.c +++ b/librz/core/cmd/cmd_search_rop.c @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2009-2016 Alexandru Caciulescu +// SPDX-FileCopyrightText: 2024 z3phyr // SPDX-License-Identifier: LGPL-3.0-only #include @@ -119,9 +119,7 @@ static bool parse_reg_to_const(const RzCore *core, const char *str, RzRopConstra rop_constraint->type = MOV_CONST; rop_constraint->args[DST_REG] = dst_reg; rop_constraint->args[SRC_REG] = NULL; - char value_str[256]; - rz_strf(value_str, "%" PFMT64u, const_value); - rop_constraint->args[SRC_CONST] = strdup(value_str); + rop_constraint->args[SRC_CONST] = rz_str_newf("%" PFMT64u, const_value); return true; } diff --git a/librz/include/rz_rop.h b/librz/include/rz_rop.h index c7787b32c91..a136c2e7a4c 100644 --- a/librz/include/rz_rop.h +++ b/librz/include/rz_rop.h @@ -5,7 +5,9 @@ #define RZ_ROP_H #include - +#ifdef __cplusplus +extern "C" { +#endif /** * \file rz_rop.h * \brief Return-Oriented Programming (ROP) related APIs and structures.. @@ -133,4 +135,7 @@ RZ_IPI void rz_core_rop_reg_info_free(RzRopRegInfo *reg_info); RZ_IPI RzRopRegInfo *rz_core_rop_reg_info_new(const RzCore *core, const RzILEvent *evt, ut64 init_val, ut64 new_val); RZ_BORROW RZ_API RzRopRegInfo *rz_core_rop_gadget_info_get_modified_register(const RZ_NONNULL RzRopGadgetInfo *gadget_info, RZ_NONNULL const char *name); +#ifdef __cplusplus +} +#endif #endif // RZ_ROP_H