Skip to content

Commit

Permalink
Merge pull request FreeRDP#4055 from akallabeth/talos_v3
Browse files Browse the repository at this point in the history
Security fixes and code cleanups
nfedera authored Jul 24, 2017
2 parents 72cd36c + f23e10f commit 1648deb
Showing 319 changed files with 1,122 additions and 1,029 deletions.
6 changes: 3 additions & 3 deletions buildflags.h.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _FREERDP_BUILD_FLAGS_H
#define _FREERDP_BUILD_FLAGS_H
#ifndef FREERDP_BUILD_FLAGS_H
#define FREERDP_BUILD_FLAGS_H

#define CFLAGS "${CMAKE_C_FLAGS}"
#define COMPILER_ID "${CMAKE_C_COMPILER_ID}"
@@ -8,4 +8,4 @@
#define BUILD_CONFIG "${FREERDP_BUILD_CONFIG}"
#define BUILD_TYPE "${CMAKE_BUILD_TYPE}"

#endif /*_FREERDP_BUILD_FLAGS_H */
#endif /* FREERDP_BUILD_FLAGS_H */
4 changes: 2 additions & 2 deletions channels/audin/client/alsa/audin_alsa.c
Original file line number Diff line number Diff line change
@@ -229,7 +229,7 @@ static void* audin_alsa_thread_func(void* arg)
DWORD status;
DEBUG_DVC("in");
rbytes_per_frame = alsa->actual_channels * alsa->bytes_per_channel;
buffer = (BYTE*) calloc(1, rbytes_per_frame * alsa->frames_per_packet);
buffer = (BYTE*) calloc(alsa->frames_per_packet, rbytes_per_frame);

