lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0b1b5224-b891-bf6d-8d6f-f5d236890127@linaro.org>
Date:   Mon, 31 Jul 2023 10:20:54 +0200
From:   Konrad Dybcio <konrad.dybcio@...aro.org>
To:     Bjorn Andersson <quic_bjorande@...cinc.com>,
        Bjorn Andersson <andersson@...nel.org>,
        Chris Lew <quic_clew@...cinc.com>
Cc:     Alex Elder <elder@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Mathieu Poirier <mathieu.poirier@...aro.org>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-msm@...r.kernel.org, linux-remoteproc@...r.kernel.org
Subject: Re: [PATCH 3/4] soc: qcom: aoss: Format string in qmp_send()

On 31.07.2023 06:10, Bjorn Andersson wrote:
> The majority of callers to qmp_send() composes the message dynamically
> using some form of sprintf(), resulting in unnecessary complication and
> stack usage.
> 
> By changing the interface of qmp_send() to take a format string and
> arguments, the duplicated composition of the commands can be moved to a
> single location.
> 
> Signed-off-by: Bjorn Andersson <quic_bjorande@...cinc.com>
> ---
[...]


> +int qmp_send(struct qmp *qmp, const char *fmt, ...)
>  {
>  	long time_left;
> +	va_list args;
>  	char buf[QMP_MSG_LEN];
> +	int len;
>  	int ret;
>  
> -	if (WARN_ON(IS_ERR_OR_NULL(qmp) || !data))
> +	if (WARN_ON(IS_ERR_OR_NULL(qmp) || !fmt))
>  		return -EINVAL;
>  
> -	if (WARN_ON(strlen(data) >= sizeof(buf)))
> -		return -EINVAL;
> +	memset(buf, 0, sizeof(buf));
Wouldn't initializing the array with = { 0 } be faster?

Otherwise, this looks very cool

Reviewed-by: Konrad Dybcio <konrad.dybcio@...aro.org>

Konrad

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