mirror of https://github.com/FreeRDP/FreeRDP
Replaced snprintf with sprintf_s
This commit is contained in:
parent
358289fb51
commit
cf9f975341
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/string.h>
|
||||
#include <winpr/thread.h>
|
||||
#include <winpr/cmdline.h>
|
||||
|
||||
|
@ -171,8 +172,8 @@ static void* audin_oss_thread_func(void* arg)
|
|||
|
||||
if (oss->dev_unit != -1)
|
||||
{
|
||||
snprintf(dev_name, (PATH_MAX - 1), "/dev/dsp%i", oss->dev_unit);
|
||||
snprintf(mixer_name, PATH_MAX - 1, "/dev/mixer%i", oss->dev_unit);
|
||||
sprintf_s(dev_name, (PATH_MAX - 1), "/dev/dsp%i", oss->dev_unit);
|
||||
sprintf_s(mixer_name, PATH_MAX - 1, "/dev/mixer%i", oss->dev_unit);
|
||||
}
|
||||
|
||||
WLog_INFO(TAG, "open: %s", dev_name);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/string.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/thread.h>
|
||||
#include <winpr/stream.h>
|
||||
|
@ -726,7 +727,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
|||
/* Special case: path[0] == '%' -> user home dir */
|
||||
if (strcmp(drive->Path, "%") == 0)
|
||||
{
|
||||
_snprintf(buf, sizeof(buf), "%s\\", getenv("USERPROFILE"));
|
||||
sprintf_s(buf, sizeof(buf), "%s\\", getenv("USERPROFILE"));
|
||||
drive_register_drive_path(pEntryPoints, drive->Name, _strdup(buf));
|
||||
}
|
||||
else if (strcmp(drive->Path, "*") == 0)
|
||||
|
@ -741,7 +742,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
|||
if (*dev > 'B')
|
||||
{
|
||||
/* Suppress disk drives A and B to avoid pesty messages */
|
||||
len = _snprintf(buf, sizeof(buf) - 4, "%s", drive->Name);
|
||||
len = sprintf_s(buf, sizeof(buf) - 4, "%s", drive->Name);
|
||||
buf[len] = '_';
|
||||
buf[len + 1] = dev[0];
|
||||
buf[len + 2] = 0;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <cups/cups.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/string.h>
|
||||
|
||||
#include <freerdp/channels/rdpdr.h>
|
||||
|
||||
|
@ -70,7 +71,7 @@ static void printer_cups_get_printjob_name(char* buf, int size)
|
|||
|
||||
tt = time(NULL);
|
||||
t = localtime(&tt);
|
||||
snprintf(buf, size - 1, "FreeRDP Print Job %d%02d%02d%02d%02d%02d",
|
||||
sprintf_s(buf, size - 1, "FreeRDP Print Job %d%02d%02d%02d%02d%02d",
|
||||
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
|
||||
t->tm_hour, t->tm_min, t->tm_sec);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/string.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/thread.h>
|
||||
#include <winpr/stream.h>
|
||||
|
@ -238,7 +239,7 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
|
|||
PRINTER_DEVICE* printer_dev;
|
||||
|
||||
port = malloc(10);
|
||||
snprintf(port, 10, "PRN%d", printer->id);
|
||||
sprintf_s(port, 10, "PRN%d", printer->id);
|
||||
|
||||
printer_dev = (PRINTER_DEVICE*) malloc(sizeof(PRINTER_DEVICE));
|
||||
ZeroMemory(printer_dev, sizeof(PRINTER_DEVICE));
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/string.h>
|
||||
#include <winpr/windows.h>
|
||||
|
||||
#include <time.h>
|
||||
|
@ -69,7 +70,7 @@ static void printer_win_get_printjob_name(char* buf, int size)
|
|||
|
||||
tt = time(NULL);
|
||||
t = localtime(&tt);
|
||||
snprintf(buf, size - 1, "FreeRDP Print Job %d%02d%02d%02d%02d%02d",
|
||||
sprintf_s(buf, size - 1, "FreeRDP Print Job %d%02d%02d%02d%02d%02d",
|
||||
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
|
||||
t->tm_hour, t->tm_min, t->tm_sec);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,3 @@ rdpPrinterDriver* printer_win_get_driver(void);
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/string.h>
|
||||
#include <winpr/cmdline.h>
|
||||
#include <winpr/sysinfo.h>
|
||||
#include <winpr/collections.h>
|
||||
|
@ -190,7 +191,7 @@ static void rdpsnd_oss_open_mixer(rdpsndOssPlugin* oss)
|
|||
return;
|
||||
|
||||
if (oss->dev_unit != -1)
|
||||
snprintf(mixer_name, PATH_MAX - 1, "/dev/mixer%i", oss->dev_unit);
|
||||
sprintf_s(mixer_name, PATH_MAX - 1, "/dev/mixer%i", oss->dev_unit);
|
||||
|
||||
if ((oss->mixer_handle = open(mixer_name, O_RDWR)) < 0)
|
||||
{
|
||||
|
@ -217,7 +218,7 @@ static void rdpsnd_oss_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, in
|
|||
return;
|
||||
|
||||
if (oss->dev_unit != -1)
|
||||
snprintf(dev_name, PATH_MAX - 1, "/dev/dsp%i", oss->dev_unit);
|
||||
sprintf_s(dev_name, PATH_MAX - 1, "/dev/dsp%i", oss->dev_unit);
|
||||
|
||||
WLog_INFO(TAG, "open: %s", dev_name);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <winpr/thread.h>
|
||||
#include <winpr/string.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
#if GST_VERSION_MAJOR > 0
|
||||
|
@ -65,7 +66,7 @@ struct X11Handle
|
|||
static const char* get_shm_id()
|
||||
{
|
||||
static char shm_id[128];
|
||||
snprintf(shm_id, sizeof(shm_id), "/com.freerdp.xfreerdp.tsmf_%016X", GetCurrentProcessId());
|
||||
sprintf_s(shm_id, sizeof(shm_id), "/com.freerdp.xfreerdp.tsmf_%016X", GetCurrentProcessId());
|
||||
return shm_id;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <winpr/string.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/app/gstappsrc.h>
|
||||
#include <gst/app/gstappsink.h>
|
||||
|
@ -422,9 +424,9 @@ BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder* mdecoder)
|
|||
* The only fixed elements necessary are appsrc and the volume element for audio streams.
|
||||
* The rest could easily be provided in gstreamer pipeline notation from command line. */
|
||||
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
||||
snprintf(pipeline, sizeof(pipeline), "%s %s %s name=outsink", appsrc, video, tsmf_platform_get_video_sink());
|
||||
sprintf_s(pipeline, sizeof(pipeline), "%s %s %s name=outsink", appsrc, video, tsmf_platform_get_video_sink());
|
||||
else
|
||||
snprintf(pipeline, sizeof(pipeline), "%s %s %s name=outsink", appsrc, audio, tsmf_platform_get_audio_sink());
|
||||
sprintf_s(pipeline, sizeof(pipeline), "%s %s %s name=outsink", appsrc, audio, tsmf_platform_get_audio_sink());
|
||||
|
||||
DEBUG_TSMF("pipeline=%s", pipeline);
|
||||
mdecoder->pipe = gst_parse_launch(pipeline, NULL);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/string.h>
|
||||
#include <winpr/thread.h>
|
||||
#include <winpr/stream.h>
|
||||
#include <winpr/collections.h>
|
||||
|
@ -314,7 +315,7 @@ static char* guid_to_string(const BYTE* guid, char* str, size_t len)
|
|||
return NULL;
|
||||
|
||||
for (i=0; i<GUID_SIZE && len > 2*i; i++)
|
||||
snprintf(str + (2*i), len - 2*i, "%02X", guid[i]);
|
||||
sprintf_s(str + (2*i), len - 2*i, "%02X", guid[i]);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
@ -391,10 +392,10 @@ static void tsmf_sample_playback_video(TSMF_SAMPLE* sample)
|
|||
|
||||
if ((frame_id % 30) == 0)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "/tmp/FreeRDP_Frame_%d.ppm", frame_id);
|
||||
sprintf_s(buf, sizeof(buf), "/tmp/FreeRDP_Frame_%d.ppm", frame_id);
|
||||
fp = fopen(buf, "wb");
|
||||
fwrite("P5\n", 1, 3, fp);
|
||||
snprintf(buf, sizeof(buf), "%d %d\n", sample->stream->width, sample->stream->height);
|
||||
sprintf_s(buf, sizeof(buf), "%d %d\n", sample->stream->width, sample->stream->height);
|
||||
fwrite(buf, 1, strlen(buf), fp);
|
||||
fwrite("255\n", 1, 4, fp);
|
||||
fwrite(sample->data, 1, sample->stream->width * sample->stream->height, fp);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/string.h>
|
||||
#include <winpr/cmdline.h>
|
||||
|
||||
#include <freerdp/dvc.h>
|
||||
|
@ -57,10 +58,10 @@ static int func_hardware_id_format(IUDEVICE* pdev, char(*HardwareIds)[DEVICE_HAR
|
|||
idProduct = (UINT16)pdev->query_device_descriptor(pdev, ID_PRODUCT);
|
||||
bcdDevice = (UINT16)pdev->query_device_descriptor(pdev, BCD_DEVICE);
|
||||
|
||||
snprintf(str, sizeof(str), "USB\\VID_%04X&PID_%04X", idVendor, idProduct);
|
||||
sprintf_s(str, sizeof(str), "USB\\VID_%04X&PID_%04X", idVendor, idProduct);
|
||||
strcpy(HardwareIds[1], str);
|
||||
|
||||
snprintf(str, sizeof(str), "%s&REV_%04X", HardwareIds[1], bcdDevice);
|
||||
sprintf_s(str, sizeof(str), "%s&REV_%04X", HardwareIds[1], bcdDevice);
|
||||
strcpy(HardwareIds[0], str);
|
||||
|
||||
return 0;
|
||||
|
@ -77,20 +78,20 @@ static int func_compat_id_format(IUDEVICE* pdev, char (*CompatibilityIds)[DEVICE
|
|||
|
||||
if(!(pdev->isCompositeDevice(pdev)))
|
||||
{
|
||||
snprintf(str, sizeof(str),"USB\\Class_%02X", bDeviceClass);
|
||||
sprintf_s(str, sizeof(str),"USB\\Class_%02X", bDeviceClass);
|
||||
strcpy(CompatibilityIds[2], str);
|
||||
snprintf(str, sizeof(str),"%s&SubClass_%02X", CompatibilityIds[2], bDeviceSubClass);
|
||||
sprintf_s(str, sizeof(str),"%s&SubClass_%02X", CompatibilityIds[2], bDeviceSubClass);
|
||||
strcpy(CompatibilityIds[1], str);
|
||||
snprintf(str, sizeof(str),"%s&Prot_%02X", CompatibilityIds[1], bDeviceProtocol);
|
||||
sprintf_s(str, sizeof(str),"%s&Prot_%02X", CompatibilityIds[1], bDeviceProtocol);
|
||||
strcpy(CompatibilityIds[0], str);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(str, sizeof(str),"USB\\DevClass_00");
|
||||
sprintf_s(str, sizeof(str),"USB\\DevClass_00");
|
||||
strcpy(CompatibilityIds[2], str);
|
||||
snprintf(str, sizeof(str),"%s&SubClass_00", CompatibilityIds[2]);
|
||||
sprintf_s(str, sizeof(str),"%s&SubClass_00", CompatibilityIds[2]);
|
||||
strcpy(CompatibilityIds[1], str);
|
||||
snprintf(str, sizeof(str),"%s&Prot_00", CompatibilityIds[1]);
|
||||
sprintf_s(str, sizeof(str),"%s&Prot_00", CompatibilityIds[1]);
|
||||
strcpy(CompatibilityIds[0], str);
|
||||
}
|
||||
|
||||
|
@ -161,10 +162,10 @@ static int func_container_id_generate(IUDEVICE* pdev, char* strContainerId)
|
|||
p = path;
|
||||
|
||||
ZeroMemory(containerId, sizeof(containerId));
|
||||
snprintf((char*)containerId, sizeof(containerId), "%04X%04X%s", idVendor, idProduct, p);
|
||||
sprintf_s((char*)containerId, sizeof(containerId), "%04X%04X%s", idVendor, idProduct, p);
|
||||
|
||||
/* format */
|
||||
snprintf(strContainerId, DEVICE_CONTAINER_STR_SIZE,
|
||||
sprintf_s(strContainerId, DEVICE_CONTAINER_STR_SIZE,
|
||||
"{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
||||
containerId[0], containerId[1],containerId[2], containerId[3],
|
||||
containerId[4], containerId[5], containerId[6], containerId[7],
|
||||
|
@ -180,10 +181,10 @@ static int func_instance_id_generate(IUDEVICE* pdev, char* strInstanceId)
|
|||
|
||||
memset(instanceId, 0, 17);
|
||||
ZeroMemory(instanceId, sizeof(instanceId));
|
||||
snprintf((char*)instanceId, sizeof(instanceId), "\\%s", pdev->getPath(pdev));
|
||||
sprintf_s((char*)instanceId, sizeof(instanceId), "\\%s", pdev->getPath(pdev));
|
||||
|
||||
/* format */
|
||||
snprintf(strInstanceId, DEVICE_INSTANCE_STR_SIZE,
|
||||
sprintf_s(strInstanceId, DEVICE_INSTANCE_STR_SIZE,
|
||||
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
instanceId[0], instanceId[1],instanceId[2], instanceId[3],
|
||||
instanceId[4], instanceId[5], instanceId[6], instanceId[7],
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include <winpr/thread.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/string.h>
|
||||
|
||||
#include <freerdp/rail.h>
|
||||
#include <freerdp/log.h>
|
||||
|
@ -335,7 +336,7 @@ static void xf_SetWindowPID(xfContext* xfc, Window window, pid_t pid)
|
|||
static const char* get_shm_id()
|
||||
{
|
||||
static char shm_id[64];
|
||||
snprintf(shm_id, sizeof(shm_id), "/com.freerdp.xfreerdp.tsmf_%016X", GetCurrentProcessId());
|
||||
sprintf_s(shm_id, sizeof(shm_id), "/com.freerdp.xfreerdp.tsmf_%016X", GetCurrentProcessId());
|
||||
return shm_id;
|
||||
}
|
||||
|
||||
|
@ -659,7 +660,7 @@ int xf_AppWindowInit(xfContext* xfc, xfAppWindow* appWindow)
|
|||
else
|
||||
{
|
||||
class = malloc(sizeof("RAIL:00000000"));
|
||||
snprintf(class, sizeof("RAIL:00000000"), "RAIL:%08X", appWindow->windowId);
|
||||
sprintf_s(class, sizeof("RAIL:00000000"), "RAIL:%08X", appWindow->windowId);
|
||||
class_hints->res_class = class;
|
||||
}
|
||||
|
||||
|
|
|
@ -913,7 +913,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
/* Open the server socket and start listening. */
|
||||
snprintf(name, sizeof(name), "tfreerdp-server.%d", port);
|
||||
sprintf_s(name, sizeof(name), "tfreerdp-server.%d", port);
|
||||
file = GetKnownSubPath(KNOWN_PATH_TEMP, name);
|
||||
if (!file)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/string.h>
|
||||
|
||||
/* Data Conversion: http://msdn.microsoft.com/en-us/library/0heszx3w/ */
|
||||
|
||||
|
@ -31,12 +32,12 @@ errno_t _itoa_s(int value, char* buffer, size_t sizeInCharacters, int radix)
|
|||
{
|
||||
int length;
|
||||
|
||||
length = snprintf(NULL, 0, "%d", value);
|
||||
length = sprintf_s(NULL, 0, "%d", value);
|
||||
|
||||
if (sizeInCharacters < length)
|
||||
return -1;
|
||||
|
||||
snprintf(buffer, length + 1, "%d", value);
|
||||
sprintf_s(buffer, length + 1, "%d", value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <winpr/string.h>
|
||||
|
||||
#if defined(HAVE_EXECINFO_H)
|
||||
#include <execinfo.h>
|
||||
|
@ -394,10 +395,10 @@ char** winpr_backtrace_symbols(void* buffer, size_t* used)
|
|||
|
||||
if (SymGetLineFromAddr64(process, address, &displacement, line))
|
||||
{
|
||||
_snprintf(vlines[i], line_len, "%08lX: %s in %s:%lu", symbol->Address, symbol->Name, line->FileName, line->LineNumber);
|
||||
sprintf_s(vlines[i], line_len, "%08lX: %s in %s:%lu", symbol->Address, symbol->Name, line->FileName, line->LineNumber);
|
||||
}
|
||||
else
|
||||
_snprintf(vlines[i], line_len, "%08lX: %s", symbol->Address, symbol->Name);
|
||||
sprintf_s(vlines[i], line_len, "%08lX: %s", symbol->Address, symbol->Name);
|
||||
}
|
||||
|
||||
if (used)
|
||||
|
|
Loading…
Reference in New Issue