All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Frank Sorenson <sorenson@redhat.com>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs_restore: Fix compile warnings with strncpy size equal to string size
Date: Fri, 13 Dec 2019 16:09:50 -0600	[thread overview]
Message-ID: <c40ef1e4-17cc-aaea-a6b8-1198e90e01f6@sandeen.net> (raw)
In-Reply-To: <20191213001114.3442739-1-sorenson@redhat.com>

On 12/12/19 6:11 PM, Frank Sorenson wrote:
> If the strncpy size equals the string size, the result will not
> be null-terminated.
> 
> Call the already-existing strncpyterm which ensures proper
> termination.
> 
> Signed-off-by: Frank Sorenson <sorenson@redhat.com>

Thanks Frank!

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  restore/content.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/restore/content.c b/restore/content.c
> index 5e30f08..4c4d6ec 100644
> --- a/restore/content.c
> +++ b/restore/content.c
> @@ -5081,7 +5081,7 @@ pi_insertfile(ix_t drivecnt,
>  	     &&
>  	     ! DH2O(objh)->o_idlabvalpr) {
>  		uuid_copy(DH2O(objh)->o_id, *mediaidp);
> -		strncpy(DH2O(objh)->o_lab,
> +		strncpyterm(DH2O(objh)->o_lab,
>  			 medialabel,
>  			 sizeof(DH2O(objh)->o_lab));
>  		DH2O(objh)->o_idlabvalpr = BOOL_TRUE;
> @@ -5111,7 +5111,7 @@ pi_insertfile(ix_t drivecnt,
>  	     &&
>  	     ! DH2O(prevobjh)->o_idlabvalpr) {
>  		uuid_copy(DH2O(prevobjh)->o_id, *prevmediaidp);
> -		strncpy(DH2O(prevobjh)->o_lab,
> +		strncpyterm(DH2O(prevobjh)->o_lab,
>  			       prevmedialabel,
>  			       sizeof(DH2O(prevobjh)->o_lab));
>  		DH2O(prevobjh)->o_idlabvalpr = BOOL_TRUE;
> @@ -5581,7 +5581,7 @@ pi_transcribe(inv_session_t *sessp)
>  					       fileszvalpr,
>  					       filep->m_size);
>  			uuid_copy(lastobjid, filep->m_moid);
> -			strncpy(lastobjlabel,
> +			strncpyterm(lastobjlabel,
>  				 filep->m_label,
>  				 sizeof(lastobjlabel));
>  			dumpmediafileix++;
> @@ -6749,7 +6749,7 @@ addobj(bag_t *bagp,
>  	bagobjp = (bagobj_t *)calloc(1, sizeof(bagobj_t));
>  	assert(bagobjp);
>  	uuid_copy(bagobjp->id, *idp);
> -	strncpy(bagobjp->label,
> +	strncpyterm(bagobjp->label,
>  		 label,
>  		 sizeof(bagobjp->label));
>  	bagobjp->indrivepr = indrivepr;
> 

      reply	other threads:[~2019-12-13 22:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13  0:11 [PATCH] xfs_restore: Fix compile warnings with strncpy size equal to string size Frank Sorenson
2019-12-13 22:09 ` Eric Sandeen [this message]

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=c40ef1e4-17cc-aaea-a6b8-1198e90e01f6@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sorenson@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.