if (!buffer)
{
@@ -410,7 +410,7 @@ static UINT audin_alsa_open(IAudinDevice* device, AudinReceive receive,
alsa->receive = receive;
alsa->user_data = user_data;
tbytes_per_frame = alsa->target_channels * alsa->bytes_per_channel;
alsa->buffer = (BYTE*) calloc(1, tbytes_per_frame * alsa->frames_per_packet);
alsa->buffer = (BYTE*) calloc(alsa->frames_per_packet, tbytes_per_frame);

if (!alsa->buffer)
{
2 changes: 1 addition & 1 deletion channels/audin/client/audin_main.c
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ static UINT audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback,
}

Stream_Seek_UINT32(s); /* cbSizeFormatsPacket */
callback->formats = (audinFormat*) calloc(1, NumFormats * sizeof(audinFormat));
callback->formats = (audinFormat*) calloc(NumFormats, sizeof(audinFormat));

if (!callback->formats)
{
6 changes: 3 additions & 3 deletions channels/audin/client/audin_main.h
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
* limitations under the License.
*/

#ifndef FREERDP_AUDIN_CLIENT_MAIN_H
#define FREERDP_AUDIN_CLIENT_MAIN_H
#ifndef FREERDP_CHANNEL_AUDIN_CLIENT_MAIN_H
#define FREERDP_CHANNEL_AUDIN_CLIENT_MAIN_H

#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -38,5 +38,5 @@
#define DEBUG_DVC(...) do { } while (0)
#endif

#endif /* FREERDP_AUDIN_CLIENT_MAIN_H */
#endif /* FREERDP_CHANNEL_AUDIN_CLIENT_MAIN_H */

2 changes: 1 addition & 1 deletion channels/audin/client/opensles/opensl_io.c
Original file line number Diff line number Diff line change
@@ -253,7 +253,7 @@ OPENSL_STREAM* android_OpenRecDevice(char* name, int sr, int inchannels,
int bufferframes, int bits_per_sample)
{
OPENSL_STREAM* p;
p = (OPENSL_STREAM*) calloc(sizeof(OPENSL_STREAM), 1);
p = (OPENSL_STREAM*) calloc(1, sizeof(OPENSL_STREAM));

if (!p)
return NULL;
6 changes: 3 additions & 3 deletions channels/audin/client/opensles/opensl_io.h
Original file line number Diff line number Diff line change
@@ -27,8 +27,8 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef OPENSL_IO
#define OPENSL_IO
#ifndef FREERDP_CHANNEL_AUDIN_CLIENT_OPENSL_IO_H
#define FREERDP_CHANNEL_AUDIN_CLIENT_OPENSL_IO_H

#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
@@ -93,4 +93,4 @@ FREERDP_LOCAL int android_RecIn(OPENSL_STREAM* p, short* buffer, int size);
};
#endif

#endif // #ifndef OPENSL_IO
#endif /* FREERDP_CHANNEL_AUDIN_CLIENT_OPENSL_IO_H */
2 changes: 1 addition & 1 deletion channels/audin/client/pulse/audin_pulse.c
Original file line number Diff line number Diff line change
@@ -496,7 +496,7 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u

pa_threaded_mainloop_unlock(pulse->mainloop);
freerdp_dsp_context_reset_adpcm(pulse->dsp_context);
pulse->buffer = calloc(1, pulse->bytes_per_frame * pulse->frames_per_packet);
pulse->buffer = calloc(pulse->frames_per_packet, pulse->bytes_per_frame);

if (!pulse->buffer)
{
4 changes: 2 additions & 2 deletions channels/client/addin.c
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPSTR pszName, LPSTR
FREERDP_ADDIN** ppAddins = NULL;
STATIC_SUBSYSTEM_ENTRY* subsystems;
nAddins = 0;
ppAddins = (FREERDP_ADDIN**) calloc(1, sizeof(FREERDP_ADDIN*) * 128);
ppAddins = (FREERDP_ADDIN**) calloc(128, sizeof(FREERDP_ADDIN*));

if (!ppAddins)
{
@@ -216,7 +216,7 @@ FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPSTR pszName, LPSTR pszSub
hFind = FindFirstFileA(pszSearchPath, &FindData);
free(pszSearchPath);
nAddins = 0;
ppAddins = (FREERDP_ADDIN**) calloc(1, sizeof(FREERDP_ADDIN*) * 128);
ppAddins = (FREERDP_ADDIN**) calloc(128, sizeof(FREERDP_ADDIN*));

if (!ppAddins)
{
6 changes: 3 additions & 3 deletions channels/cliprdr/client/cliprdr_format.h
Original file line number Diff line number Diff line change
@@ -20,12 +20,12 @@
* limitations under the License.
*/

#ifndef __CLIPRDR_FORMAT_H
#define __CLIPRDR_FORMAT_H
#ifndef FREERDP_CHANNEL_CLIPRDR_CLIENT_FORMAT_H
#define FREERDP_CHANNEL_CLIPRDR_CLIENT_FORMAT_H

UINT cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags);
UINT cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags);
UINT cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags);
UINT cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags);

#endif /* __CLIPRDR_FORMAT_H */
#endif /* FREERDP_CHANNEL_CLIPRDR_CLIENT_FORMAT_H */
6 changes: 3 additions & 3 deletions channels/cliprdr/client/cliprdr_main.h
Original file line number Diff line number Diff line change
@@ -19,8 +19,8 @@
* limitations under the License.
*/

#ifndef __CLIPRDR_MAIN_H
#define __CLIPRDR_MAIN_H
#ifndef FREERDP_CHANNEL_CLIPRDR_CLIENT_MAIN_H
#define FREERDP_CHANNEL_CLIPRDR_CLIENT_MAIN_H

#include <winpr/stream.h>

@@ -60,4 +60,4 @@ CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr);
#define DEBUG_CLIPRDR(...) do { } while (0)
#endif

#endif /* __CLIPRDR_MAIN_H */
#endif /* FREERDP_CHANNEL_CLIPRDR_CLIENT_MAIN_H */
6 changes: 3 additions & 3 deletions channels/cliprdr/server/cliprdr_main.h
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
* limitations under the License.
*/

#ifndef FREERDP_CHANNEL_SERVER_CLIPRDR_MAIN_H
#define FREERDP_CHANNEL_SERVER_CLIPRDR_MAIN_H
#ifndef FREERDP_CHANNEL_CLIPRDR_SERVER_MAIN_H
#define FREERDP_CHANNEL_CLIPRDR_SERVER_MAIN_H

#include <winpr/crt.h>
#include <winpr/synch.h>
@@ -45,4 +45,4 @@ struct _cliprdr_server_private
};
typedef struct _cliprdr_server_private CliprdrServerPrivate;

#endif /* FREERDP_CHANNEL_SERVER_CLIPRDR_MAIN_H */
#endif /* FREERDP_CHANNEL_CLIPRDR_SERVER_MAIN_H */
6 changes: 3 additions & 3 deletions channels/drdynvc/client/drdynvc_main.h
Original file line number Diff line number Diff line change
@@ -19,8 +19,8 @@
* limitations under the License.
*/

#ifndef __DRDYNVC_MAIN_H
#define __DRDYNVC_MAIN_H
#ifndef FREERDP_CHANNEL_DRDYNVC_CLIENT_MAIN_H
#define FREERDP_CHANNEL_DRDYNVC_CLIENT_MAIN_H

