[Spice-devel] [vdagent-win PATCH] file-xfer: handle_start: use snprintf instead of sprintf_s

Victor Toso victortoso at redhat.com
Thu Feb 28 09:38:29 UTC 2019


Hi,

On Thu, Feb 28, 2019 at 11:04:51AM +0200, Uri Lublin wrote:
> On 2/25/19 2:08 PM, Victor Toso wrote:
> > On Mon, Feb 25, 2019 at 12:20:06PM +0200, Uri Lublin wrote:
> > > When building with older mingw, sprintf_s does not
> > > always work as expected, but snprintf does.
> > > 
> > > Also it's more consistent in the file.
> > > 
> > > Note that when building with VS, snprintf becomes sprintf_s
> > 
> > I really don't mind to have this patch (I might have proposed it
> > long time ago even, not sure) but overall this should have been
> > fixed by rebase on mingw-crt, no?
> 
> I think it should be fixed by a rebase of mingw-crt.
> 
> Do you want me to mention it in the commit log ?

Looking at tags that contain the fix:

$ git tag --contains 9975303
v5.0-rc1
v5.0-rc2
v5.0.0
v5.0.1
v5.0.2
v5.0.3
v5.0.4
v6.0.0

So perhaps adding `Fixed in mingw-w64 at v5.0.0 by 9975303 (CRT:
vsprintf_s calling wrong function)` would be fine.

This tag is from Oct 17, 2016 so indeed, quite old!

Cheers,

> Thanks,
>     Uri.
> 
> > 
> > Cheers,
> > 
> > > Related: rhbz#1410181
> > > 
> > > Signed-off-by: Uri Lublin <uril at redhat.com>
> > > ---
> > >   vdagent/file_xfer.cpp | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
> > > index ada3b47..c456bbe 100644
> > > --- a/vdagent/file_xfer.cpp
> > > +++ b/vdagent/file_xfer.cpp
> > > @@ -113,7 +113,7 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
> > >           if (attempt == 0) {
> > >               strcpy(dest_filename, file_name);
> > >           } else {
> > > -            sprintf_s(dest_filename, SPICE_N_ELEMENTS(dest_filename),
> > > +            snprintf(dest_filename, sizeof(dest_filename),
> > >                         "%.*s (%d)%s", int(extension - file_name), file_name, attempt, extension);
> > >           }
> > >           if ((MultiByteToWideChar(CP_UTF8, 0, dest_filename, -1, file_path + wlen, MAX_PATH - wlen)) == 0) {
> > > -- 
> > > 2.20.1
> > > 
> > > _______________________________________________
> > > Spice-devel mailing list
> > > Spice-devel at lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190228/b11e764a/attachment.sig>


More information about the Spice-devel mailing list