From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v2 for-4.5 1/3] python/xc: Fix multiple issues in pyflask_context_to_sid() Date: Tue, 16 Dec 2014 17:16:25 +0000 Message-ID: <1418750185.20265.0.camel@citrix.com> References: <20141209162048.GB9585@laptop.dumpdata.com> <1418143402-29674-1-git-send-email-andrew.cooper3@citrix.com> <20141210171345.GM4268@laptop.dumpdata.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20141210171345.GM4268@laptop.dumpdata.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Konrad Rzeszutek Wilk Cc: Andrew Cooper , Ian Jackson , Wei Liu , Xen Coverity Team , Xen-devel List-Id: xen-devel@lists.xenproject.org On Wed, 2014-12-10 at 12:13 -0500, Konrad Rzeszutek Wilk wrote: > On Tue, Dec 09, 2014 at 04:43:22PM +0000, Andrew Cooper wrote: > > The error handling from a failed memory allocation should return > > PyErr_SetFromErrno(xc_error_obj); rather than simply calling it and continuing > > to the memcpy() below, with the dest pointer being NULL. > > > > Coverity also complains about passing a non-NUL terminated string to > > xc_flask_context_to_sid(). xc_flask_context_to_sid() doesn't actually take a > > NUL terminated string, but it does take a char* which, in context, used to be > > a string, which is why Coverity complains. > > > > One solution would be to use strdup(ctx) which is simpler than a > > strlen()/malloc()/memcpy() combo, which would result in a NUL-terminated > > string being used with xc_flask_context_to_sid(). > > > > However, ctx is strictly an input to the hypercall and is not mutated along > > the way. Both these issues can be fixed, and the error logic simplified, by > > not duplicating ctx in the first place. > > > > Signed-off-by: Andrew Cooper > > Coverity-IDs: 1055305 1055721 > > Acked-by: Ian Campbell > > CC: Ian Jackson > > CC: Wei Liu > > CC: Xen Coverity Team > > > > --- > > v2: Expand the commit message. No code change > > Thank you. > > Release-Acked-by: Konrad Rzeszutek Wilk > Applied.