Skip to content

Commit

Permalink
Merge pull request neutrinolabs#3410 from matt335672/coverity_scan
Browse files Browse the repository at this point in the history
Fix more coverity warnings
  • Loading branch information
matt335672 authored Jan 27, 2025
2 parents 64cfeb3 + 8196314 commit 7eb96dd
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 29 deletions.
4 changes: 2 additions & 2 deletions common/string_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ utf8_get_next_char(const char **utf8str_ref, unsigned int *len_ref)
/*
* Macro used to parse a continuation character
* @param cp Character Pointer (incremented on success)
* @param end One character past end of input string
* @param end One character past end of input string, or NULL
* @param value The value we're constructing
* @param finish_label Where to go in the event of an error */
#define PARSE_CONTINUATION_CHARACTER(cp, end, value, finish_label) \
Expand All @@ -1210,7 +1210,7 @@ utf8_get_next_char(const char **utf8str_ref, unsigned int *len_ref)

/* Easier to work with unsigned chars and no indirection */
const unsigned char *cp = (const unsigned char *)*utf8str_ref;
const unsigned char *end = (len_ref != NULL) ? cp + *len_ref : cp + 6;
const unsigned char *end = (len_ref != NULL) ? cp + *len_ref : NULL;

if (cp == end)
{
Expand Down
8 changes: 6 additions & 2 deletions neutrinordp/xrdp-neutrinordp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1790,14 +1790,18 @@ lfreerdp_synchronize(rdpContext *context)
static boolean
lfreerdp_pre_connect(freerdp *instance)
{
#define MAX_FREERDP_CHANNELS \
(sizeof(instance->settings->channels) / \
sizeof(instance->settings->channels[0]))

struct mod *mod;
int index;
int error;
int num_chans;
int target_chan;
int ch_flags;
char ch_name[256];
const char *ch_names[MAX_STATIC_CHANNELS];
const char *ch_names[MAX_FREERDP_CHANNELS];
char *dst_ch_name;

LOG_DEVEL(LOG_LEVEL_INFO, "lfreerdp_pre_connect:");
Expand Down Expand Up @@ -1828,7 +1832,7 @@ lfreerdp_pre_connect(freerdp *instance)
LOG(LOG_LEVEL_INFO, "Channel '%s' not passed to module",
ch_name);
}
else if (target_chan < MAX_STATIC_CHANNELS)
else if (target_chan < MAX_FREERDP_CHANNELS)
{
dst_ch_name = instance->settings->channels[target_chan].name;
ch_names[target_chan] = dst_ch_name;
Expand Down
2 changes: 1 addition & 1 deletion neutrinordp/xrdp-neutrinordp.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct mod
struct bitmap_item bitmap_cache[4][4096];
struct brush_item brush_cache[64];
struct pointer_item pointer_cache[32];
char pamusername[255];
char pamusername[256];

int allow_client_experiencesettings;
int perf_settings_override_mask; /* Performance bits overridden in ini file */
Expand Down
51 changes: 28 additions & 23 deletions sesman/chansrv/smartcard_pcsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ scard_function_list_readers_return(void *user_data,
struct trans *con;
struct pcsc_list_readers *pcscListReaders;
char *msz_readers = NULL;
int rv;

LOG_DEVEL(LOG_LEVEL_DEBUG, "scard_function_list_readers_return:");
LOG_DEVEL(LOG_LEVEL_DEBUG, " status 0x%8.8x", status);
Expand Down Expand Up @@ -788,37 +789,41 @@ scard_function_list_readers_return(void *user_data,
out_s = trans_get_out_s(con, 8192);
if (out_s == NULL)
{
return 1;
rv = 1;
}
s_push_layer(out_s, iso_hdr, 8);
out_uint32_le(out_s, llen);
out_uint32_le(out_s, readers);
else
{
const char *p = msz_readers;
for (index = 0; index < readers; index++)
s_push_layer(out_s, iso_hdr, 8);
out_uint32_le(out_s, llen);
out_uint32_le(out_s, readers);
{
unsigned int slen = strlen(p);
if (slen < 100)
{
out_uint8a(out_s, p, slen);
out_uint8s(out_s, 100 - slen);
}
else
const char *p = msz_readers;
for (index = 0; index < readers; index++)
{
out_uint8a(out_s, p, 99);
out_uint8s(out_s, 1);
unsigned int slen = strlen(p);
if (slen < 100)
{
out_uint8a(out_s, p, slen);
out_uint8s(out_s, 100 - slen);
}
else
{
out_uint8a(out_s, p, 99);
out_uint8s(out_s, 1);
}
p += (slen + 1);
}
p += (slen + 1);
}
out_uint32_le(out_s, status); /* SCARD_S_SUCCESS status */
s_mark_end(out_s);
bytes = (int) (out_s->end - out_s->data);
s_pop_layer(out_s, iso_hdr);
out_uint32_le(out_s, bytes - 8);
out_uint32_le(out_s, 0x03); /* SCARD_LIST_READERS 0x03 */
rv = trans_force_write(con);
}
free(msz_readers);
out_uint32_le(out_s, status); /* SCARD_S_SUCCESS status */
s_mark_end(out_s);
bytes = (int) (out_s->end - out_s->data);
s_pop_layer(out_s, iso_hdr);
out_uint32_le(out_s, bytes - 8);
out_uint32_le(out_s, 0x03); /* SCARD_LIST_READERS 0x03 */
return trans_force_write(con);
return rv;
}

/*****************************************************************************/
Expand Down
3 changes: 2 additions & 1 deletion xrdp/xrdp_wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ xrdp_wm_clear_popup(struct xrdp_wm *self)
//struct xrdp_bitmap* b;

//b = 0;
if (self->popup_wnd != 0)
if (self->popup_wnd != NULL)
{
//b = self->popup_wnd->popped_from;
i = list_index_of(self->screen->child_list, (long)self->popup_wnd);
Expand All @@ -1282,6 +1282,7 @@ xrdp_wm_clear_popup(struct xrdp_wm *self)
self->popup_wnd->width, self->popup_wnd->height);
xrdp_bitmap_invalidate(self->screen, &rect);
xrdp_bitmap_delete(self->popup_wnd);
self->popup_wnd = NULL;
}

//xrdp_wm_set_focused(self, b->parent);
Expand Down

0 comments on commit 7eb96dd

Please sign in to comment.