2012-10-14 22:46:01 +04:00
|
|
|
/**
|
|
|
|
* xrdp: A Remote Desktop Protocol server.
|
|
|
|
*
|
|
|
|
* Copyright (C) Jay Sorg 2012
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-10-30 07:12:24 +04:00
|
|
|
/* MS-RDPECLIP
|
|
|
|
* http://msdn.microsoft.com/en-us/library/cc241066%28prot.20%29.aspx
|
|
|
|
*
|
|
|
|
* CLIPRDR_FILEDESCRIPTOR
|
|
|
|
* http://msdn.microsoft.com/en-us/library/ff362447%28prot.20%29.aspx */
|
|
|
|
|
2017-03-03 07:33:23 +03:00
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
#include <config_ac.h>
|
|
|
|
#endif
|
|
|
|
|
2016-01-30 23:32:13 +03:00
|
|
|
#include <sys/time.h>
|
2012-10-14 22:46:01 +04:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
#include "arch.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "os_calls.h"
|
2020-12-21 15:36:00 +03:00
|
|
|
#include "string_calls.h"
|
2012-11-08 10:48:18 +04:00
|
|
|
#include "list.h"
|
2012-10-14 22:46:01 +04:00
|
|
|
#include "chansrv.h"
|
|
|
|
#include "clipboard.h"
|
|
|
|
#include "clipboard_file.h"
|
2012-10-19 05:43:04 +04:00
|
|
|
#include "clipboard_common.h"
|
2012-10-14 22:46:01 +04:00
|
|
|
#include "xcommon.h"
|
2012-10-30 07:12:24 +04:00
|
|
|
#include "chansrv_fuse.h"
|
2021-05-27 17:34:13 +03:00
|
|
|
#include "ms-rdpeclip.h"
|
2012-10-14 22:46:01 +04:00
|
|
|
|
|
|
|
extern int g_cliprdr_chan_id; /* in chansrv.c */
|
|
|
|
|
2012-10-19 05:43:04 +04:00
|
|
|
extern struct clip_s2c g_clip_s2c; /* in clipboard.c */
|
|
|
|
extern struct clip_c2s g_clip_c2s; /* in clipboard.c */
|
2012-10-14 22:46:01 +04:00
|
|
|
|
2013-04-27 05:55:28 +04:00
|
|
|
extern char g_fuse_clipboard_path[];
|
2012-11-04 05:47:04 +04:00
|
|
|
|
2012-10-14 22:46:01 +04:00
|
|
|
struct cb_file_info
|
|
|
|
{
|
|
|
|
char pathname[256];
|
|
|
|
char filename[256];
|
|
|
|
int flags;
|
|
|
|
int size;
|
2012-10-30 07:12:24 +04:00
|
|
|
tui64 time;
|
|
|
|
};
|
|
|
|
|
2012-11-08 10:48:18 +04:00
|
|
|
static struct list *g_files_list = 0;
|
|
|
|
|
|
|
|
/* used when server is asking for file info from the client */
|
2012-11-05 01:52:33 +04:00
|
|
|
static int g_file_request_sent_type = 0;
|
2012-10-14 22:46:01 +04:00
|
|
|
|
2012-10-30 07:12:24 +04:00
|
|
|
/* number of seconds from 1 Jan. 1601 00:00 to 1 Jan 1970 00:00 UTC */
|
|
|
|
#define CB_EPOCH_DIFF 11644473600LL
|
|
|
|
|
2012-10-22 09:15:31 +04:00
|
|
|
/*****************************************************************************/
|
2016-04-22 08:27:27 +03:00
|
|
|
#if 0
|
2017-03-12 19:35:00 +03:00
|
|
|
static tui64
|
2012-10-30 07:12:24 +04:00
|
|
|
timeval2wintime(struct timeval *tv)
|
|
|
|
{
|
|
|
|
tui64 result;
|
|
|
|
|
|
|
|
result = CB_EPOCH_DIFF;
|
|
|
|
result += tv->tv_sec;
|
|
|
|
result *= 10000000LL;
|
|
|
|
result += tv->tv_usec * 10;
|
|
|
|
return result;
|
|
|
|
}
|
2016-04-22 08:27:27 +03:00
|
|
|
#endif
|
2012-10-30 07:12:24 +04:00
|
|
|
|
2021-09-15 12:20:15 +03:00
|
|
|
/***
|
|
|
|
* See MS-RDPECLIP 3.1.5.4.7
|
|
|
|
*
|
|
|
|
* Sends a failure response to a CLIPRDR_FILECONTENTS_REQUEST
|
|
|
|
* @param streamId Stream ID from CLIPRDR_FILECONTENTS_REQUEST
|
|
|
|
* @return 0 for success
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
clipboard_send_filecontents_response_fail(int streamId)
|
|
|
|
{
|
|
|
|
LOG_DEVEL(LOG_LEVEL_TRACE, "clipboardn_send_filecontents_response_fail:");
|
|
|
|
|
|
|
|
struct stream *s;
|
|
|
|
int size;
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
make_stream(s);
|
|
|
|
init_stream(s, 64);
|
|
|
|
|
|
|
|
out_uint16_le(s, CB_FILECONTENTS_RESPONSE);
|
|
|
|
out_uint16_le(s, CB_RESPONSE_FAIL);
|
|
|
|
out_uint32_le(s, 4);
|
|
|
|
out_uint32_le(s, streamId);
|
|
|
|
s_mark_end(s);
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
|
|
|
|
free_stream(s);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-10-30 07:12:24 +04:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* this will replace %20 or any hex with the space or correct char
|
|
|
|
* returns error */
|
2017-03-12 19:35:00 +03:00
|
|
|
static int
|
2012-10-22 09:15:31 +04:00
|
|
|
clipboard_check_file(char *filename)
|
|
|
|
{
|
|
|
|
char lfilename[256];
|
|
|
|
char jchr[8];
|
|
|
|
int lindex;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
g_memset(lfilename, 0, 256);
|
|
|
|
lindex = 0;
|
|
|
|
index = 0;
|
|
|
|
while (filename[index] != 0)
|
|
|
|
{
|
|
|
|
if (filename[index] == '%')
|
|
|
|
{
|
|
|
|
jchr[0] = filename[index + 1];
|
|
|
|
jchr[1] = filename[index + 2];
|
|
|
|
jchr[2] = 0;
|
|
|
|
index += 3;
|
|
|
|
lfilename[lindex] = g_htoi(jchr);
|
|
|
|
lindex++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lfilename[lindex] = filename[index];
|
|
|
|
lindex++;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "[%s] [%s]", filename, lfilename);
|
2012-10-22 09:15:31 +04:00
|
|
|
g_strcpy(filename, lfilename);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-14 22:46:01 +04:00
|
|
|
/*****************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
static int
|
2017-01-22 21:27:50 +03:00
|
|
|
clipboard_get_file(const char *file, int bytes)
|
2012-10-14 22:46:01 +04:00
|
|
|
{
|
|
|
|
int sindex;
|
|
|
|
int pindex;
|
2012-10-30 07:12:24 +04:00
|
|
|
int flags;
|
2012-10-22 09:15:31 +04:00
|
|
|
char full_fn[256]; /* /etc/xrdp/xrdp.ini */
|
|
|
|
char filename[256]; /* xrdp.ini */
|
|
|
|
char pathname[256]; /* /etc/xrdp */
|
2012-11-08 10:48:18 +04:00
|
|
|
struct cb_file_info *cfi;
|
2012-11-05 13:04:04 +04:00
|
|
|
|
|
|
|
/* x-special/gnome-copied-files */
|
|
|
|
if ((g_strncmp(file, "copy", 4) == 0) && (bytes == 4))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ((g_strncmp(file, "cut", 3) == 0) && (bytes == 3))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-14 22:46:01 +04:00
|
|
|
sindex = 0;
|
2012-10-30 07:12:24 +04:00
|
|
|
flags = CB_FILE_ATTRIBUTE_ARCHIVE;
|
2012-11-05 13:04:04 +04:00
|
|
|
/* text/uri-list */
|
|
|
|
/* x-special/gnome-copied-files */
|
|
|
|
if (g_strncmp(file, "file://", 7) == 0)
|
2012-10-14 22:46:01 +04:00
|
|
|
{
|
|
|
|
sindex = 7;
|
|
|
|
}
|
|
|
|
pindex = bytes;
|
|
|
|
while (pindex > sindex)
|
|
|
|
{
|
|
|
|
if (file[pindex] == '/')
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pindex--;
|
|
|
|
}
|
|
|
|
g_memset(pathname, 0, 256);
|
|
|
|
g_memset(filename, 0, 256);
|
|
|
|
g_memcpy(pathname, file + sindex, pindex - sindex);
|
|
|
|
if (pathname[0] == 0)
|
|
|
|
{
|
|
|
|
pathname[0] = '/';
|
|
|
|
}
|
|
|
|
g_memcpy(filename, file + pindex + 1, (bytes - 1) - pindex);
|
2012-10-22 09:15:31 +04:00
|
|
|
/* this should replace %20 with space */
|
2016-08-30 09:49:58 +03:00
|
|
|
clipboard_check_file(pathname);
|
2012-10-22 09:15:31 +04:00
|
|
|
clipboard_check_file(filename);
|
2012-10-14 22:46:01 +04:00
|
|
|
g_snprintf(full_fn, 255, "%s/%s", pathname, filename);
|
2021-10-25 17:23:54 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Before we look at the file, see if it's in the FUSE filesystem. If it is,
|
|
|
|
* we can't call normal file checking functions, as these will result in
|
|
|
|
* a deadlock */
|
|
|
|
if (xfuse_path_in_xfuse_fs(full_fn))
|
|
|
|
{
|
|
|
|
LOG(LOG_LEVEL_ERROR, "clipboard_get_file: Can't add client-side file "
|
|
|
|
"%s to clipboard", full_fn);
|
|
|
|
return 1;
|
|
|
|
}
|
2012-10-14 22:46:01 +04:00
|
|
|
if (g_directory_exist(full_fn))
|
|
|
|
{
|
2021-10-25 17:23:54 +03:00
|
|
|
LOG(LOG_LEVEL_ERROR, "clipboard_get_file: file [%s] is a directory, "
|
|
|
|
"not supported", full_fn);
|
2012-10-30 07:12:24 +04:00
|
|
|
flags |= CB_FILE_ATTRIBUTE_DIRECTORY;
|
2012-10-14 22:46:01 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (!g_file_exist(full_fn))
|
|
|
|
{
|
2021-10-25 17:23:54 +03:00
|
|
|
LOG(LOG_LEVEL_ERROR, "clipboard_get_file: file [%s] does not exist",
|
|
|
|
full_fn);
|
2012-10-14 22:46:01 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-30 03:36:20 +03:00
|
|
|
cfi = (struct cb_file_info *)g_malloc(sizeof(struct cb_file_info), 1);
|
2012-11-08 10:48:18 +04:00
|
|
|
list_add_item(g_files_list, (tintptr)cfi);
|
|
|
|
g_strcpy(cfi->filename, filename);
|
|
|
|
g_strcpy(cfi->pathname, pathname);
|
|
|
|
cfi->size = g_file_get_size(full_fn);
|
|
|
|
cfi->flags = flags;
|
|
|
|
cfi->time = (g_time1() + CB_EPOCH_DIFF) * 10000000LL;
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "ok filename [%s] pathname [%s] size [%d]",
|
2020-11-30 03:36:20 +03:00
|
|
|
cfi->filename, cfi->pathname, cfi->size);
|
2012-10-14 22:46:01 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
static int
|
2017-01-22 21:27:50 +03:00
|
|
|
clipboard_get_files(const char *files, int bytes)
|
2012-10-14 22:46:01 +04:00
|
|
|
{
|
|
|
|
int index;
|
|
|
|
int file_index;
|
|
|
|
char file[512];
|
|
|
|
|
|
|
|
file_index = 0;
|
|
|
|
for (index = 0; index < bytes; index++)
|
|
|
|
{
|
|
|
|
if (files[index] == '\n' || files[index] == '\r')
|
|
|
|
{
|
|
|
|
if (file_index > 0)
|
|
|
|
{
|
|
|
|
if (clipboard_get_file(file, file_index) == 0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
file_index = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
file[file_index] = files[index];
|
|
|
|
file_index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (file_index > 0)
|
|
|
|
{
|
|
|
|
if (clipboard_get_file(file, file_index) == 0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2012-11-08 10:48:18 +04:00
|
|
|
if (g_files_list->count < 1)
|
2012-10-14 22:46:01 +04:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2012-10-19 05:43:04 +04:00
|
|
|
/* server to client */
|
2012-11-04 05:47:04 +04:00
|
|
|
/* response to client asking for clipboard contents that is file list */
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2017-01-22 21:27:50 +03:00
|
|
|
clipboard_send_data_response_for_file(const char *data, int data_size)
|
2012-10-14 22:46:01 +04:00
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
int size;
|
|
|
|
int rv;
|
|
|
|
int bytes_after_header;
|
|
|
|
int cItems;
|
|
|
|
int flags;
|
|
|
|
int index;
|
2012-10-30 07:12:24 +04:00
|
|
|
tui32 ui32;
|
2012-10-14 22:46:01 +04:00
|
|
|
char fn[256];
|
2012-11-08 10:48:18 +04:00
|
|
|
struct cb_file_info *cfi;
|
2012-10-14 22:46:01 +04:00
|
|
|
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_send_data_response_for_file: data_size %d",
|
2020-11-30 03:36:20 +03:00
|
|
|
data_size);
|
|
|
|
LOG_DEVEL_HEXDUMP(LOG_LEVEL_TRACE, "", data, data_size);
|
2012-11-08 10:48:18 +04:00
|
|
|
if (g_files_list == 0)
|
|
|
|
{
|
|
|
|
g_files_list = list_create();
|
|
|
|
g_files_list->auto_free = 1;
|
|
|
|
}
|
|
|
|
list_clear(g_files_list);
|
2012-10-14 22:46:01 +04:00
|
|
|
clipboard_get_files(data, data_size);
|
2012-11-08 10:48:18 +04:00
|
|
|
cItems = g_files_list->count;
|
2012-10-14 22:46:01 +04:00
|
|
|
bytes_after_header = cItems * 592 + 4;
|
|
|
|
make_stream(s);
|
|
|
|
init_stream(s, 64 + bytes_after_header);
|
|
|
|
out_uint16_le(s, CB_FORMAT_DATA_RESPONSE); /* 5 CLIPRDR_DATA_RESPONSE */
|
2012-10-15 05:08:06 +04:00
|
|
|
out_uint16_le(s, CB_RESPONSE_OK); /* 1 status */
|
2012-10-14 22:46:01 +04:00
|
|
|
out_uint32_le(s, bytes_after_header);
|
|
|
|
out_uint32_le(s, cItems);
|
|
|
|
for (index = 0; index < cItems; index++)
|
|
|
|
{
|
2012-11-08 10:48:18 +04:00
|
|
|
cfi = (struct cb_file_info *)list_get_item(g_files_list, index);
|
2012-10-14 22:46:01 +04:00
|
|
|
flags = CB_FD_ATTRIBUTES | CB_FD_FILESIZE | CB_FD_WRITESTIME | CB_FD_PROGRESSUI;
|
|
|
|
out_uint32_le(s, flags);
|
|
|
|
out_uint8s(s, 32); /* reserved1 */
|
2012-11-08 10:48:18 +04:00
|
|
|
flags = cfi->flags;
|
2012-10-14 22:46:01 +04:00
|
|
|
out_uint32_le(s, flags);
|
|
|
|
out_uint8s(s, 16); /* reserved2 */
|
|
|
|
/* file time */
|
|
|
|
/* 100-nanoseconds intervals since 1 January 1601 */
|
2012-10-30 07:12:24 +04:00
|
|
|
//out_uint32_le(s, 0x2c305d08); /* 25 October 2009, 21:17 */
|
|
|
|
//out_uint32_le(s, 0x01ca55f3);
|
2012-11-08 10:48:18 +04:00
|
|
|
ui32 = cfi->time & 0xffffffff;
|
2012-10-30 07:12:24 +04:00
|
|
|
out_uint32_le(s, ui32);
|
2012-11-08 10:48:18 +04:00
|
|
|
ui32 = cfi->time >> 32;
|
2012-10-30 07:12:24 +04:00
|
|
|
out_uint32_le(s, ui32);
|
2012-10-14 22:46:01 +04:00
|
|
|
/* file size */
|
|
|
|
out_uint32_le(s, 0);
|
2012-11-08 10:48:18 +04:00
|
|
|
out_uint32_le(s, cfi->size);
|
|
|
|
g_snprintf(fn, 255, "%s", cfi->filename);
|
2012-10-14 22:46:01 +04:00
|
|
|
clipboard_out_unicode(s, fn, 256);
|
|
|
|
out_uint8s(s, 8); /* pad */
|
|
|
|
}
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
s_mark_end(s);
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
|
|
|
|
free_stream(s);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2012-11-04 05:47:04 +04:00
|
|
|
/* send the file size from server to the client */
|
2017-03-12 19:35:00 +03:00
|
|
|
static int
|
2012-10-14 22:46:01 +04:00
|
|
|
clipboard_send_file_size(int streamId, int lindex)
|
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
int size;
|
|
|
|
int rv;
|
|
|
|
int file_size;
|
2012-11-08 10:48:18 +04:00
|
|
|
struct cb_file_info *cfi;
|
2012-10-14 22:46:01 +04:00
|
|
|
|
2012-11-08 10:48:18 +04:00
|
|
|
if (g_files_list == 0)
|
|
|
|
{
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_size: error g_files_list is nil");
|
2021-09-15 12:20:15 +03:00
|
|
|
clipboard_send_filecontents_response_fail(streamId);
|
2012-11-08 10:48:18 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
cfi = (struct cb_file_info *)list_get_item(g_files_list, lindex);
|
|
|
|
if (cfi == 0)
|
|
|
|
{
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_size: error cfi is nil");
|
2021-09-15 12:20:15 +03:00
|
|
|
clipboard_send_filecontents_response_fail(streamId);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (cfi->size < 0)
|
|
|
|
{
|
2021-09-21 12:19:47 +03:00
|
|
|
LOG(LOG_LEVEL_ERROR, "clipboard_send_file_size: error cfi->size is negative"
|
|
|
|
"value [%d]", cfi->size);
|
2021-09-15 12:20:15 +03:00
|
|
|
clipboard_send_filecontents_response_fail(streamId);
|
2012-11-08 10:48:18 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
file_size = cfi->size;
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_send_file_size: streamId %d file_size %d",
|
2020-11-30 03:36:20 +03:00
|
|
|
streamId, file_size);
|
2012-10-14 22:46:01 +04:00
|
|
|
make_stream(s);
|
|
|
|
init_stream(s, 8192);
|
|
|
|
out_uint16_le(s, CB_FILECONTENTS_RESPONSE); /* 9 */
|
|
|
|
out_uint16_le(s, CB_RESPONSE_OK); /* 1 status */
|
|
|
|
out_uint32_le(s, 12);
|
|
|
|
out_uint32_le(s, streamId);
|
|
|
|
out_uint32_le(s, file_size);
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
s_mark_end(s);
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
|
|
|
|
free_stream(s);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2012-11-04 05:47:04 +04:00
|
|
|
/* ask the client to send the file size */
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2012-11-05 01:52:33 +04:00
|
|
|
clipboard_request_file_size(int stream_id, int lindex)
|
2012-11-04 05:47:04 +04:00
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
int size;
|
|
|
|
int rv;
|
|
|
|
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_request_file_size:");
|
2012-11-05 01:52:33 +04:00
|
|
|
if (g_file_request_sent_type != 0)
|
|
|
|
{
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_request_file_size: warning, still waiting "
|
2020-11-30 03:36:20 +03:00
|
|
|
"for CB_FILECONTENTS_RESPONSE");
|
2012-11-05 01:52:33 +04:00
|
|
|
}
|
2012-11-04 05:47:04 +04:00
|
|
|
make_stream(s);
|
|
|
|
init_stream(s, 8192);
|
|
|
|
out_uint16_le(s, CB_FILECONTENTS_REQUEST); /* 8 */
|
|
|
|
out_uint16_le(s, 0);
|
|
|
|
out_uint32_le(s, 28);
|
2012-11-05 01:52:33 +04:00
|
|
|
out_uint32_le(s, stream_id);
|
2012-11-04 05:47:04 +04:00
|
|
|
out_uint32_le(s, lindex);
|
|
|
|
out_uint32_le(s, CB_FILECONTENTS_SIZE);
|
|
|
|
out_uint32_le(s, 0); /* nPositionLow */
|
|
|
|
out_uint32_le(s, 0); /* nPositionHigh */
|
|
|
|
out_uint32_le(s, 0); /* cbRequested */
|
|
|
|
out_uint32_le(s, 0); /* clipDataId */
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
s_mark_end(s);
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
|
|
|
|
free_stream(s);
|
2012-11-05 01:52:33 +04:00
|
|
|
g_file_request_sent_type = CB_FILECONTENTS_SIZE;
|
2012-11-04 05:47:04 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* send a chunk of the file from server to client */
|
2017-03-12 19:35:00 +03:00
|
|
|
static int
|
2012-10-14 22:46:01 +04:00
|
|
|
clipboard_send_file_data(int streamId, int lindex,
|
|
|
|
int nPositionLow, int cbRequested)
|
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
int size;
|
|
|
|
int rv;
|
|
|
|
int fd;
|
|
|
|
char full_fn[256];
|
2012-11-08 10:48:18 +04:00
|
|
|
struct cb_file_info *cfi;
|
2012-10-14 22:46:01 +04:00
|
|
|
|
2012-11-08 10:48:18 +04:00
|
|
|
if (g_files_list == 0)
|
|
|
|
{
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_data: error g_files_list is nil");
|
2021-09-15 12:20:15 +03:00
|
|
|
clipboard_send_filecontents_response_fail(streamId);
|
2012-11-08 10:48:18 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
cfi = (struct cb_file_info *)list_get_item(g_files_list, lindex);
|
|
|
|
if (cfi == 0)
|
|
|
|
{
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_data: error cfi is nil");
|
2021-09-15 12:20:15 +03:00
|
|
|
clipboard_send_filecontents_response_fail(streamId);
|
2012-11-08 10:48:18 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_send_file_data: streamId %d lindex %d "
|
2020-11-30 03:36:20 +03:00
|
|
|
"nPositionLow %d cbRequested %d", streamId, lindex,
|
|
|
|
nPositionLow, cbRequested);
|
2012-11-08 10:48:18 +04:00
|
|
|
g_snprintf(full_fn, 255, "%s/%s", cfi->pathname, cfi->filename);
|
2012-10-14 22:46:01 +04:00
|
|
|
fd = g_file_open_ex(full_fn, 1, 0, 0, 0);
|
|
|
|
if (fd == -1)
|
|
|
|
{
|
2021-09-15 12:20:15 +03:00
|
|
|
LOG(LOG_LEVEL_ERROR, "clipboard_send_file_data: file open [%s] failed: %s",
|
|
|
|
full_fn, g_get_strerror());
|
|
|
|
clipboard_send_filecontents_response_fail(streamId);
|
2012-10-14 22:46:01 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2014-07-21 00:14:09 +04:00
|
|
|
if (g_file_seek(fd, nPositionLow) < 0)
|
|
|
|
{
|
2021-09-21 12:19:47 +03:00
|
|
|
LOG(LOG_LEVEL_ERROR, "clipboard_send_file_data: seek error in file [%s]: %s",
|
|
|
|
full_fn, g_get_strerror());
|
2014-07-21 00:14:09 +04:00
|
|
|
g_file_close(fd);
|
2021-09-15 12:20:15 +03:00
|
|
|
clipboard_send_filecontents_response_fail(streamId);
|
2014-07-21 00:14:09 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2012-10-14 22:46:01 +04:00
|
|
|
make_stream(s);
|
|
|
|
init_stream(s, cbRequested + 64);
|
|
|
|
size = g_file_read(fd, s->data + 12, cbRequested);
|
|
|
|
if (size < 1)
|
|
|
|
{
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_data: read error, want %d got %d",
|
2020-11-30 03:36:20 +03:00
|
|
|
cbRequested, size);
|
2012-10-14 22:46:01 +04:00
|
|
|
free_stream(s);
|
|
|
|
g_file_close(fd);
|
2021-09-15 12:20:15 +03:00
|
|
|
clipboard_send_filecontents_response_fail(streamId);
|
2012-10-14 22:46:01 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
out_uint16_le(s, CB_FILECONTENTS_RESPONSE); /* 9 */
|
|
|
|
out_uint16_le(s, CB_RESPONSE_OK); /* 1 status */
|
|
|
|
out_uint32_le(s, size + 4);
|
|
|
|
out_uint32_le(s, streamId);
|
|
|
|
s->p += size;
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
s_mark_end(s);
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
|
|
|
|
free_stream(s);
|
|
|
|
g_file_close(fd);
|
2021-07-27 11:09:43 +03:00
|
|
|
|
|
|
|
/* Log who transferred which file via clipboard for the purpose of audit */
|
|
|
|
LOG(LOG_LEVEL_INFO, "S2C: Transfered a file: filename=%s, uid=%d", full_fn, g_getuid());
|
|
|
|
|
2012-10-14 22:46:01 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-11-05 01:52:33 +04:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* ask the client to send the file size */
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2012-11-05 01:52:33 +04:00
|
|
|
clipboard_request_file_data(int stream_id, int lindex, int offset,
|
|
|
|
int request_bytes)
|
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
int size;
|
|
|
|
int rv;
|
|
|
|
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_request_file_data: stream_id=%d lindex=%d off=%d request_bytes=%d",
|
2020-11-30 03:36:20 +03:00
|
|
|
stream_id, lindex, offset, request_bytes);
|
2013-04-27 05:55:28 +04:00
|
|
|
|
2012-11-05 01:52:33 +04:00
|
|
|
if (g_file_request_sent_type != 0)
|
|
|
|
{
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_request_file_data: warning, still waiting "
|
2020-11-30 03:36:20 +03:00
|
|
|
"for CB_FILECONTENTS_RESPONSE");
|
2012-11-05 01:52:33 +04:00
|
|
|
}
|
|
|
|
make_stream(s);
|
|
|
|
init_stream(s, 8192);
|
|
|
|
out_uint16_le(s, CB_FILECONTENTS_REQUEST); /* 8 */
|
|
|
|
out_uint16_le(s, 0);
|
|
|
|
out_uint32_le(s, 28);
|
|
|
|
out_uint32_le(s, stream_id);
|
|
|
|
out_uint32_le(s, lindex);
|
|
|
|
out_uint32_le(s, CB_FILECONTENTS_RANGE);
|
|
|
|
out_uint32_le(s, offset); /* nPositionLow */
|
|
|
|
out_uint32_le(s, 0); /* nPositionHigh */
|
|
|
|
out_uint32_le(s, request_bytes); /* cbRequested */
|
|
|
|
out_uint32_le(s, 0); /* clipDataId */
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
s_mark_end(s);
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
|
|
|
|
free_stream(s);
|
|
|
|
g_file_request_sent_type = CB_FILECONTENTS_RANGE;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-14 22:46:01 +04:00
|
|
|
/*****************************************************************************/
|
2012-11-08 10:48:18 +04:00
|
|
|
/* client is asking from info about a file */
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2012-10-14 22:46:01 +04:00
|
|
|
clipboard_process_file_request(struct stream *s, int clip_msg_status,
|
|
|
|
int clip_msg_len)
|
|
|
|
{
|
|
|
|
int streamId;
|
|
|
|
int lindex;
|
|
|
|
int dwFlags;
|
|
|
|
int nPositionLow;
|
|
|
|
int cbRequested;
|
|
|
|
//int clipDataId;
|
|
|
|
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_process_file_request:");
|
2020-11-30 03:36:20 +03:00
|
|
|
LOG_DEVEL_HEXDUMP(LOG_LEVEL_TRACE, "", s->p, clip_msg_len);
|
2012-10-14 22:46:01 +04:00
|
|
|
in_uint32_le(s, streamId);
|
|
|
|
in_uint32_le(s, lindex);
|
|
|
|
in_uint32_le(s, dwFlags);
|
|
|
|
in_uint32_le(s, nPositionLow);
|
2016-04-23 09:40:48 +03:00
|
|
|
in_uint8s(s, 4); /* nPositionHigh */
|
2012-10-14 22:46:01 +04:00
|
|
|
in_uint32_le(s, cbRequested);
|
|
|
|
//in_uint32_le(s, clipDataId); /* options, used when locking */
|
|
|
|
if (dwFlags & CB_FILECONTENTS_SIZE)
|
|
|
|
{
|
|
|
|
clipboard_send_file_size(streamId, lindex);
|
|
|
|
}
|
|
|
|
if (dwFlags & CB_FILECONTENTS_RANGE)
|
|
|
|
{
|
|
|
|
clipboard_send_file_data(streamId, lindex, nPositionLow, cbRequested);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-30 07:12:24 +04:00
|
|
|
|
2012-11-05 01:52:33 +04:00
|
|
|
/*****************************************************************************/
|
2016-01-14 19:32:09 +03:00
|
|
|
/* server requested info about the file and this is the response
|
2012-11-05 01:52:33 +04:00
|
|
|
it's either the file size or file data */
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2012-11-05 01:52:33 +04:00
|
|
|
clipboard_process_file_response(struct stream *s, int clip_msg_status,
|
|
|
|
int clip_msg_len)
|
|
|
|
{
|
|
|
|
int streamId;
|
|
|
|
int file_size;
|
|
|
|
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_process_file_response:");
|
2012-11-05 01:52:33 +04:00
|
|
|
if (g_file_request_sent_type == CB_FILECONTENTS_SIZE)
|
|
|
|
{
|
2012-11-05 13:04:04 +04:00
|
|
|
g_file_request_sent_type = 0;
|
2012-11-05 01:52:33 +04:00
|
|
|
in_uint32_le(s, streamId);
|
|
|
|
in_uint32_le(s, file_size);
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_process_file_response: streamId %d "
|
2020-11-30 03:36:20 +03:00
|
|
|
"file_size %d", streamId, file_size);
|
2013-03-09 03:37:30 +04:00
|
|
|
xfuse_file_contents_size(streamId, file_size);
|
2012-11-05 01:52:33 +04:00
|
|
|
}
|
|
|
|
else if (g_file_request_sent_type == CB_FILECONTENTS_RANGE)
|
|
|
|
{
|
2012-11-05 13:04:04 +04:00
|
|
|
g_file_request_sent_type = 0;
|
2012-11-05 01:52:33 +04:00
|
|
|
in_uint32_le(s, streamId);
|
2013-03-09 03:37:30 +04:00
|
|
|
xfuse_file_contents_range(streamId, s->p, clip_msg_len - 4);
|
2012-11-05 01:52:33 +04:00
|
|
|
}
|
2012-11-05 13:04:04 +04:00
|
|
|
else
|
|
|
|
{
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_process_file_response: error");
|
2012-11-05 13:04:04 +04:00
|
|
|
g_file_request_sent_type = 0;
|
|
|
|
}
|
2012-11-05 01:52:33 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-30 07:12:24 +04:00
|
|
|
/*****************************************************************************/
|
2021-09-09 16:35:44 +03:00
|
|
|
/* read in CLIPRDR_FILEDESCRIPTOR [MS-RDPECLIP] 2.2.5.2.3.1 */
|
2017-03-12 19:35:00 +03:00
|
|
|
static int
|
2012-10-30 07:12:24 +04:00
|
|
|
clipboard_c2s_in_file_info(struct stream *s, struct clip_file_desc *cfd)
|
|
|
|
{
|
|
|
|
int num_chars;
|
2021-09-09 16:34:27 +03:00
|
|
|
int filename_bytes;
|
2012-10-30 07:12:24 +04:00
|
|
|
int ex_bytes;
|
|
|
|
|
2021-09-09 16:35:44 +03:00
|
|
|
if (!s_check_rem_and_log(s, 4 + 32 + 4 + 16 + 8 + 8 + 520,
|
|
|
|
"Parsing [MS-RDPECLIP] CLIPRDR_FILEDESCRIPTOR"))
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2012-10-30 07:12:24 +04:00
|
|
|
in_uint32_le(s, cfd->flags);
|
|
|
|
in_uint8s(s, 32); /* reserved1 */
|
|
|
|
in_uint32_le(s, cfd->fileAttributes);
|
|
|
|
in_uint8s(s, 16); /* reserved2 */
|
|
|
|
in_uint32_le(s, cfd->lastWriteTimeLow);
|
|
|
|
in_uint32_le(s, cfd->lastWriteTimeHigh);
|
|
|
|
in_uint32_le(s, cfd->fileSizeHigh);
|
|
|
|
in_uint32_le(s, cfd->fileSizeLow);
|
2021-09-09 16:28:19 +03:00
|
|
|
num_chars = sizeof(cfd->cFileName);
|
2021-09-09 16:34:27 +03:00
|
|
|
filename_bytes = clipboard_in_unicode(s, cfd->cFileName, &num_chars);
|
|
|
|
ex_bytes = 520 - filename_bytes;
|
2012-10-30 07:12:24 +04:00
|
|
|
in_uint8s(s, ex_bytes);
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_c2s_in_file_info:");
|
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, " flags 0x%8.8x", cfd->flags);
|
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, " fileAttributes 0x%8.8x", cfd->fileAttributes);
|
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, " lastWriteTime 0x%8.8x%8.8x", cfd->lastWriteTimeHigh,
|
2020-11-30 03:36:20 +03:00
|
|
|
cfd->lastWriteTimeLow);
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, " fileSize 0x%8.8x%8.8x", cfd->fileSizeHigh,
|
2020-11-30 03:36:20 +03:00
|
|
|
cfd->fileSizeLow);
|
2020-10-08 04:55:08 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, " num_chars %d cFileName [%s]", num_chars, cfd->cFileName);
|
2012-10-30 07:12:24 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2021-09-14 16:43:33 +03:00
|
|
|
clipboard_c2s_in_files(struct stream *s, char *file_list, int file_list_size,
|
|
|
|
const char *fprefix)
|
2012-10-30 07:12:24 +04:00
|
|
|
{
|
2021-09-14 16:34:47 +03:00
|
|
|
int citems;
|
2012-11-05 01:52:33 +04:00
|
|
|
int lindex;
|
2012-11-05 13:04:04 +04:00
|
|
|
int str_len;
|
2021-09-09 16:31:38 +03:00
|
|
|
struct clip_file_desc cfd;
|
2012-11-05 13:04:04 +04:00
|
|
|
char *ptr;
|
2021-09-14 16:34:47 +03:00
|
|
|
char *last; /* Last writeable char in buffer */
|
|
|
|
int dropped_files = 0; /* # files we can't add to buffer */
|
2012-10-30 07:12:24 +04:00
|
|
|
|
2021-09-14 16:34:47 +03:00
|
|
|
if (file_list_size < 1)
|
|
|
|
{
|
|
|
|
LOG(LOG_LEVEL_ERROR, "clipboard_c2s_in_files: No space in string");
|
|
|
|
return 1;
|
|
|
|
}
|
2013-02-16 06:35:44 +04:00
|
|
|
if (!s_check_rem(s, 4))
|
|
|
|
{
|
2021-09-14 16:34:47 +03:00
|
|
|
LOG(LOG_LEVEL_ERROR, "clipboard_c2s_in_files: parse error");
|
2013-02-16 06:35:44 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2021-09-14 16:34:47 +03:00
|
|
|
in_uint32_le(s, citems);
|
|
|
|
if (citems < 0 || citems > 64 * 1024) /* sanity check */
|
2013-02-16 06:35:44 +04:00
|
|
|
{
|
2021-09-14 16:34:47 +03:00
|
|
|
LOG(LOG_LEVEL_ERROR, "clipboard_c2s_in_files: "
|
|
|
|
"Bad number of files in list (%d)", citems);
|
2013-02-16 06:35:44 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2013-03-09 03:37:30 +04:00
|
|
|
xfuse_clear_clip_dir();
|
2021-09-14 16:34:47 +03:00
|
|
|
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_c2s_in_files: cItems %d", citems);
|
2012-11-05 13:04:04 +04:00
|
|
|
ptr = file_list;
|
2021-09-14 16:34:47 +03:00
|
|
|
last = file_list + file_list_size - 1;
|
|
|
|
|
|
|
|
for (lindex = 0; lindex < citems; lindex++)
|
2012-10-30 07:12:24 +04:00
|
|
|
{
|
2021-09-09 16:31:38 +03:00
|
|
|
g_memset(&cfd, 0, sizeof(struct clip_file_desc));
|
2021-09-09 16:35:44 +03:00
|
|
|
if (clipboard_c2s_in_file_info(s, &cfd) != 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2021-09-09 16:31:38 +03:00
|
|
|
if ((g_pos(cfd.cFileName, "\\") >= 0) ||
|
|
|
|
(cfd.fileAttributes & CB_FILE_ATTRIBUTE_DIRECTORY))
|
2012-11-08 11:38:28 +04:00
|
|
|
{
|
2021-09-14 16:34:47 +03:00
|
|
|
LOG(LOG_LEVEL_WARNING, "clipboard_c2s_in_files: skipping "
|
|
|
|
"directory not supported [%s]", cfd.cFileName);
|
2012-11-08 11:38:28 +04:00
|
|
|
continue;
|
|
|
|
}
|
2021-09-14 16:34:47 +03:00
|
|
|
|
|
|
|
/* Have we already run out of room in the list? */
|
|
|
|
if (dropped_files > 0)
|
|
|
|
{
|
|
|
|
dropped_files += 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Room for this file? */
|
|
|
|
str_len = (ptr == file_list) ? 0 : 1; /* Delimiter */
|
2021-09-14 16:43:33 +03:00
|
|
|
str_len += g_strlen(fprefix); /* e.g. "file://" */
|
2021-09-14 16:34:47 +03:00
|
|
|
str_len += g_strlen(g_fuse_clipboard_path);
|
|
|
|
str_len += 1; /* '/' */
|
|
|
|
str_len += g_strlen(cfd.cFileName);
|
|
|
|
if (str_len > (last - ptr))
|
|
|
|
{
|
|
|
|
dropped_files += 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-09-09 16:31:38 +03:00
|
|
|
if (xfuse_add_clip_dir_item(cfd.cFileName, 0, cfd.fileSizeLow, lindex) == -1)
|
2016-07-21 10:02:21 +03:00
|
|
|
{
|
2021-09-14 16:34:47 +03:00
|
|
|
LOG(LOG_LEVEL_WARNING, "clipboard_c2s_in_files: "
|
|
|
|
"failed to add clip dir item %s", cfd.cFileName);
|
2016-07-21 10:02:21 +03:00
|
|
|
continue;
|
|
|
|
}
|
2012-11-05 13:04:04 +04:00
|
|
|
|
2021-09-14 16:34:47 +03:00
|
|
|
if (ptr > file_list)
|
2015-03-13 22:58:31 +03:00
|
|
|
{
|
2021-09-14 16:34:47 +03:00
|
|
|
*ptr++ = '\n';
|
2015-03-13 22:58:31 +03:00
|
|
|
}
|
|
|
|
|
2021-09-14 16:43:33 +03:00
|
|
|
str_len = g_strlen(fprefix);
|
|
|
|
g_strcpy(ptr, fprefix);
|
2021-09-14 16:34:47 +03:00
|
|
|
ptr += str_len;
|
2012-11-05 13:04:04 +04:00
|
|
|
|
2013-04-27 05:55:28 +04:00
|
|
|
str_len = g_strlen(g_fuse_clipboard_path);
|
|
|
|
g_strcpy(ptr, g_fuse_clipboard_path);
|
2012-11-05 13:04:04 +04:00
|
|
|
ptr += str_len;
|
2021-09-14 16:34:47 +03:00
|
|
|
*ptr++ = '/';
|
2012-11-05 13:04:04 +04:00
|
|
|
|
2021-09-09 16:31:38 +03:00
|
|
|
str_len = g_strlen(cfd.cFileName);
|
|
|
|
g_strcpy(ptr, cfd.cFileName);
|
2012-11-05 13:04:04 +04:00
|
|
|
ptr += str_len;
|
2012-10-30 07:12:24 +04:00
|
|
|
}
|
2021-09-14 16:34:47 +03:00
|
|
|
*ptr = '\0';
|
|
|
|
|
|
|
|
if (dropped_files > 0)
|
|
|
|
{
|
|
|
|
LOG(LOG_LEVEL_WARNING, "clipboard_c2s_in_files: "
|
|
|
|
"Dropped %d files from the clip buffer due to insufficient space",
|
|
|
|
dropped_files);
|
|
|
|
}
|
2012-10-30 07:12:24 +04:00
|
|
|
return 0;
|
|
|
|
}
|