From: bp@alien8.de (Borislav Petkov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] edac: xgene: Fix possible sprintf overflow issue
Date: Fri, 25 Sep 2015 15:45:51 +0200 [thread overview]
Message-ID: <20150925134551.GE3568@pd.tnic> (raw)
In-Reply-To: <1443116287-11752-1-git-send-email-lho@apm.com>
On Thu, Sep 24, 2015 at 10:38:07AM -0700, Loc Ho wrote:
> Replace sprintf with snprintf to avoid possible string array overflow.
>
> Signed-off-by: Loc Ho <lho@apm.com>
> ---
> drivers/edac/xgene_edac.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/edac/xgene_edac.c b/drivers/edac/xgene_edac.c
> index 37121e8..dfa13bb 100644
> --- a/drivers/edac/xgene_edac.c
> +++ b/drivers/edac/xgene_edac.c
> @@ -879,7 +879,7 @@ xgene_edac_pmd_create_debugfs_nodes(struct edac_device_ctl_info *edac_dev)
> if (!IS_ENABLED(CONFIG_EDAC_DEBUG) || !ctx->edac->dfs)
> return;
>
> - sprintf(name, "PMD%d", ctx->pmd);
> + snprintf(name, sizeof(name), "PMD%d", ctx->pmd);
> dbgfs_dir = edac_debugfs_create_dir_at(name, ctx->edac->dfs);
> if (!dbgfs_dir)
> return;
> @@ -923,7 +923,7 @@ static int xgene_edac_pmd_add(struct xgene_edac *edac, struct device_node *np,
> goto err_group;
> }
>
> - sprintf(edac_name, "l2c%d", pmd);
> + snprintf(edac_name, sizeof(edac_name), "l2c%d", pmd);
> edac_dev = edac_device_alloc_ctl_info(sizeof(*ctx),
> edac_name, 1, "l2c", 1, 2, NULL,
> 0, edac_device_alloc_index());
> @@ -1183,7 +1183,7 @@ xgene_edac_l3_create_debugfs_nodes(struct edac_device_ctl_info *edac_dev)
> if (!IS_ENABLED(CONFIG_EDAC_DEBUG) || !ctx->edac->dfs)
> return;
>
> - sprintf(name, "l3c%d", ctx->edac_idx);
> + snprintf(name, sizeof(name), "l3c%d", ctx->edac_idx);
> dbgfs_dir = edac_debugfs_create_dir_at(name, ctx->edac->dfs);
> if (!dbgfs_dir)
> return;
All 5 applied.
I've merged the last hunk changing xgene_edac_l3_create_debugfs_nodes
into the second patch which adds the L3 support.
Thanks.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
next prev parent reply other threads:[~2015-09-25 13:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-24 17:38 [PATCH] edac: xgene: Fix possible sprintf overflow issue Loc Ho
2015-09-25 13:45 ` Borislav Petkov [this message]
2015-09-25 17:52 ` Loc Ho
2015-09-26 8:38 ` Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150925134551.GE3568@pd.tnic \
--to=bp@alien8.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).