#include <winpr/wlog.h>
#include <winpr/synch.h>
@@ -137,4 +137,4 @@ struct drdynvc_plugin
IWTSVirtualChannelManager* channel_mgr;
};

#endif
#endif /* FREERDP_CHANNEL_DRDYNVC_CLIENT_MAIN_H */
6 changes: 3 additions & 3 deletions channels/drdynvc/server/drdynvc_main.h
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
* limitations under the License.
*/

#ifndef FREERDP_CHANNEL_SERVER_DRDYNVC_MAIN_H
#define FREERDP_CHANNEL_SERVER_DRDYNVC_MAIN_H
#ifndef FREERDP_CHANNEL_DRDYNVC_SERVER_MAIN_H
#define FREERDP_CHANNEL_DRDYNVC_SERVER_MAIN_H

#include <winpr/crt.h>
#include <winpr/synch.h>
@@ -34,4 +34,4 @@ struct _drdynvc_server_private
void* ChannelHandle;
};

#endif /* FREERDP_CHANNEL_SERVER_DRDYNVC_MAIN_H */
#endif /* FREERDP_CHANNEL_DRDYNVC_SERVER_MAIN_H */
6 changes: 3 additions & 3 deletions channels/drive/client/drive_file.h
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@
* limitations under the License.
*/

#ifndef FREERDP_CHANNEL_DRIVE_FILE_H
#define FREERDP_CHANNEL_DRIVE_FILE_H
#ifndef FREERDP_CHANNEL_DRIVE_CLIENT_FILE_H
#define FREERDP_CHANNEL_DRIVE_CLIENT_FILE_H

#include <winpr/stream.h>
#include <freerdp/channels/log.h>
@@ -68,4 +68,4 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT

extern UINT sys_code_page;

#endif /* FREERDP_CHANNEL_DRIVE_FILE_H */
#endif /* FREERDP_CHANNEL_DRIVE_CLIENT_FILE_H */
22 changes: 15 additions & 7 deletions channels/drive/client/drive_main.c
Original file line number Diff line number Diff line change
@@ -735,6 +735,19 @@ static UINT drive_irp_request(DEVICE* device, IRP* irp)
return CHANNEL_RC_OK;
}

static void drive_free_resources(DRIVE_DEVICE* drive)
{
if (!drive)
return;

CloseHandle(drive->thread);
ListDictionary_Free(drive->files);
MessageQueue_Free(drive->IrpQueue);
Stream_Free(drive->device.data, TRUE);
free(drive->path);
free(drive);
}

/**
* Function description
*
@@ -753,12 +766,7 @@ static UINT drive_free(DEVICE* device)
return error;
}

CloseHandle(drive->thread);
ListDictionary_Free(drive->files);
MessageQueue_Free(drive->IrpQueue);
Stream_Free(drive->device.data, TRUE);
free(drive->path);
free(drive);
drive_free_resources(drive);
return error;
}

@@ -866,7 +874,7 @@ UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,

return CHANNEL_RC_OK;
out_error:
drive_free((DEVICE*) drive);
drive_free_resources(drive);
return error;
}

6 changes: 3 additions & 3 deletions channels/echo/client/echo_main.h
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
* limitations under the License.
*/

#ifndef __ECHO_MAIN_H
#define __ECHO_MAIN_H
#ifndef FREERDP_CHANNEL_ECHO_CLIENT_MAIN_H
#define FREERDP_CHANNEL_ECHO_CLIENT_MAIN_H

#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -36,5 +36,5 @@
#define DEBUG_DVC(...) do { } while (0)
#endif

#endif /* __ECHO_MAIN_H */
#endif /* FREERDP_CHANNEL_ECHO_CLIENT_MAIN_H */

6 changes: 3 additions & 3 deletions channels/encomsp/server/encomsp_main.h
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
* limitations under the License.
*/

#ifndef FREERDP_CHANNEL_SERVER_ENCOMSP_MAIN_H
#define FREERDP_CHANNEL_SERVER_ENCOMSP_MAIN_H
#ifndef FREERDP_CHANNEL_ENCOMSP_SERVER_MAIN_H
#define FREERDP_CHANNEL_ENCOMSP_SERVER_MAIN_H

#include <winpr/crt.h>
#include <winpr/synch.h>
@@ -33,4 +33,4 @@ struct _encomsp_server_private
void* ChannelHandle;
};

