code stringlengths 14 2.05k | label int64 0 1 | programming_language stringclasses 7
values | cwe_id stringlengths 6 14 | cwe_name stringlengths 5 98 ⌀ | description stringlengths 36 379 ⌀ | url stringlengths 36 48 ⌀ | label_name stringclasses 2
values |
|---|---|---|---|---|---|---|---|
simple_upscale(j_decompress_ptr cinfo,
JDIFFROW diff_buf, _JSAMPROW output_buf, JDIMENSION width)
{
do {
#if BITS_IN_JSAMPLE == 12
/* 12-bit is the only data precision for which the range of the sample data
* type exceeds the valid sample range. Thus, we need to range-limit the
* samples... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
noscale(j_decompress_ptr cinfo,
JDIFFROW diff_buf, _JSAMPROW output_buf, JDIMENSION width)
{
do {
#if BITS_IN_JSAMPLE == 12
*output_buf++ = (_JSAMPLE)((*diff_buf++) & 0xFFF);
#else
*output_buf++ = (_JSAMPLE)(*diff_buf++);
#endif
} while (--width);
} | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
print_perm_line (int idx,
GPtrArray *items,
int cols)
{
g_autoptr(GString) res = g_string_new (NULL);
g_autofree char *escaped_first_perm = NULL;
int i;
escaped_first_perm = flatpak_escape_string (items->pdata[0], FLATPAK_ESCAPE_DEFAULT);
g_string_append_printf... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
load_kernel_module_list (void)
{
GHashTable *modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
g_autofree char *modules_data = NULL;
g_autoptr(GError) error = NULL;
char *start, *end;
if (!g_file_get_contents ("/proc/modules", &modules_data, NULL, &error))
{
g_info ("Failed t... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
append_hex_escaped_character (GString *result,
gunichar c)
{
if (c <= 0xFF)
g_string_append_printf (result, "\\x%02X", c);
else if (c <= 0xFFFF)
g_string_append_printf (result, "\\u%04X", c);
else
g_string_append_printf (result, "\\U%08X", c);
} | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
flatpak_print_escaped_string (const char *s,
FlatpakEscapeFlags flags)
{
g_autofree char *escaped = flatpak_escape_string (s, flags);
g_print ("%s", escaped);
} | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
is_char_safe (gunichar c)
{
return g_unichar_isgraph (c) || c == ' ';
} | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
should_hex_escape (gunichar c,
FlatpakEscapeFlags flags)
{
if ((flags & FLATPAK_ESCAPE_ALLOW_NEWLINES) && c == '\n')
return FALSE;
return !is_char_safe (c);
} | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
flatpak_escape_string (const char *s,
FlatpakEscapeFlags flags)
{
g_autoptr(GString) res = g_string_new ("");
gboolean did_escape = FALSE;
while (*s)
{
gunichar c = g_utf8_get_char_validated (s, -1);
if (c == (gunichar)-2 || c == (gunichar)-1)
{
/* ... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
test_string_escape (void)
{
gsize idx;
for (idx = 0; idx < G_N_ELEMENTS (escapes); idx++)
{
EscapeData *data = &escapes[idx];
g_autofree char *ret = NULL;
ret = flatpak_escape_string (data->in, data->flags);
g_assert_cmpstr (ret, ==, data->out);
}
} | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
option_persist_cb (const gchar *option_name,
const gchar *value,
gpointer data,
GError **error)
{
FlatpakContext *context = data;
return flatpak_context_set_persistent (context, value, error);
} | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
flatpak_context_set_persistent (FlatpakContext *context,
const char *path,
GError **error)
{
if (!flatpak_validate_path_characters (path, error))
return FALSE;
g_hash_table_insert (context->persistent, g_strdup (path), GINT_TO_POINTER (... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
flatpak_validate_path_characters (const char *path,
GError **error)
{
while (*path)
{
gunichar c = g_utf8_get_char_validated (path, -1);
if (c == (gunichar)-1 || c == (gunichar)-2)
{
/* Need to convert to unsigned first, to avoid negative chars be... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
escape_character (gunichar c)
{
g_autoptr(GString) res = g_string_new ("");
append_hex_escaped_character (res, c);
return g_string_free (g_steal_pointer (&res), FALSE);
} | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/context/env", test_context_env);
g_test_add_func ("/context/env-fd", test_context_env_fd);
g_test_add_func ("/context/merge-fs", test_context_merge_fs);
g_test_add_func ("/context/validate-path-args", test_validate_path_args... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
test_validate_path_meta (void)
{
gsize idx;
for (idx = 0; idx < G_N_ELEMENTS (invalid_path_meta); idx++)
{
g_autoptr(FlatpakContext) context = flatpak_context_new ();
g_autoptr(GKeyFile) metakey = g_key_file_new ();
g_autoptr(GError) local_error = NULL;
PathValidityData *data = &invalid... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
test_validate_path_args (void)
{
gsize idx;
for (idx = 0; idx < G_N_ELEMENTS (invalid_path_args); idx++)
{
g_autoptr(FlatpakContext) context = flatpak_context_new ();
g_autoptr(GError) local_error = NULL;
const char *path = invalid_path_args[idx];
context_parse_args (context, &local_er... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
context_parse_args (FlatpakContext *context,
GError **error,
...)
{
g_autoptr(GOptionContext) oc = NULL;
g_autoptr(GOptionGroup) group = NULL;
g_autoptr(GPtrArray) args = g_ptr_array_new_with_free_func (g_free);
g_auto(GStrv) argv = NULL;
const char *arg;
va_li... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
test_validate_path_characters (void)
{
gsize idx;
for (idx = 0; idx < G_N_ELEMENTS (paths); idx++)
{
PathValidityData *data = &paths[idx];
gboolean ret = FALSE;
ret = flatpak_validate_path_characters (data->path, NULL);
g_assert_cmpint (ret, ==, data->ret);
}
} | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
int packet__queue(struct mosquitto *mosq, struct mosquitto__packet *packet)
{
#ifndef WITH_BROKER
char sockpair_data = 0;
#endif
assert(mosq);
assert(packet);
packet->pos = 0;
packet->to_process = packet->packet_length;
packet->next = NULL;
pthread_mutex_lock(&mosq->out_packet_mutex);
#ifdef WITH_BROKER
if(m... | 1 | C | CWE-401 | Missing Release of Memory after Effective Lifetime | The product does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | https://cwe.mitre.org/data/definitions/401.html | safe |
struct mosquitto *context__init(mosq_sock_t sock)
{
struct mosquitto *context;
char address[1024];
context = mosquitto__calloc(1, sizeof(struct mosquitto));
if(!context) return NULL;
#ifdef WITH_EPOLL
context->ident = id_client;
#else
context->pollfd_index = -1;
#endif
mosquitto__set_state(context, mosq_cs_new... | 1 | C | CWE-401 | Missing Release of Memory after Effective Lifetime | The product does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | https://cwe.mitre.org/data/definitions/401.html | safe |
static void context__cleanup_out_packets(struct mosquitto *context)
{
struct mosquitto__packet *packet;
if(!context) return;
if(context->current_out_packet){
packet__cleanup(context->current_out_packet);
mosquitto__free(context->current_out_packet);
context->current_out_packet = NULL;
}
while(context->out_... | 1 | C | CWE-401 | Missing Release of Memory after Effective Lifetime | The product does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | https://cwe.mitre.org/data/definitions/401.html | safe |
void context__cleanup(struct mosquitto *context, bool force_free)
{
if(!context) return;
if(force_free){
context->clean_start = true;
}
#ifdef WITH_BRIDGE
if(context->bridge){
bridge__cleanup(context);
}
#endif
alias__free_all(context);
context__cleanup_out_packets(context);
mosquitto__free(context->aut... | 1 | C | CWE-401 | Missing Release of Memory after Effective Lifetime | The product does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | https://cwe.mitre.org/data/definitions/401.html | safe |
int db__message_store_find(struct mosquitto *context, uint16_t mid, struct mosquitto_client_msg **client_msg)
{
struct mosquitto_client_msg *cmsg;
*client_msg = NULL;
if(!context) return MOSQ_ERR_INVAL;
DL_FOREACH(context->msgs_in.inflight, cmsg){
if(cmsg->store->source_mid == mid){
*client_msg = cmsg;
r... | 1 | C | CWE-401 | Missing Release of Memory after Effective Lifetime | The product does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | https://cwe.mitre.org/data/definitions/401.html | safe |
static int db__message_reconnect_reset_incoming(struct mosquitto *context)
{
struct mosquitto_client_msg *msg, *tmp;
context->msgs_in.inflight_bytes = 0;
context->msgs_in.inflight_bytes12 = 0;
context->msgs_in.inflight_count = 0;
context->msgs_in.inflight_count12 = 0;
context->msgs_in.queued_bytes = 0;
context-... | 1 | C | CWE-401 | Missing Release of Memory after Effective Lifetime | The product does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | https://cwe.mitre.org/data/definitions/401.html | safe |
escape(unsigned char ch, char *buf)
{
const int len = ch < 0100 ? (ch < 010 ? 3 : 4) : 5;
/* Work backwards from the least significant digit to most significant. */
switch (len) {
case 5:
buf[4] = (ch & 7) + '0';
ch >>= 3;
FALLTHROUGH;
case 4:
buf[3] = (ch & 7) + '0';
ch >>= 3;
FALLTHROUGH;
... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
escape(unsigned char ch, char *buf)
{
const int len = ch < 0100 ? (ch < 010 ? 3 : 4) : 5;
/* Work backwards from the least significant digit to most significant. */
switch (len) {
case 5:
buf[4] = (ch & 7) + '0';
ch >>= 3;
FALLTHROUGH;
case 4:
buf[3] = (ch & 7) + '0';
ch >>= 3;
FALLTHROUGH;
... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
sudo_lbuf_append_esc_v1(struct sudo_lbuf *lbuf, int flags, const char *fmt, ...)
{
unsigned int saved_len = lbuf->len;
bool ret = false;
const char *s;
va_list ap;
debug_decl(sudo_lbuf_append_esc, SUDO_DEBUG_UTIL);
if (sudo_lbuf_error(lbuf))
debug_return_bool(false);
#define should_escape(ch)... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
sudo_lbuf_append_esc_v1(struct sudo_lbuf *lbuf, int flags, const char *fmt, ...)
{
unsigned int saved_len = lbuf->len;
bool ret = false;
const char *s;
va_list ap;
debug_decl(sudo_lbuf_append_esc, SUDO_DEBUG_UTIL);
if (sudo_lbuf_error(lbuf))
debug_return_bool(false);
#define should_escape(ch)... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
expand_command(struct eventlog *evlog, char **newbuf)
{
size_t len, bufsize = strlen(evlog->command) + 1;
char *cp, *buf;
int ac;
debug_decl(expand_command, SUDO_DEBUG_UTIL);
if (evlog->argv == NULL || evlog->argv[0] == NULL || evlog->argv[1] == NULL) {
/* No arguments, we can use the command as-i... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
expand_command(struct eventlog *evlog, char **newbuf)
{
size_t len, bufsize = strlen(evlog->command) + 1;
char *cp, *buf;
int ac;
debug_decl(expand_command, SUDO_DEBUG_UTIL);
if (evlog->argv == NULL || evlog->argv[0] == NULL || evlog->argv[1] == NULL) {
/* No arguments, we can use the command as-i... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
match_expr(struct search_node_list *head, struct eventlog *evlog, bool last_match)
{
struct search_node *sn;
bool res = false, matched = last_match;
char *tofree;
int rc;
debug_decl(match_expr, SUDO_DEBUG_UTIL);
STAILQ_FOREACH(sn, head, entries) {
switch (sn->type) {
case ST_EXPR:
res = ... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
match_expr(struct search_node_list *head, struct eventlog *evlog, bool last_match)
{
struct search_node *sn;
bool res = false, matched = last_match;
char *tofree;
int rc;
debug_decl(match_expr, SUDO_DEBUG_UTIL);
STAILQ_FOREACH(sn, head, entries) {
switch (sn->type) {
case ST_EXPR:
res = ... | 1 | C | CWE-116 | Improper Encoding or Escaping of Output | The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. | https://cwe.mitre.org/data/definitions/116.html | safe |
sudo_passwd_verify(const struct sudoers_context *ctx, struct passwd *pw,
const char *pass, sudo_auth *auth, struct sudo_conv_callback *callback)
{
char des_pass[9], *epass;
char *pw_epasswd = auth->data;
size_t pw_len;
int ret;
debug_decl(sudo_passwd_verify, SUDOERS_DEBUG_AUTH);
/* An empty... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
sudo_auth_cleanup(const struct sudoers_context *ctx, struct passwd *pw,
bool force)
{
sudo_auth *auth;
debug_decl(sudo_auth_cleanup, SUDOERS_DEBUG_AUTH);
/* Call cleanup routines. */
for (auth = auth_switch; auth->name; auth++) {
if (auth->cleanup && !IS_DISABLED(auth)) {
int status = (auth->... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
sudo_auth_begin_session(const struct sudoers_context *ctx, struct passwd *pw,
char **user_env[])
{
sudo_auth *auth;
int ret = true;
debug_decl(sudo_auth_begin_session, SUDOERS_DEBUG_AUTH);
for (auth = auth_switch; auth->name; auth++) {
if (auth->begin_session && !IS_DISABLED(auth)) {
int stat... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
sudo_auth_end_session(void)
{
sudo_auth *auth;
int ret = true;
int status;
debug_decl(sudo_auth_end_session, SUDOERS_DEBUG_AUTH);
for (auth = auth_switch; auth->name; auth++) {
if (auth->end_session && !IS_DISABLED(auth)) {
status = (auth->end_session)(auth);
switch (status) {
case ... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
sudoers_lookup(struct sudo_nss_list *snl, struct sudoers_context *ctx,
time_t now, sudoers_lookup_callback_fn_t callback, void *cb_data,
int *cmnd_status, int pwflag)
{
struct defaults_list *defs = NULL;
struct sudoers_parse_tree *parse_tree = NULL;
struct cmndspec *cs = NULL;
struct sudo_nss *n... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
hostlist_matches_int(const struct sudoers_parse_tree *parse_tree,
const struct passwd *pw, const char *lhost, const char *shost,
const struct member_list *list)
{
struct member *m;
int matched = UNSPEC;
debug_decl(hostlist_matches, SUDOERS_DEBUG_MATCH);
TAILQ_FOREACH_REVERSE(m, list, member_lis... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
host_matches(const struct sudoers_parse_tree *parse_tree,
const struct passwd *pw, const char *lhost, const char *shost,
const struct member *m)
{
struct alias *a;
int matched = UNSPEC;
debug_decl(host_matches, SUDOERS_DEBUG_MATCH);
switch (m->type) {
case ALL:
matched = m->negated ? DENY... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
cmnd_matches(const struct sudoers_parse_tree *parse_tree,
const struct member *m, const char *runchroot, struct cmnd_info *info)
{
struct alias *a;
struct sudo_command *c;
int rc, matched = UNSPEC;
debug_decl(cmnd_matches, SUDOERS_DEBUG_MATCH);
switch (m->type) {
case ALL:
case COMMAND:
... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
cmndlist_matches(const struct sudoers_parse_tree *parse_tree,
const struct member_list *list, const char *runchroot,
struct cmnd_info *info)
{
struct member *m;
int matched = UNSPEC;
debug_decl(cmndlist_matches, SUDOERS_DEBUG_MATCH);
TAILQ_FOREACH_REVERSE(m, list, member_list, entries) {
match... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
user_matches(const struct sudoers_parse_tree *parse_tree,
const struct passwd *pw, const struct member *m)
{
const struct sudoers_context *ctx = parse_tree->ctx;
const char *lhost = parse_tree->lhost ? parse_tree->lhost : ctx->runas.host;
const char *shost = parse_tree->shost ? parse_tree->shost : ctx->... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
cmnd_matches_all(const struct sudoers_parse_tree *parse_tree,
const struct member *m, const char *runchroot, struct cmnd_info *info)
{
const bool negated = m->negated;
struct sudo_command *c;
int matched = UNSPEC;
struct alias *a;
debug_decl(cmnd_matches_all, SUDOERS_DEBUG_MATCH);
switch (m... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
runas_grouplist_matches(const struct sudoers_parse_tree *parse_tree,
const struct member_list *group_list, struct member **matching_group)
{
const struct sudoers_context *ctx = parse_tree->ctx;
int group_matched = UNSPEC;
struct member *m;
struct alias *a;
debug_decl(runas_grouplist_matches, SUD... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
userlist_matches(const struct sudoers_parse_tree *parse_tree,
const struct passwd *pw, const struct member_list *list)
{
struct member *m;
int matched = UNSPEC;
debug_decl(userlist_matches, SUDOERS_DEBUG_MATCH);
TAILQ_FOREACH_REVERSE(m, list, member_list, entries) {
matched = user_matches(parse_tr... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
static int parse_packet(const char *payload, struct ncrx_msg *msg)
{
char buf[1024];
char *p, *tok;
int idx;
memset(msg, 0, sizeof(*msg));
p = strchr(payload, ';');
if (!p || p - payload >= (signed)sizeof(buf))
goto einval;
memcpy(buf, payload, p - payload);
buf[p - payload] = '\0';
msg->text = p + 1;
ms... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
int valid_field (const char *field, const char *illegal)
{
const char *cp;
int err = 0;
if (NULL == field) {
return -1;
}
/* For each character of field, search if it appears in the list
* of illegal characters. */
for (cp = field; '\0' != *cp; cp++) {
if (strchr (illegal, *cp) != NULL) {
err = -1;
... | 1 | C | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
static u32 crc32sum(u32 crc, u8 * RESTRICT buf, size_t size) {
// Test endianness. The code needs to be different for LE and BE systems.
u32 test = 1;
if (*(u8 *) &test) {
while (size--) crc = crc32Table[(crc ^ *(buf++)) & 0xff] ^ (crc >> 8);
return crc;
} else {
while (size--) c... | 1 | C | CWE-125 | Out-of-bounds Read | The product reads data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/125.html | safe |
static int mrled(u8 * RESTRICT in, u8 * RESTRICT out, s32 outlen, s32 maxin) {
s32 op = 0, ip = 0;
s32 c, pc = -1;
s32 t[256] = { 0 };
s32 run = 0;
if(maxin < 32)
return 1;
for (s32 i = 0; i < 32; ++i) {
c = in[ip++];
for (s32 j = 0; j < 8; ++j) t[i * 8 + j] = (c >> j)... | 1 | C | CWE-125 | Out-of-bounds Read | The product reads data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/125.html | safe |
BZIP3_API struct bz3_state * bz3_new(s32 block_size) {
if (block_size < KiB(65) || block_size > MiB(511)) {
return NULL;
}
struct bz3_state * bz3_state = malloc(sizeof(struct bz3_state));
if (!bz3_state) {
return NULL;
}
bz3_state->cm_state = malloc(sizeof(state));
bz3_st... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
int dns_HTTPS_add_ipv4hint(struct dns_rr_nested *svcparam, unsigned char *addr[], int addr_num)
{
if (_dns_left_len(&svcparam->context) < 4 + addr_num * DNS_RR_A_LEN) {
return -1;
}
unsigned short value = DNS_HTTPS_T_IPV4HINT;
dns_add_rr_nested_memcpy(svcparam, &value, 2);
value = addr_num * DNS_RR_A_LEN;
dns... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
int dns_add_rr_nested_end(struct dns_rr_nested *rr_nested, dns_type_t rtype)
{
if (rr_nested == NULL || rr_nested->rr_start == NULL) {
return -1;
}
int len = rr_nested->context.ptr - rr_nested->rr_start;
unsigned char *ptr = rr_nested->rr_len_ptr;
if (ptr == NULL || _dns_left_len(&rr_nested->context) < 2) {
r... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
int dns_add_rr_nested_memcpy(struct dns_rr_nested *rr_nested, const void *data, int data_len)
{
if (rr_nested == NULL || data == NULL || data_len <= 0) {
return -1;
}
if (_dns_left_len(&rr_nested->context) < data_len) {
return -1;
}
memcpy(rr_nested->context.ptr, data, data_len);
rr_nested->context.ptr += d... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
int dns_get_HTTPS_svcparm_start(struct dns_rrs *rrs, struct dns_https_param **https_param, char *domain, int maxsize,
int *ttl, int *priority, char *target, int target_size)
{
int qtype = 0;
unsigned char *data = NULL;
int rr_len = 0;
data = dns_get_rr_nested_start(rrs, domain, maxsize, &qtype, ttl, &rr_le... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
int dns_HTTPS_add_ipv6hint(struct dns_rr_nested *svcparam, unsigned char *addr[], int addr_num)
{
if (_dns_left_len(&svcparam->context) < 4 + addr_num * DNS_RR_AAAA_LEN) {
return -1;
}
unsigned short value = DNS_HTTPS_T_IPV6HINT;
dns_add_rr_nested_memcpy(svcparam, &value, 2);
value = addr_num * DNS_RR_AAAA_LEN... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
static int _dns_encode_HTTPS(struct dns_context *context, struct dns_rrs *rrs)
{
int ret = 0;
int qtype = 0;
int qclass = 0;
char domain[DNS_MAX_CNAME_LEN];
char target[DNS_MAX_CNAME_LEN] = {0};
unsigned char *rr_len_ptr = NULL;
unsigned char *start = NULL;
unsigned char *rr_start = NULL;
int ttl = 0;
int pri... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
int dns_add_HTTPS_start(struct dns_rr_nested *svcparam_buffer, struct dns_packet *packet, dns_rr_type type,
const char *domain, int ttl, int priority, const char *target)
{
svcparam_buffer = dns_add_rr_nested_start(svcparam_buffer, packet, type, DNS_T_HTTPS, domain, ttl);
if (svcparam_buffer == NULL) {
return... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
static int _dns_encode_domain(struct dns_context *context, const char *domain)
{
int num = 0;
int total_len = 0;
unsigned char *ptr_num = context->ptr++;
int dict_offset = 0;
dict_offset = _dns_get_domain_offset(context, domain);
total_len++;
/*[len]string[len]string...[0]0 */
while (_dns_left_len(context) > ... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
int dns_HTTPS_add_alpn(struct dns_rr_nested *svcparam, const char *alpn, int alpn_len)
{
if (_dns_left_len(&svcparam->context) < 2 + 2 + alpn_len) {
return -1;
}
unsigned short value = DNS_HTTPS_T_ALPN;
dns_add_rr_nested_memcpy(svcparam, &value, 2);
value = alpn_len;
dns_add_rr_nested_memcpy(svcparam, &value,... | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
PrintBackend *cpdbCreateBackendFromFile(GDBusConnection *connection,
const char *backend_file_name)
{
FILE *file = NULL;
PrintBackend *proxy;
GError *error = NULL;
char *path, *backend_name;
const char *info_dir_name;
char obj_path[CPDB_BSIZE];
ba... | 1 | C | CWE-121 | Stack-based Buffer Overflow | A stack-based buffer overflow condition is a condition where the buffer being overwritten is allocated on the stack (i.e., is a local variable or, rarely, a parameter to a function). | https://cwe.mitre.org/data/definitions/121.html | safe |
ssl3_free(SSL *s)
{
if (s == NULL)
return;
tls1_cleanup_key_block(s);
ssl3_release_read_buffer(s);
ssl3_release_write_buffer(s);
tls_content_free(s->s3->rcontent);
tls_buffer_free(s->s3->alert_fragment);
tls_buffer_free(s->s3->handshake_fragment);
freezero(s->s3->hs.sigalgs, s->s3->hs.sigalgs_len);
sk_X5... | 1 | C | CWE-415 | Double Free | The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations. | https://cwe.mitre.org/data/definitions/415.html | safe |
ssl3_free(SSL *s)
{
if (s == NULL)
return;
tls1_cleanup_key_block(s);
ssl3_release_read_buffer(s);
ssl3_release_write_buffer(s);
tls_content_free(s->s3->rcontent);
tls_buffer_free(s->s3->alert_fragment);
tls_buffer_free(s->s3->handshake_fragment);
freezero(s->s3->hs.sigalgs, s->s3->hs.sigalgs_len);
sk_X5... | 1 | C | CWE-416 | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. | https://cwe.mitre.org/data/definitions/416.html | safe |
int pico_tcp_initconn(struct pico_socket *s)
{
struct pico_socket_tcp *ts = TCP_SOCK(s);
struct pico_frame *syn;
struct pico_tcp_hdr *hdr;
uint16_t mtu, opt_len = tcp_options_size(ts, PICO_TCP_SYN);
syn = s->net->alloc(s->stack, s->net, NULL, (uint16_t)(PICO_SIZE_TCPHDR + opt_len));
if (!syn)
... | 1 | C | CWE-908 | Use of Uninitialized Resource | The product uses or accesses a resource that has not been initialized. | https://cwe.mitre.org/data/definitions/908.html | safe |
struct pico_socket *pico_tcp_open(struct pico_stack *S, uint16_t family)
{
struct pico_socket_tcp *t = PICO_ZALLOC(sizeof(struct pico_socket_tcp));
if (!t)
return NULL;
t->sock.stack = S;
t->sock.timestamp = TCP_TIME;
pico_socket_set_family(&t->sock, family);
t->mss = (uint16_t)(pico_so... | 1 | C | CWE-908 | Use of Uninitialized Resource | The product uses or accesses a resource that has not been initialized. | https://cwe.mitre.org/data/definitions/908.html | safe |
int ipfilter(struct pico_frame *f)
{
struct filter_node temp;
struct pico_ipv4_hdr *ipv4_hdr = (struct pico_ipv4_hdr *) f->net_hdr;
struct pico_trans *trans;
struct pico_icmp4_hdr *icmp_hdr;
memset(&temp, 0u, sizeof(struct filter_node));
temp.fdev = f->dev;
temp.out_addr = ipv4_hdr->dst.ad... | 1 | C | NVD-CWE-noinfo | null | null | null | safe |
static inline void tcp_parse_option_mss(struct pico_socket_tcp *t, uint8_t len, uint8_t *opt, uint32_t *idx)
{
uint16_t mss;
if (tcpopt_len_check(idx, len, PICO_TCPOPTLEN_MSS) < 0)
return;
if ((*idx + PICO_TCPOPTLEN_MSS) > len)
return;
t->mss_ok = 1;
mss = short_from(opt + *idx);
... | 1 | C | CWE-754 | Improper Check for Unusual or Exceptional Conditions | The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. | https://cwe.mitre.org/data/definitions/754.html | safe |
static int tcp_parse_options(struct pico_frame *f)
{
struct pico_socket_tcp *t = (struct pico_socket_tcp *)f->sock;
uint8_t *opt = f->transport_hdr + PICO_SIZE_TCPHDR;
uint32_t i = 0;
f->timestamp = 0;
if (f->buffer + f->buffer_len > f->transport_hdr + f->transport_len)
return -1;
whil... | 1 | C | CWE-754 | Improper Check for Unusual or Exceptional Conditions | The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. | https://cwe.mitre.org/data/definitions/754.html | safe |
_xdr_kadm5_principal_ent_rec(XDR *xdrs, kadm5_principal_ent_rec *objp,
int v)
{
unsigned int n;
bool_t r;
if (!xdr_krb5_principal(xdrs, &objp->principal)) {
return (FALSE);
}
if (!xdr_krb5_timestamp(xdrs, &objp->princ_expire_time)) {
return (FALSE);
}
if (!xdr_krb5_timestamp(xdrs, &objp->last_pwd_ch... | 1 | C | CWE-824 | Access of Uninitialized Pointer | The product accesses or uses a pointer that has not been initialized. | https://cwe.mitre.org/data/definitions/824.html | safe |
DltReturnValue dlt_file_message(DltFile *file, int index, int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
if (file == NULL)
return DLT_RETURN_WRONG_PARAMETER;
/* check if message is in range */
if (index < 0 || index >= file->counter) {
dlt_vlog(LOG_WARNING, "Message %d out of range!\r... | 1 | C | CWE-120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The product copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | https://cwe.mitre.org/data/definitions/120.html | safe |
static int benaloh(void) {
int code = RLC_ERR;
bdpe_t pub, prv;
bn_t a, b;
dig_t in, out;
uint8_t buf[RLC_BN_BITS / 8 + 1];
size_t len;
int result;
dig_t prime = 0xFB;
bn_null(a);
bn_null(b);
bdpe_null(pub);
bdpe_null(prv);
RLC_TRY {
bn_new(a);
bn_new(b);
bdpe_new(pub);
bdpe_new(prv);
result =... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
static void benaloh(void) {
bdpe_t pub, prv;
dig_t in, new;
uint8_t out[RLC_BN_BITS / 8 + 1];
size_t out_len;
dig_t prime = 0xFB;
bdpe_null(pub);
bdpe_null(prv);
bdpe_new(pub);
bdpe_new(prv);
BENCH_ONE("cp_bdpe_gen", cp_bdpe_gen(pub, prv, prime, RLC_BN_BITS), 1);
BENCH_RUN("cp_bdpe_enc") {
out_len = RL... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
static void memory2(void) {
ep2_t a[BENCH];
BENCH_FEW("ep2_null", ep2_null(a[i]), 1);
BENCH_FEW("ep2_new", ep2_new(a[i]), 1);
for (int i = 0; i < BENCH; i++) {
ep2_free(a[i]);
}
for (int i = 0; i < BENCH; i++) {
ep2_new(a[i]);
}
BENCH_FEW("ep2_free", ep2_free(a[i]), 1);
(void)a;
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_grow(bn_t a, size_t digits) {
#if ALLOC == DYNAMIC
dig_t *t;
if (a->alloc < digits) {
/* At least add RLC_BN_SIZE more digits. */
digits += (RLC_BN_SIZE * 2) - (digits % RLC_BN_SIZE);
t = (dig_t *)realloc(a->dp, (RLC_DIG / 8) * digits);
if (t == NULL) {
RLC_THROW(ERR_NO_MEMORY);
return;
}
a... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_make(bn_t a, size_t digits) {
if (digits < 0) {
RLC_THROW(ERR_NO_VALID);
}
/* Allocate at least one digit. */
digits = RLC_MAX(digits, 1);
#if ALLOC == DYNAMIC
if (digits % RLC_BN_SIZE != 0) {
/* Pad the number of digits to a multiple of the block. */
digits += (RLC_BN_SIZE - digits % RLC_BN_SIZE);
... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_trim(bn_t a) {
if (a->used <= a->alloc) {
while (a->used > 0 && a->dp[a->used - 1] == 0) {
--(a->used);
}
/* Zero can't be negative. */
if (a->used == 0) {
a->used = 1;
a->dp[0] = 0;
a->sign = RLC_POS;
}
}
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_mxp_slide(bn_t c, const bn_t a, const bn_t b, const bn_t m) {
bn_t tab[RLC_TABLE_SIZE], t, u, r;
size_t l, w = 1;
uint8_t *win = RLC_ALLOCA(uint8_t, bn_bits(b));
if (win == NULL) {
RLC_THROW(ERR_NO_MEMORY);
return;
}
if (bn_cmp_dig(m, 1) == RLC_EQ) {
RLC_FREE(win);
bn_zero(c);
return;
}
if ... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_gen_prime_safep(bn_t a, size_t bits) {
while (1) {
do {
bn_rand(a, RLC_POS, bits);
} while (bn_bits(a) != bits);
/* Check if (a - 1)/2 is prime. */
bn_sub_dig(a, a, 1);
bn_rsh(a, a, 1);
if (bn_is_prime(a)) {
/* Restore a. */
bn_lsh(a, a, 1);
bn_add_dig(a, a, 1);
if (bn_is_prime(a)) {... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
int bn_gen_prime_factor(bn_t a, bn_t b, size_t abits, size_t bbits) {
bn_t t;
int result = RLC_OK;
if (! (bbits>abits) ) {
return RLC_ERR;
}
bn_null(t);
RLC_TRY {
bn_new(t);
bn_gen_prime(a, abits);
do {
bn_rand(t, RLC_POS, bbits - bn_bits(a));
do {
... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_gen_prime_stron(bn_t a, size_t bits) {
dig_t i, j;
int found, k;
bn_t r, s, t;
bn_null(r);
bn_null(s);
bn_null(t);
RLC_TRY {
bn_new(r);
bn_new(s);
bn_new(t);
do {
do {
/* Generate two large primes r and s. */
bn_rand(s, RLC_POS, bits / 2 - RLC_DIG / 2);
bn_rand(t, RLC_POS, bits ... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_gen_prime_basic(bn_t a, size_t bits) {
while (1) {
do {
bn_rand(a, RLC_POS, bits);
} while (bn_bits(a) != bits);
if (bn_is_prime(a)) {
return;
}
}
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
static char get_bits(const bn_t a, size_t from, size_t to) {
int f, t;
dig_t mf, mt;
RLC_RIP(from, f, from);
RLC_RIP(to, t, to);
if (f == t) {
/* Same digit. */
mf = RLC_MASK(from);
if (to + 1 >= RLC_DIG) {
mt = RLC_DMASK;
} else {
mt = RLC_MASK(to + 1);
}
mf = mf ^ mt;
return ((a->dp[f] &... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_rec_naf(int8_t *naf, size_t *len, const bn_t k, size_t w) {
int i, l;
bn_t t;
dig_t t0, mask;
int8_t u_i;
if (*len < (bn_bits(k) + 1)) {
*len = 0;
RLC_THROW(ERR_NO_BUFFER);
return;
}
bn_null(t);
RLC_TRY {
bn_new(t);
bn_abs(t, k);
mask = RLC_MASK(w);
l = (1 << w);
memset(naf, 0, *len... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_rec_slw(uint8_t *win, size_t *len, const bn_t k, size_t w) {
int i, j, l, s;
l = bn_bits(k);
if (*len < l) {
*len = 0;
RLC_THROW(ERR_NO_BUFFER);
return;
}
memset(win, 0, *len);
i = l - 1;
j = 0;
while (i >= 0) {
if (!bn_get_bit(k, i)) {
i--;
win[j++] = 0;
} else {
s = RLC_MAX(i - ... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_rec_glv(bn_t k0, bn_t k1, const bn_t k, const bn_t n, const bn_t *v1,
const bn_t *v2) {
bn_t t, b1, b2;
int r1, r2;
size_t bits;
bn_null(b1);
bn_null(b2);
bn_null(t);
RLC_TRY {
bn_new(b1);
bn_new(b2);
bn_new(t);
bn_abs(t, k);
bits = bn_bits(n);
bn_mul(b1, t, v1[0]);
r1 = bn_get_bit(b1... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_rec_tnaf_mod(bn_t r0, bn_t r1, const bn_t k, int u, size_t m) {
bn_t t, t0, t1, t2, t3;
bn_null(t);
bn_null(t0);
bn_null(t1);
bn_null(t2);
bn_null(t3);
RLC_TRY {
bn_new(t);
bn_new(t0);
bn_new(t1);
bn_new(t2);
bn_new(t3);
/* (a0, a1) = (1, 0). */
bn_set_dig(t0, 1);
bn_zero(t1);
/* (b0... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_rec_win(uint8_t *win, size_t *len, const bn_t k, size_t w) {
int i, j, l;
l = bn_bits(k);
if (*len < RLC_CEIL(l, w)) {
*len = 0;
RLC_THROW(ERR_NO_BUFFER);
return;
}
memset(win, 0, *len);
j = 0;
for (i = 0; i < l - w; i += w) {
win[j++] = get_bits(k, i, i + w - 1);
}
win[j++] = get_bits(k, i... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_rec_reg(int8_t *naf, size_t *len, const bn_t k, size_t n, size_t w) {
int i, l;
bn_t t;
dig_t t0, mask;
int8_t u_i;
bn_null(t);
mask = RLC_MASK(w);
l = RLC_CEIL(n, w - 1);
if (*len <= l) {
*len = 0;
RLC_THROW(ERR_NO_BUFFER);
return;
}
RLC_TRY {
bn_new(t);
bn_abs(t, k);
memset(naf, 0, ... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_rec_jsf(int8_t *jsf, size_t *len, const bn_t k, const bn_t l) {
bn_t n0, n1;
dig_t l0, l1;
int8_t u0, u1, d0, d1;
int i, j, offset;
if (*len < (2 * bn_bits(k) + 1)) {
*len = 0;
RLC_THROW(ERR_NO_BUFFER);
return;
}
bn_null(n0);
bn_null(n1);
RLC_TRY {
bn_new(n0);
bn_new(n1);
bn_abs(n0, k);... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_lsh(bn_t c, const bn_t a, unsigned int bits) {
int digits;
dig_t carry;
bn_copy(c, a);
RLC_RIP(bits, digits, bits);
RLC_TRY {
bn_grow(c, c->used + digits + (bits > 0));
c->used = a->used + digits;
c->sign = a->sign;
if (digits > 0) {
dv_lshd(c->dp, a->dp, c->used, digits);
}
if (bits > ... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_rsh(bn_t c, const bn_t a, unsigned int bits) {
int digits = 0;
bn_copy(c, a);
RLC_RIP(bits, digits, bits);
if (digits > 0) {
dv_rshd(c->dp, a->dp, a->used, digits);
}
if (a->used > digits) {
c->used = a->used - digits;
} else {
c->used = 0;
}
c->sign = a->sign;
if (c->used > 0 && bits > 0) ... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
int bn_smb_jac(const bn_t a, const bn_t b) {
bn_t t0, t1, r;
int t, h, res;
bn_null(t0);
bn_null(t1);
bn_null(r);
/* Argument b must be odd. */
if (bn_is_even(b) || bn_sign(b) == RLC_NEG) {
RLC_THROW(ERR_NO_VALID);
return 0;
}
RLC_TRY {
bn_new(t0);
bn_new(t1);
bn_new(r);
t = 1;
if (bn_sign(a)... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_srt(bn_t c, bn_t a) {
bn_t h, l, m, t;
size_t bits;
int cmp;
if (bn_sign(a) == RLC_NEG) {
RLC_THROW(ERR_NO_VALID);
}
bits = bn_bits(a);
bits += (bits % 2);
bn_null(h);
bn_null(l);
bn_null(m);
bn_null(t);
RLC_TRY {
bn_new(h);
bn_new(l);
bn_new(m);
bn_new(t);
bn_zero(l);
bn_set_2b(h... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
size_t bn_bits(const bn_t a) {
int bits;
if (bn_is_zero(a)) {
return 0;
}
/* Bits in lower digits. */
bits = (a->used - 1) * RLC_DIG;
return bits + util_bits_dig(a->dp[a->used - 1]);
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_write_raw(dig_t *raw, size_t len, const bn_t a) {
int i, size;
size = a->used;
if (len < size) {
RLC_THROW(ERR_NO_BUFFER);
return;
}
for (i = 0; i < size; i++) {
raw[i] = a->dp[i];
}
for (; i < len; i++) {
raw[i] = 0;
}
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_set_2b(bn_t a, size_t b) {
int i, d;
if (b >= RLC_BN_SIZE * RLC_DIG) {
RLC_THROW(ERR_NO_VALID);
} else {
RLC_RIP(b, d, b);
bn_grow(a, d + 1);
for (i = 0; i < d; i++) {
a->dp[i] = 0;
}
a->used = d + 1;
a->dp[d] = ((dig_t)1 << b);
a->sign = RLC_POS;
}
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_read_raw(bn_t a, const dig_t *raw, size_t len) {
RLC_TRY {
bn_grow(a, len);
a->used = len;
a->sign = RLC_POS;
dv_copy(a->dp, raw, len);
bn_trim(a);
} RLC_CATCH_ANY {
RLC_THROW(ERR_CAUGHT);
}
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
size_t bn_size_raw(const bn_t a) {
return a->used;
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
size_t bn_size_str(const bn_t a, unsigned int radix) {
int digits = 0;
bn_t t;
bn_null(t);
/* Check the radix. */
if (radix < 2 || radix > 64) {
RLC_THROW(ERR_NO_VALID);
return 0;
}
if (bn_is_zero(a)) {
return 2;
}
/* Binary case requires the bits, a sign and the null terminator. */
if (radix == 2) ... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
void bn_set_bit(bn_t a, size_t bit, int value) {
int d;
if (bit < 0) {
RLC_THROW(ERR_NO_VALID);
return;
}
RLC_RIP(bit, d, bit);
bn_grow(a, d);
if (value == 1) {
a->dp[d] |= ((dig_t)1 << bit);
if ((d + 1) > a->used) {
a->used = d + 1;
}
} else {
a->dp[d] &= ~((dig_t)1 << bit);
bn_trim(a);
}
... | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.