| To: | xfs@xxxxxxxxxxx |
|---|---|
| Subject: | Re: [PATCH 07/11] xfsprogs: xfs_fsr: replace sprintf with snprintf to avoid buffer overflow |
| From: | Eric Sandeen <sandeen@xxxxxxxxxxx> |
| Date: | Wed, 2 Dec 2015 23:44:02 -0600 |
| Delivered-to: | xfs@xxxxxxxxxxx |
| In-reply-to: | <1449055167-19936-8-git-send-email-t.vivek@xxxxxxxxxxx> |
| References: | <1449055167-19936-1-git-send-email-t.vivek@xxxxxxxxxxx> <1449055167-19936-8-git-send-email-t.vivek@xxxxxxxxxxx> |
| User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
it seems like the sprintfs in i.e. fsrall_cleanup() and tmp_init()
might have the same problem, no?
And then what happens if it is truncated to SMBUFSZ; at that point
I think this needs error handling, if the string got truncated.
-Eric
On 12/2/15 5:19 AM, Vivek Trivedi wrote:
> Fix possible buffer overflow by replacing sprintf with snprintf in tmp_next
> and tmp_close.
> Reported by coverity.
>
> Signed-off-by: Vivek Trivedi <t.vivek@xxxxxxxxxxx>
> ---
> fsr/xfs_fsr.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
> index 424fbce..bd459b6 100644
> --- a/fsr/xfs_fsr.c
> +++ b/fsr/xfs_fsr.c
> @@ -1804,7 +1804,7 @@ tmp_next(char *mnt)
> {
> static char buf[SMBUFSZ];
>
> - sprintf(buf, "%s/.fsr/ag%d/tmp%d",
> + snprintf(buf, SMBUFSZ, "%s/.fsr/ag%d/tmp%d",
> ( (strcmp(mnt, "/") == 0) ? "" : mnt),
> tmp_agi,
> getpid());
> @@ -1823,7 +1823,7 @@ tmp_close(char *mnt)
>
> /* No data is ever actually written so we can just do rmdir's */
> for (i=0; i < fsgeom.agcount; i++) {
> - sprintf(buf, "%s/.fsr/ag%d", mnt, i);
> + snprintf(buf, SMBUFSZ, "%s/.fsr/ag%d", mnt, i);
> if (rmdir(buf) < 0) {
> if (errno != ENOENT) {
> fsrprintf(
>
|
| Previous by Date: | Re: [PATCH 06/11] xfsprogs: xfs_db: check null derefernce after block_to_bt, Eric Sandeen |
|---|---|
| Next by Date: | Re: [PATCH 02/11] xfsprogs: fix integer overflow in xlog_find_verify_cycle, Dave Chinner |
| Previous by Thread: | [PATCH 07/11] xfsprogs: xfs_fsr: replace sprintf with snprintf to avoid buffer overflow, Vivek Trivedi |
| Next by Thread: | Re: [PATCH 07/11] xfsprogs: xfs_fsr: replace sprintf with snprintf to avoid buffer overflow, Dave Chinner |
| Indexes: | [Date] [Thread] [Top] [All Lists] |