Re: [PATCH] vdagent-win: Use wide characters in drap&drop code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 23, 2015 at 09:24:38AM -0400, Frediano Ziglio wrote:
> > 
> > On Thu, Apr 23, 2015 at 08:23:18AM -0400, Frediano Ziglio wrote:
> > > This allow username to contain any extended characters.
> > > 
> > > Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> > > ---
> > >  vdagent/file_xfer.cpp | 32 +++++++++++++-------------------
> > >  vdagent/file_xfer.h   |  9 +++++----
> > >  2 files changed, 18 insertions(+), 23 deletions(-)
> > > 
> > > diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
> > > index 2dc138b..275768b 100644
> > > --- a/vdagent/file_xfer.cpp
> > > +++ b/vdagent/file_xfer.cpp
> > > @@ -39,7 +39,7 @@ FileXfer::~FileXfer()
> > >      for (iter = _tasks.begin(); iter != _tasks.end(); iter++) {
> > >          task = iter->second;
> > >          CloseHandle(task->handle);
> > > -        DeleteFileA(task->name);
> > > +        DeleteFile(task->name);
> > >          delete task;
> > >      }
> > >  }
> > > @@ -48,7 +48,8 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage*
> > > start,
> > >                              VDAgentFileXferStatusMessage* status)
> > >  {
> > >      char* file_meta = (char*)start->data;
> > > -    char file_path[MAX_PATH], file_name[MAX_PATH];
> > > +    TCHAR file_path[MAX_PATH];
> > > +    char file_name[MAX_PATH];
> > >      ULARGE_INTEGER free_bytes;
> > >      FileXferTask* task;
> > >      uint64_t file_size;
> > > @@ -73,12 +74,12 @@ void
> > > FileXfer::handle_start(VDAgentFileXferStartMessage* start,
> > >          return;
> > >      }
> > >  
> > > -    if (FAILED(SHGetFolderPathA(NULL, CSIDL_DESKTOPDIRECTORY |
> > > CSIDL_FLAG_CREATE, NULL,
> > > +    if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY |
> > > CSIDL_FLAG_CREATE, NULL,
> > >              SHGFP_TYPE_CURRENT, file_path))) {
> > >          vd_printf("failed getting desktop path");
> > >          return;
> > >      }
> > > -    if (!GetDiskFreeSpaceExA(file_path, &free_bytes, NULL, NULL)) {
> > > +    if (!GetDiskFreeSpaceEx(file_path, &free_bytes, NULL, NULL)) {
> > >          vd_printf("failed getting disk free space %lu", GetLastError());
> > >          return;
> > >      }
> > > @@ -87,25 +88,18 @@ void
> > > FileXfer::handle_start(VDAgentFileXferStartMessage* start,
> > >          return;
> > >      }
> > >  
> > > -    if (strlen(file_path) + strlen(file_name) + 1 >= MAX_PATH) {
> > > -        vd_printf("error: file too long %s\\%s", file_path, file_name);
> > > +    wlen = _tcslen(file_path);
> > > +    if (wlen + 3 >= MAX_PATH) {
> > 
> > Why 3 ?
> > 
> 
> On char for the separator, one for the file (can't be empty) and one for the NUL terminator.

Hmm, I'd say the 'one for the file' is going to be caught by
MultiByteToWideChar() anyway, but why not...

Christophe

Attachment: pgpb4iyHYnC1m.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]