[warnings] integer casts/checks
This commit is contained in:
parent
d6949721c6
commit
4099bd4e45
@ -231,7 +231,7 @@ static UINT parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
{
|
||||
status = write(parallel->file, ptr, len);
|
||||
|
||||
if (status < 0)
|
||||
if ((status < 0) || (status > len))
|
||||
{
|
||||
irp->IoStatus = STATUS_UNSUCCESSFUL;
|
||||
Length = 0;
|
||||
|
@ -874,6 +874,11 @@ static UINT rdpgfx_send_cache_offer(RDPGFX_PLUGIN* gfx)
|
||||
}
|
||||
|
||||
count = persistent_cache_get_count(persistent);
|
||||
if (count < 0)
|
||||
{
|
||||
error = ERROR_INVALID_DATA;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (count >= RDPGFX_CACHE_ENTRY_MAX_COUNT)
|
||||
count = RDPGFX_CACHE_ENTRY_MAX_COUNT - 1;
|
||||
|
@ -527,7 +527,7 @@ namespace webview
|
||||
int n = json_unescape(value, value_sz, nullptr);
|
||||
if (n > 0)
|
||||
{
|
||||
char* decoded = new char[n + 1];
|
||||
char* decoded = new char[1ull + n];
|
||||
json_unescape(value, value_sz, decoded);
|
||||
std::string result(decoded, n);
|
||||
delete[] decoded;
|
||||
|
@ -230,7 +230,7 @@ void* UwacClipboardDataGet(UwacSeat* seat, const char* mime, size_t* size)
|
||||
size_t alloc = 0;
|
||||
size_t pos = 0;
|
||||
char* data = NULL;
|
||||
int pipefd[2];
|
||||
int pipefd[2] = { 0 };
|
||||
|
||||
if (!seat || !mime || !size || !seat->offer)
|
||||
return NULL;
|
||||
@ -250,26 +250,21 @@ void* UwacClipboardDataGet(UwacSeat* seat, const char* mime, size_t* size)
|
||||
alloc += 1024;
|
||||
tmp = xrealloc(data, alloc);
|
||||
if (!tmp)
|
||||
{
|
||||
free(data);
|
||||
close(pipefd[0]);
|
||||
return NULL;
|
||||
}
|
||||
goto fail;
|
||||
|
||||
data = tmp;
|
||||
|
||||
if (pos > alloc)
|
||||
goto fail;
|
||||
|
||||
r = read(pipefd[0], &data[pos], alloc - pos);
|
||||
if (r > 0)
|
||||
pos += r;
|
||||
if (r < 0)
|
||||
{
|
||||
free(data);
|
||||
close(pipefd[0]);
|
||||
return NULL;
|
||||
}
|
||||
goto fail;
|
||||
} while (r > 0);
|
||||
|
||||
close(pipefd[0]);
|
||||
close(pipefd[1]);
|
||||
|
||||
if (alloc > 0)
|
||||
{
|
||||
@ -277,4 +272,9 @@ void* UwacClipboardDataGet(UwacSeat* seat, const char* mime, size_t* size)
|
||||
*size = pos + 1;
|
||||
}
|
||||
return data;
|
||||
|
||||
fail:
|
||||
free(data);
|
||||
close(pipefd[0]);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ static void UwacWindowDestroyBuffers(UwacWindow* w)
|
||||
w->buffers = NULL;
|
||||
}
|
||||
|
||||
static int UwacWindowShmAllocBuffers(UwacWindow* w, int nbuffers, int allocSize, uint32_t width,
|
||||
uint32_t height, enum wl_shm_format format);
|
||||
static int UwacWindowShmAllocBuffers(UwacWindow* w, int64_t nbuffers, int64_t allocSize,
|
||||
uint32_t width, uint32_t height, enum wl_shm_format format);
|
||||
|
||||
static void xdg_handle_toplevel_configure(void* data, struct xdg_toplevel* xdg_toplevel,
|
||||
int32_t width, int32_t height, struct wl_array* states)
|
||||
@ -316,22 +316,28 @@ static void shell_popup_done(void* data, struct wl_shell_surface* surface)
|
||||
static const struct wl_shell_surface_listener shell_listener = { shell_ping, shell_configure,
|
||||
shell_popup_done };
|
||||
|
||||
int UwacWindowShmAllocBuffers(UwacWindow* w, int nbuffers, int allocSize, uint32_t width,
|
||||
int UwacWindowShmAllocBuffers(UwacWindow* w, int64_t nbuffers, int64_t allocSize, uint32_t width,
|
||||
uint32_t height, enum wl_shm_format format)
|
||||
{
|
||||
int ret = UWAC_SUCCESS;
|
||||
UwacBuffer* newBuffers = NULL;
|
||||
int fd = 0;
|
||||
void* data = NULL;
|
||||
struct wl_shm_pool* pool = NULL;
|
||||
size_t pagesize = sysconf(_SC_PAGESIZE);
|
||||
newBuffers = xrealloc(w->buffers, (w->nbuffers + nbuffers) * sizeof(UwacBuffer));
|
||||
|
||||
if (!newBuffers)
|
||||
int64_t pagesize = sysconf(_SC_PAGESIZE);
|
||||
if (pagesize <= 0)
|
||||
return UWAC_ERROR_NOMEMORY;
|
||||
|
||||
/* round up to a multiple of PAGESIZE to page align data for each buffer */
|
||||
allocSize = (allocSize + pagesize - 1) & ~(pagesize - 1);
|
||||
UINT64 test = (0ull + allocSize + pagesize - 1ull) & ~(pagesize - 1);
|
||||
if (test > INT64_MAX)
|
||||
return UWAC_ERROR_NOMEMORY;
|
||||
|
||||
allocSize = (int64_t)test;
|
||||
|
||||
UwacBuffer* newBuffers = xrealloc(w->buffers, (w->nbuffers + nbuffers) * sizeof(UwacBuffer));
|
||||
|
||||
if (!newBuffers)
|
||||
return UWAC_ERROR_NOMEMORY;
|
||||
|
||||
w->buffers = newBuffers;
|
||||
memset(w->buffers + w->nbuffers, 0, sizeof(UwacBuffer) * nbuffers);
|
||||
|
@ -117,7 +117,8 @@ static void StreamPool_ShiftUsed(wStreamPool* pool, size_t index, INT64 count)
|
||||
else if (count < 0)
|
||||
{
|
||||
const size_t pcount = (size_t)-count;
|
||||
if ((pool->uSize - index - pcount) > 0)
|
||||
const size_t off = index + pcount;
|
||||
if (pool->uSize > off)
|
||||
{
|
||||
MoveMemory(&pool->uArray[index], &pool->uArray[index + pcount],
|
||||
(pool->uSize - index - pcount) * sizeof(wStream*));
|
||||
@ -169,8 +170,8 @@ static void StreamPool_ShiftAvailable(wStreamPool* pool, size_t index, INT64 cou
|
||||
else if (count < 0)
|
||||
{
|
||||
const size_t pcount = (size_t)-count;
|
||||
|
||||
if ((pool->aSize - index - pcount) > 0)
|
||||
const size_t off = index + pcount;
|
||||
if (pool->aSize > off)
|
||||
{
|
||||
MoveMemory(&pool->aArray[index], &pool->aArray[index + pcount],
|
||||
(pool->aSize - index - pcount) * sizeof(wStream*));
|
||||
|
Loading…
Reference in New Issue
Block a user