#endif /* FREERDP_CHANNEL_SERVER_ENCOMSP_MAIN_H */
#endif /* FREERDP_CHANNEL_ENCOMSP_SERVER_MAIN_H */
2 changes: 1 addition & 1 deletion channels/printer/client/printer_cups.c
Original file line number Diff line number Diff line change
@@ -281,7 +281,7 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver)
int i;

num_dests = cupsGetDests(&dests);
printers = (rdpPrinter**) calloc(1, sizeof(rdpPrinter*) * (num_dests + 1));
printers = (rdpPrinter**) calloc(num_dests + 1, sizeof(rdpPrinter*));
if (!printers)
return NULL;

6 changes: 3 additions & 3 deletions channels/printer/client/printer_cups.h
Original file line number Diff line number Diff line change
@@ -17,12 +17,12 @@
* limitations under the License.
*/

#ifndef __PRINTER_CUPS_H
#define __PRINTER_CUPS_H
#ifndef FREERDP_CHANNEL_PRINTER_CLIENT_CUPS_H
#define FREERDP_CHANNEL_PRINTER_CLIENT_CUPS_H

#include "printer_main.h"

rdpPrinterDriver* printer_cups_get_driver(void);

#endif
#endif /* FREERDP_CHANNEL_PRINTER_CLIENT_CUPS_H */

6 changes: 3 additions & 3 deletions channels/printer/client/printer_main.h
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@
* limitations under the License.
*/

#ifndef __PRINTER_MAIN_H
#define __PRINTER_MAIN_H
#ifndef FREERDP_CHANNEL_PRINTER_CLIENT_MAIN_H
#define FREERDP_CHANNEL_PRINTER_CLIENT_MAIN_H

#include <freerdp/channels/rdpdr.h>

@@ -66,4 +66,4 @@ struct rdp_print_job
pcClosePrintJob Close;
};

#endif
#endif /* FREERDP_CHANNEL_PRINTER_CLIENT_MAIN_H */
6 changes: 3 additions & 3 deletions channels/printer/client/printer_win.h
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
* limitations under the License.
*/

#ifndef __PRINTER_WIN_H
#define __PRINTER_WIN_H
#ifndef FREERDP_CHANNEL_PRINTER_CLIENT_WIN_H
#define FREERDP_CHANNEL_PRINTER_CLIENT_WIN_H

#include <freerdp/channels/log.h>

@@ -31,5 +31,5 @@ rdpPrinterDriver* printer_win_get_driver(void);
#define DEBUG_WINPR(...) do { } while (0)
#endif

#endif
#endif /* FREERDP_CHANNEL_PRINTER_CLIENT_WIN_H */

6 changes: 3 additions & 3 deletions channels/printer/printer.h
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
* limitations under the License.
*/

#ifndef __CHANNELS_PRINTER_PRINTER_H_
#define __CHANNELS_PRINTER_PRINTER_H_
#ifndef FREERDP_CHANNEL_PRINTER_PRINTER_H
#define FREERDP_CHANNEL_PRINTER_PRINTER_H

/* SERVER_PRINTER_CACHE_EVENT.cachedata */
#define RDPDR_ADD_PRINTER_EVENT 0x00000001
@@ -34,4 +34,4 @@
#define RDPDR_PRINTER_ANNOUNCE_FLAG_XPSFORMAT 0x00000010


#endif /* __CHANNELS_PRINTER_PRINTER_H_ */
#endif /* FREERDP_CHANNEL_PRINTER_PRINTER_H */
6 changes: 3 additions & 3 deletions channels/rail/client/rail_main.h
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@
* limitations under the License.
*/

#ifndef FREERDP_CHANNEL_CLIENT_RAIL_MAIN_H
#define FREERDP_CHANNEL_CLIENT_RAIL_MAIN_H
#ifndef FREERDP_CHANNEL_RAIL_CLIENT_MAIN_H
#define FREERDP_CHANNEL_RAIL_CLIENT_MAIN_H

#include <freerdp/rail.h>
#include <freerdp/svc.h>
@@ -56,4 +56,4 @@ typedef struct rail_plugin railPlugin;
RailClientContext* rail_get_client_interface(railPlugin* rail);
UINT rail_send_channel_data(railPlugin* rail, void* data, size_t length);

#endif /* FREERDP_CHANNEL_CLIENT_RAIL_MAIN_H */
#endif /* FREERDP_CHANNEL_RAIL_CLIENT_MAIN_H */
Loading
Oops, something went wrong.

0 comments on commit 1648deb

Please sign in to comment.