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
get_register( int name, int copy) // make a copy, if FALSE make register empty. { yankreg_T *reg; int i; #ifdef FEAT_CLIPBOARD // When Visual area changed, may have to update selection. Obtain the // selection too. if (name == '*' && clip_star.available) { if (clip_isautosel_star()) clip_update_selection(&clip_star); may_get_selection(name); } if (name == '+' && clip_plus.available) { if (clip_isautosel_plus()) clip_update_selection(&clip_plus); may_get_selection(name); } #endif get_yank_register(name, 0); reg = ALLOC_ONE(yankreg_T); if (reg == NULL) return (void *)NULL; *reg = *y_current; if (copy) { // If we run out of memory some or all of the lines are empty. if (reg->y_size == 0) reg->y_array = NULL; else reg->y_array = ALLOC_MULT(char_u *, reg->y_size); if (reg->y_array != NULL) { for (i = 0; i < reg->y_size; ++i) reg->y_array[i] = vim_strsave(y_current->y_array[i]); } } else y_current->y_array = NULL; return (void *)reg; }
0
C
CWE-476
NULL Pointer Dereference
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
https://cwe.mitre.org/data/definitions/476.html
vulnerable
regtilde(char_u *source, int magic) { char_u *newsub = source; char_u *tmpsub; char_u *p; int len; int prevlen; for (p = newsub; *p; ++p) { if ((*p == '~' && magic) || (*p == '\\' && *(p + 1) == '~' && !magic)) { if (reg_prev_sub != NULL) { // length = len(newsub) - 1 + len(prev_sub) + 1 prevlen = (int)STRLEN(reg_prev_sub); tmpsub = alloc(STRLEN(newsub) + prevlen); if (tmpsub != NULL) { // copy prefix len = (int)(p - newsub); // not including ~ mch_memmove(tmpsub, newsub, (size_t)len); // interpret tilde mch_memmove(tmpsub + len, reg_prev_sub, (size_t)prevlen); // copy postfix if (!magic) ++p; // back off backslash STRCPY(tmpsub + len + prevlen, p + 1); if (newsub != source) // already allocated newsub vim_free(newsub); newsub = tmpsub; p = newsub + len + prevlen; } } else if (magic) STRMOVE(p, p + 1); // remove '~' else STRMOVE(p, p + 2); // remove '\~' --p; } else { if (*p == '\\' && p[1]) // skip escaped characters ++p; if (has_mbyte) p += (*mb_ptr2len)(p) - 1; } } // Store a copy of newsub in reg_prev_sub. It is always allocated, // because recursive calls may make the returned string invalid. vim_free(reg_prev_sub); reg_prev_sub = vim_strsave(newsub); return newsub; }
0
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
vulnerable
is_qf_win(win_T *win, qf_info_T *qi) { // A window displaying the quickfix buffer will have the w_llist_ref field // set to NULL. // A window displaying a location list buffer will have the w_llist_ref // pointing to the location list. if (bt_quickfix(win->w_buffer)) if ((IS_QF_STACK(qi) && win->w_llist_ref == NULL) || (IS_LL_STACK(qi) && win->w_llist_ref == qi)) return TRUE; return FALSE; }
0
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
vulnerable
ex_history(exarg_T *eap) { histentry_T *hist; int histype1 = HIST_CMD; int histype2 = HIST_CMD; int hisidx1 = 1; int hisidx2 = -1; int idx; int i, j, k; char_u *end; char_u *arg = eap->arg; if (hislen == 0) { msg(_("'history' option is zero")); return; } if (!(VIM_ISDIGIT(*arg) || *arg == '-' || *arg == ',')) { end = arg; while (ASCII_ISALPHA(*end) || vim_strchr((char_u *)":=@>/?", *end) != NULL) end++; i = *end; *end = NUL; histype1 = get_histtype(arg); if (histype1 == -1) { if (STRNICMP(arg, "all", STRLEN(arg)) == 0) { histype1 = 0; histype2 = HIST_COUNT-1; } else { *end = i; semsg(_(e_trailing_characters_str), arg); return; } } else histype2 = histype1; *end = i; } else end = arg; if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) { semsg(_(e_trailing_characters_str), end); return; } for (; !got_int && histype1 <= histype2; ++histype1) { STRCPY(IObuff, "\n # "); STRCAT(STRCAT(IObuff, history_names[histype1]), " history"); msg_puts_title((char *)IObuff); idx = hisidx[histype1]; hist = history[histype1]; j = hisidx1; k = hisidx2; if (j < 0) j = (-j > hislen) ? 0 : hist[(hislen+j+idx+1) % hislen].hisnum; if (k < 0) k = (-k > hislen) ? 0 : hist[(hislen+k+idx+1) % hislen].hisnum; if (idx >= 0 && j <= k) for (i = idx + 1; !got_int; ++i) { if (i == hislen) i = 0; if (hist[i].hisstr != NULL && hist[i].hisnum >= j && hist[i].hisnum <= k) { msg_putchar('\n'); sprintf((char *)IObuff, "%c%6d ", i == idx ? '>' : ' ', hist[i].hisnum); if (vim_strsize(hist[i].hisstr) > (int)Columns - 10) trunc_string(hist[i].hisstr, IObuff + STRLEN(IObuff), (int)Columns - 10, IOSIZE - (int)STRLEN(IObuff)); else STRCAT(IObuff, hist[i].hisstr); msg_outtrans(IObuff); out_flush(); } if (i == idx) break; } } }
0
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
vulnerable
ex_history(exarg_T *eap) { histentry_T *hist; int histype1 = HIST_CMD; int histype2 = HIST_CMD; int hisidx1 = 1; int hisidx2 = -1; int idx; int i, j, k; char_u *end; char_u *arg = eap->arg; if (hislen == 0) { msg(_("'history' option is zero")); return; } if (!(VIM_ISDIGIT(*arg) || *arg == '-' || *arg == ',')) { end = arg; while (ASCII_ISALPHA(*end) || vim_strchr((char_u *)":=@>/?", *end) != NULL) end++; i = *end; *end = NUL; histype1 = get_histtype(arg); if (histype1 == -1) { if (STRNICMP(arg, "all", STRLEN(arg)) == 0) { histype1 = 0; histype2 = HIST_COUNT-1; } else { *end = i; semsg(_(e_trailing_characters_str), arg); return; } } else histype2 = histype1; *end = i; } else end = arg; if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) { semsg(_(e_trailing_characters_str), end); return; } for (; !got_int && histype1 <= histype2; ++histype1) { STRCPY(IObuff, "\n # "); STRCAT(STRCAT(IObuff, history_names[histype1]), " history"); msg_puts_title((char *)IObuff); idx = hisidx[histype1]; hist = history[histype1]; j = hisidx1; k = hisidx2; if (j < 0) j = (-j > hislen) ? 0 : hist[(hislen+j+idx+1) % hislen].hisnum; if (k < 0) k = (-k > hislen) ? 0 : hist[(hislen+k+idx+1) % hislen].hisnum; if (idx >= 0 && j <= k) for (i = idx + 1; !got_int; ++i) { if (i == hislen) i = 0; if (hist[i].hisstr != NULL && hist[i].hisnum >= j && hist[i].hisnum <= k) { msg_putchar('\n'); sprintf((char *)IObuff, "%c%6d ", i == idx ? '>' : ' ', hist[i].hisnum); if (vim_strsize(hist[i].hisstr) > (int)Columns - 10) trunc_string(hist[i].hisstr, IObuff + STRLEN(IObuff), (int)Columns - 10, IOSIZE - (int)STRLEN(IObuff)); else STRCAT(IObuff, hist[i].hisstr); msg_outtrans(IObuff); out_flush(); } if (i == idx) break; } } }
0
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
vulnerable
get_list_range(char_u **str, int *num1, int *num2) { int len; int first = FALSE; varnumber_T num; *str = skipwhite(*str); if (**str == '-' || vim_isdigit(**str)) // parse "from" part of range { vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE, NULL); *str += len; *num1 = (int)num; first = TRUE; } *str = skipwhite(*str); if (**str == ',') // parse "to" part of range { *str = skipwhite(*str + 1); vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE, NULL); if (len > 0) { *num2 = (int)num; *str = skipwhite(*str + len); } else if (!first) // no number given at all return FAIL; } else if (first) // only one number given *num2 = *num1; return OK; }
0
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
vulnerable
get_list_range(char_u **str, int *num1, int *num2) { int len; int first = FALSE; varnumber_T num; *str = skipwhite(*str); if (**str == '-' || vim_isdigit(**str)) // parse "from" part of range { vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE, NULL); *str += len; *num1 = (int)num; first = TRUE; } *str = skipwhite(*str); if (**str == ',') // parse "to" part of range { *str = skipwhite(*str + 1); vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE, NULL); if (len > 0) { *num2 = (int)num; *str = skipwhite(*str + len); } else if (!first) // no number given at all return FAIL; } else if (first) // only one number given *num2 = *num1; return OK; }
0
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
vulnerable
shift_line( int left, int round, int amount, int call_changed_bytes) // call changed_bytes() { int count; int i, j; int sw_val = (int)get_sw_value_indent(curbuf); count = get_indent(); // get current indent if (round) // round off indent { i = count / sw_val; // number of 'shiftwidth' rounded down j = count % sw_val; // extra spaces if (j && left) // first remove extra spaces --amount; if (left) { i -= amount; if (i < 0) i = 0; } else i += amount; count = i * sw_val; } else // original vi indent { if (left) { count -= sw_val * amount; if (count < 0) count = 0; } else count += sw_val * amount; } // Set new indent if (State & VREPLACE_FLAG) change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes); else (void)set_indent(count, call_changed_bytes ? SIN_CHANGED : 0); }
0
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
vulnerable
static bool meta_set(RAnal *a, RAnalMetaType type, int subtype, ut64 from, ut64 to, const char *str) { if (to < from) { return false; } RSpace *space = r_spaces_current (&a->meta_spaces); RIntervalNode *node = find_node_at (a, type, space, from); RAnalMetaItem *item = node ? node->data : R_NEW0 (RAnalMetaItem); if (!item) { return false; } item->type = type; item->subtype = subtype; item->space = space; free (item->str); item->str = str ? strdup (str) : NULL; if (str && !item->str) { if (!node) { // If we just created this free (item); } return false; } R_DIRTY (a); if (!node) { r_interval_tree_insert (&a->meta, from, to, item); } else if (node->end != to) { r_interval_tree_resize (&a->meta, node, from, to); } return true; }
0
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
vulnerable
R_API size_t r_str_ansi_strip(char *str) { size_t i = 0; while (str[i]) { size_t chlen = __str_ansi_length (str + i); if (chlen > 1) { r_str_cpy (str + i + 1, str + i + chlen); } i++; } return i; }
0
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
vulnerable
static RList *patch_relocs(RBin *b) { r_return_val_if_fail (b && b->iob.io && b->iob.io->desc, NULL); RBinObject *bo = r_bin_cur_object (b); RIO *io = b->iob.io; if (!bo || !bo->bin_obj) { return NULL; } struct r_bin_coff_obj *bin = (struct r_bin_coff_obj*)bo->bin_obj; if (bin->hdr.f_flags & COFF_FLAGS_TI_F_EXEC) { return NULL; } if (!(io->cached & R_PERM_W)) { eprintf ( "Warning: please run r2 with -e io.cache=true to patch " "relocations\n"); return NULL; } size_t nimports = 0; int i; for (i = 0; i < bin->hdr.f_nsyms; i++) { if (is_imported_symbol (&bin->symbols[i])) { nimports++; } i += bin->symbols[i].n_numaux; } ut64 m_vaddr = UT64_MAX; if (nimports) { ut64 offset = 0; RIOBank *bank = b->iob.bank_get (io, io->bank); RListIter *iter; RIOMapRef *mapref; r_list_foreach (bank->maprefs, iter, mapref) { RIOMap *map = b->iob.map_get (io, mapref->id); if (r_io_map_end (map) > offset) { offset = r_io_map_end (map); } } m_vaddr = R_ROUND (offset, 16); ut64 size = nimports * BYTES_PER_IMP_RELOC; char *muri = r_str_newf ("malloc://%" PFMT64u, size); RIODesc *desc = b->iob.open_at (io, muri, R_PERM_R, 0664, m_vaddr); free (muri); if (!desc) { return NULL; } RIOMap *map = b->iob.map_get_at (io, m_vaddr); if (!map) { return NULL; } map->name = strdup (".imports.r2"); } return _relocs_list (b, bin, true, m_vaddr); }
0
C
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
static int getid(char ch) { const char *keys = "[]<>+-,."; const char *cidx = strchr (keys, ch); return cidx? cidx - keys + 1: 0; }
0
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
vulnerable
static void process_constructors(RKernelCacheObj *obj, struct MACH0_(obj_t) *mach0, RList *ret, ut64 paddr, bool is_first, int mode, const char *prefix) { const RVector *sections = MACH0_(load_sections) (mach0); if (!sections) { return; } int type; struct section_t *section; r_vector_foreach (sections, section) { if (section->size == 0) { continue; } if (strstr (section->name, "_mod_fini_func") || strstr (section->name, "_mod_term_func")) { type = R_BIN_ENTRY_TYPE_FINI; } else if (strstr (section->name, "_mod_init_func")) { type = is_first ? 0 : R_BIN_ENTRY_TYPE_INIT; is_first = false; } else { continue; } ut8 *buf = calloc (section->size, 1); if (!buf) { break; } if (r_buf_read_at (obj->cache_buf, section->paddr + paddr, buf, section->size) < section->size) { free (buf); break; } int j; int count = 0; for (j = 0; j < section->size; j += 8) { ut64 addr64 = K_RPTR (buf + j); ut64 paddr64 = section->paddr + paddr + j; if (mode == R_K_CONSTRUCTOR_TO_ENTRY) { RBinAddr *ba = newEntry (paddr64, addr64, type); r_list_append (ret, ba); } else if (mode == R_K_CONSTRUCTOR_TO_SYMBOL) { RBinSymbol *sym = R_NEW0 (RBinSymbol); if (!sym) { break; } sym->name = r_str_newf ("%s.%s.%d", prefix, (type == R_BIN_ENTRY_TYPE_INIT) ? "init" : "fini", count++); sym->vaddr = addr64; sym->paddr = paddr64; sym->size = 0; sym->forwarder = "NONE"; sym->bind = "GLOBAL"; sym->type = "FUNC"; r_list_append (ret, sym); } } free (buf); } }
0
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
vulnerable
Bool gf_sg_proto_field_is_sftime_offset(GF_Node *node, GF_FieldInfo *field) { u32 i; GF_Route *r; GF_ProtoInstance *inst; GF_FieldInfo inf; if (node->sgprivate->tag != TAG_ProtoNode) return 0; if (field->fieldType != GF_SG_VRML_SFTIME) return 0; inst = (GF_ProtoInstance *) node; /*check in interface if this is ISed */ i=0; while ((r = (GF_Route*)gf_list_enum(inst->proto_interface->sub_graph->Routes, &i))) { if (!r->IS_route) continue; /*only check eventIn/field/exposedField*/ if (r->FromNode || (r->FromField.fieldIndex != field->fieldIndex)) continue; gf_node_get_field(r->ToNode, r->ToField.fieldIndex, &inf); /*IS to another proto*/ if (r->ToNode->sgprivate->tag == TAG_ProtoNode) return gf_sg_proto_field_is_sftime_offset(r->ToNode, &inf); /*IS to a startTime/stopTime field*/ if (!stricmp(inf.name, "startTime") || !stricmp(inf.name, "stopTime")) return 1; } return 0; }
0
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
vulnerable
static s32 svc_parse_slice(GF_BitStream *bs, AVCState *avc, AVCSliceInfo *si) { s32 pps_id; /*s->current_picture.reference= h->nal_ref_idc != 0;*/ gf_bs_read_ue_log(bs, "first_mb_in_slice"); si->slice_type = gf_bs_read_ue_log(bs, "slice_type"); if (si->slice_type > 9) return -1; pps_id = gf_bs_read_ue_log(bs, "pps_id"); if ((pps_id<0) || (pps_id > 255)) return -1; si->pps = &avc->pps[pps_id]; si->pps->id = pps_id; if (!si->pps->slice_group_count) return -2; si->sps = &avc->sps[si->pps->sps_id + GF_SVC_SSPS_ID_SHIFT]; if (!si->sps->log2_max_frame_num) return -2; si->frame_num = gf_bs_read_int_log(bs, si->sps->log2_max_frame_num, "frame_num"); si->field_pic_flag = 0; if (si->sps->frame_mbs_only_flag) { /*s->picture_structure= PICT_FRAME;*/ } else { si->field_pic_flag = gf_bs_read_int_log(bs, 1, "field_pic_flag"); if (si->field_pic_flag) si->bottom_field_flag = gf_bs_read_int_log(bs, 1, "bottom_field_flag"); } if (si->nal_unit_type == GF_AVC_NALU_IDR_SLICE || si->svc_nalhdr.idr_pic_flag) si->idr_pic_id = gf_bs_read_ue_log(bs, "idr_pic_id"); if (si->sps->poc_type == 0) { si->poc_lsb = gf_bs_read_int_log(bs, si->sps->log2_max_poc_lsb, "poc_lsb"); if (si->pps->pic_order_present && !si->field_pic_flag) { si->delta_poc_bottom = gf_bs_read_se_log(bs, "delta_poc_bottom"); } } else if ((si->sps->poc_type == 1) && !si->sps->delta_pic_order_always_zero_flag) { si->delta_poc[0] = gf_bs_read_se_log(bs, "delta_poc0"); if ((si->pps->pic_order_present == 1) && !si->field_pic_flag) si->delta_poc[1] = gf_bs_read_se_log(bs, "delta_poc1"); } if (si->pps->redundant_pic_cnt_present) { si->redundant_pic_cnt = gf_bs_read_ue_log(bs, "redundant_pic_cnt"); } return 0; }
0
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
vulnerable
GF_Err Q_DecCoordOnUnitSphere(GF_BifsDecoder *codec, GF_BitStream *bs, u32 NbBits, u32 NbComp, Fixed *m_ft) { u32 i, orient, sign; s32 value; Fixed tang[4], delta; s32 dir; if (NbComp != 2 && NbComp != 3) return GF_BAD_PARAM; //only 2 or 3 comp in the quantized version dir = 1; if(NbComp == 2) dir -= 2 * gf_bs_read_int(bs, 1); orient = gf_bs_read_int(bs, 2); if ((orient==3) && (NbComp==2)) return GF_NON_COMPLIANT_BITSTREAM; for(i=0; i<NbComp; i++) { value = gf_bs_read_int(bs, NbBits) - (1 << (NbBits-1) ); sign = (value >= 0) ? 1 : -1; m_ft[i] = sign * Q_InverseQuantize(0, 1, NbBits-1, sign*value); } delta = 1; for (i=0; i<NbComp; i++) { tang[i] = gf_tan(gf_mulfix(GF_PI/4, m_ft[i]) ); delta += gf_mulfix(tang[i], tang[i]); } delta = gf_divfix(INT2FIX(dir), gf_sqrt(delta) ); m_ft[orient] = delta; for (i=0; i<NbComp; i++) { m_ft[ (orient + i+1) % (NbComp+1) ] = gf_mulfix(tang[i], delta); } return GF_OK; }
0
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
vulnerable
GF_Err dac3_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s; if (ptr->cfg.is_ec3) s->type = GF_ISOM_BOX_TYPE_DEC3; e = gf_isom_box_write_header(s, bs); if (ptr->cfg.is_ec3) s->type = GF_ISOM_BOX_TYPE_DAC3; if (e) return e; e = gf_odf_ac3_cfg_write_bs(&ptr->cfg, bs); if (e) return e; if (ptr->cfg.atmos_ec3_ext || ptr->cfg.complexity_index_type) { gf_bs_write_int(bs, 0, 7); gf_bs_write_int(bs, ptr->cfg.atmos_ec3_ext, 1); gf_bs_write_u8(bs, ptr->cfg.complexity_index_type); } return GF_OK; }
0
C
CWE-122
Heap-based Buffer Overflow
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
https://cwe.mitre.org/data/definitions/122.html
vulnerable
GF_Err video_sample_entry_box_size(GF_Box *s) { GF_Box *b; u32 pos=0; GF_MPEGVisualSampleEntryBox *ptr = (GF_MPEGVisualSampleEntryBox *)s; gf_isom_video_sample_entry_size((GF_VisualSampleEntryBox *)s); /*make sure we write the config box first, we don't care about the rest*/ /*mp4v*/ gf_isom_check_position(s, (GF_Box *)ptr->esd, &pos); gf_isom_check_position(s, (GF_Box *)ptr->cfg_3gpp, &pos); /*avc / SVC + MVC*/ gf_isom_check_position(s, (GF_Box *)ptr->avc_config, &pos); gf_isom_check_position(s, (GF_Box *)ptr->svc_config, &pos); if (ptr->mvc_config) { gf_isom_check_position(s, gf_isom_box_find_child(s->child_boxes, GF_ISOM_BOX_TYPE_VWID), &pos); gf_isom_check_position(s, (GF_Box *)ptr->mvc_config, &pos); } /*HEVC*/ gf_isom_check_position(s, (GF_Box *)ptr->hevc_config, &pos); gf_isom_check_position(s, (GF_Box *)ptr->lhvc_config, &pos); /*VVC*/ gf_isom_check_position(s, (GF_Box *)ptr->vvc_config, &pos); /*AV1*/ gf_isom_check_position(s, (GF_Box *)ptr->av1_config, &pos); /*VPx*/ gf_isom_check_position(s, (GF_Box *)ptr->vp_config, &pos); /*JP2H*/ gf_isom_check_position(s, (GF_Box *)ptr->jp2h, &pos); /*DolbyVision*/ gf_isom_check_position(s, (GF_Box *)ptr->dovi_config, &pos); b = gf_isom_box_find_child(ptr->child_boxes, GF_ISOM_BOX_TYPE_ST3D); if (b) gf_isom_check_position(s, b, &pos); b = gf_isom_box_find_child(ptr->child_boxes, GF_ISOM_BOX_TYPE_SV3D); if (b) gf_isom_check_position(s, b, &pos); return GF_OK; }
0
C
CWE-122
Heap-based Buffer Overflow
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
https://cwe.mitre.org/data/definitions/122.html
vulnerable
void gf_isom_check_position(GF_Box *s, GF_Box *child, u32 *pos) { if (!s || !s->child_boxes || !child || !pos) return; if (s->internal_flags & GF_ISOM_ORDER_FREEZE) return; s32 cur_pos = gf_list_find(s->child_boxes, child); //happens when partially cloning boxes if (cur_pos < 0) return; if (cur_pos != (s32) *pos) { gf_list_del_item(s->child_boxes, child); gf_list_insert(s->child_boxes, child, *pos); } (*pos)++;
0
C
CWE-122
Heap-based Buffer Overflow
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
https://cwe.mitre.org/data/definitions/122.html
vulnerable
GF_EXPORT GF_Err gf_isom_box_write(GF_Box *a, GF_BitStream *bs) { GF_Err e; u64 pos = gf_bs_get_position(bs); if (!a) return GF_BAD_PARAM; //box has been disabled, do not write if (!a->size) return GF_OK; if (a->registry->disabled) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Box %s disabled registry, skip write\n", gf_4cc_to_str(a->type))); return GF_OK; } GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Box %s size %d write\n", gf_4cc_to_str(a->type), a->size)); e = gf_isom_box_write_listing(a, bs); if (e) return e; if (a->child_boxes) { e = gf_isom_box_array_write(a, a->child_boxes, bs); } pos = gf_bs_get_position(bs) - pos; if (pos != a->size) { if (a->type != GF_ISOM_BOX_TYPE_MDAT) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box %s wrote "LLU" bytes but size is "LLU"\n", gf_4cc_to_str(a->type), pos, a->size )); } } return e;
0
C
CWE-122
Heap-based Buffer Overflow
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
https://cwe.mitre.org/data/definitions/122.html
vulnerable
const u32 *gf_isom_get_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, u32 group_index, u32 *switchGroupID, u32 *criteriaListSize) { GF_TrackBox *trak; GF_UserDataMap *map; GF_TrackSelectionBox *tsel; trak = gf_isom_get_track_from_file(movie, trackNumber); if (!group_index || !trak || !trak->udta) return NULL; map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_TSEL, NULL); if (!map) return NULL; tsel = (GF_TrackSelectionBox*)gf_list_get(map->boxes, group_index-1); if (!tsel) return NULL; *switchGroupID = tsel->switchGroup; *criteriaListSize = tsel->attributeListCount; return (const u32 *) tsel->attributeList; }
0
C
CWE-122
Heap-based Buffer Overflow
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
https://cwe.mitre.org/data/definitions/122.html
vulnerable
char *gf_text_get_utf8_line(char *szLine, u32 lineSize, FILE *txt_in, s32 unicode_type) { u32 i, j, len; char *sOK; char szLineConv[2048]; unsigned short *sptr; memset(szLine, 0, sizeof(char)*lineSize); sOK = gf_fgets(szLine, lineSize, txt_in); if (!sOK) return NULL; if (unicode_type<=1) { j=0; len = (u32) strlen(szLine); for (i=0; i<len; i++) { if (!unicode_type && (szLine[i] & 0x80)) { /*non UTF8 (likely some win-CP)*/ if ((szLine[i+1] & 0xc0) != 0x80) { szLineConv[j] = 0xc0 | ( (szLine[i] >> 6) & 0x3 ); j++; szLine[i] &= 0xbf; } /*UTF8 2 bytes char*/ else if ( (szLine[i] & 0xe0) == 0xc0) { szLineConv[j] = szLine[i]; i++; j++; } /*UTF8 3 bytes char*/ else if ( (szLine[i] & 0xf0) == 0xe0) { szLineConv[j] = szLine[i]; i++; j++; szLineConv[j] = szLine[i]; i++; j++; } /*UTF8 4 bytes char*/ else if ( (szLine[i] & 0xf8) == 0xf0) { szLineConv[j] = szLine[i]; i++; j++; szLineConv[j] = szLine[i]; i++; j++; szLineConv[j] = szLine[i]; i++; j++; } else { i+=1; continue; } } szLineConv[j] = szLine[i]; j++; if (j >= GF_ARRAY_LENGTH(szLineConv) - 1) { GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[TXTIn] Line too long to convert to utf8 (len: %d)\n", len)); break; } } szLineConv[j] = 0; strcpy(szLine, szLineConv); return sOK; } #ifdef GPAC_BIG_ENDIAN if (unicode_type==3) #else if (unicode_type==2) #endif { i=0; while (1) { char c; if (!szLine[i] && !szLine[i+1]) break; c = szLine[i+1]; szLine[i+1] = szLine[i]; szLine[i] = c; i+=2; } } sptr = (u16 *)szLine; i = gf_utf8_wcstombs(szLineConv, 2048, (const unsigned short **) &sptr); if (i == GF_UTF8_FAIL) i = 0; szLineConv[i] = 0; strcpy(szLine, szLineConv); /*this is ugly indeed: since input is UTF16-LE, there are many chances the gf_fgets never reads the \0 after a \n*/ if (unicode_type==3) gf_fgetc(txt_in); return sOK;
0
C
CWE-193
Off-by-one Error
A product calculates or uses an incorrect maximum or minimum value that is 1 more, or 1 less, than the correct value.
https://cwe.mitre.org/data/definitions/193.html
vulnerable
void gf_filter_pid_inst_del(GF_FilterPidInst *pidinst) { assert(pidinst); gf_filter_pid_inst_reset(pidinst); gf_fq_del(pidinst->packets, (gf_destruct_fun) pcki_del); gf_mx_del(pidinst->pck_mx); gf_list_del(pidinst->pck_reassembly); if (pidinst->props) { assert(pidinst->props->reference_count); if (safe_int_dec(&pidinst->props->reference_count) == 0) { //see \ref gf_filter_pid_merge_properties_internal for mutex gf_mx_p(pidinst->pid->filter->tasks_mx); gf_list_del_item(pidinst->pid->properties, pidinst->props); gf_mx_v(pidinst->pid->filter->tasks_mx); gf_props_del(pidinst->props); } } gf_free(pidinst); }
0
C
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
static GF_Err xml_sax_append_string(GF_SAXParser *parser, char *string) { u32 size = parser->line_size; u32 nl_size = (u32) strlen(string); if (!nl_size) return GF_OK; if ( (parser->alloc_size < size+nl_size+1) /* || (parser->alloc_size / 2 ) > size+nl_size+1 */ ) { parser->alloc_size = size+nl_size+1; parser->alloc_size = 3 * parser->alloc_size / 2; parser->buffer = (char*)gf_realloc(parser->buffer, sizeof(char) * parser->alloc_size); if (!parser->buffer ) return GF_OUT_OF_MEM; } memcpy(parser->buffer+size, string, sizeof(char)*nl_size); parser->buffer[size+nl_size] = 0; parser->line_size = size+nl_size; return GF_OK; }
0
C
CWE-476
NULL Pointer Dereference
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
https://cwe.mitre.org/data/definitions/476.html
vulnerable
int AVI_read_audio(avi_t *AVI, u8 *audbuf, int bytes, int *continuous) { int nr, todo; s64 pos; if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } if(!AVI->track[AVI->aptr].audio_index) { AVI_errno = AVI_ERR_NO_IDX; return -1; } nr = 0; /* total number of bytes read */ if (bytes==0) { AVI->track[AVI->aptr].audio_posc++; AVI->track[AVI->aptr].audio_posb = 0; } *continuous = 1; while(bytes>0) { s64 ret; int left = (int) (AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].len - AVI->track[AVI->aptr].audio_posb); if(left==0) { if(AVI->track[AVI->aptr].audio_posc>=AVI->track[AVI->aptr].audio_chunks-1) return nr; AVI->track[AVI->aptr].audio_posc++; AVI->track[AVI->aptr].audio_posb = 0; *continuous = 0; continue; } if(bytes<left) todo = bytes; else todo = left; pos = AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].pos + AVI->track[AVI->aptr].audio_posb; gf_fseek(AVI->fdes, pos, SEEK_SET); if ( (ret = avi_read(AVI->fdes,audbuf+nr,todo)) != todo) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] XXX pos = %"LLD", ret = %"LLD", todo = %ld\n", pos, ret, todo)); AVI_errno = AVI_ERR_READ; return -1; } bytes -= todo; nr += todo; AVI->track[AVI->aptr].audio_posb += todo; } return nr; }
0
C
CWE-122
Heap-based Buffer Overflow
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
https://cwe.mitre.org/data/definitions/122.html
vulnerable
int AVI_read_frame(avi_t *AVI, u8 *vidbuf, int *keyframe) { int n; if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } if(!AVI->video_index) { AVI_errno = AVI_ERR_NO_IDX; return -1; } if(AVI->video_pos < 0 || AVI->video_pos >= AVI->video_frames) return -1; n = (u32) AVI->video_index[AVI->video_pos].len; *keyframe = (AVI->video_index[AVI->video_pos].key==0x10) ? 1:0; if (vidbuf == NULL) { AVI->video_pos++; return n; } gf_fseek(AVI->fdes, AVI->video_index[AVI->video_pos].pos, SEEK_SET); if (avi_read(AVI->fdes,vidbuf,n) != (u32) n) { AVI_errno = AVI_ERR_READ; return -1; } AVI->video_pos++; return n; }
0
C
CWE-122
Heap-based Buffer Overflow
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
https://cwe.mitre.org/data/definitions/122.html
vulnerable
static void get_info_for_all_streams (mpeg2ps_t *ps) { u8 stream_ix, max_ix, av; mpeg2ps_stream_t *sptr; u8 *buffer; u32 buflen; file_seek_to(ps->fd, 0); // av will be 0 for video streams, 1 for audio streams // av is just so I don't have to dup a lot of code that does the // same thing. for (av = 0; av < 2; av++) { if (av == 0) max_ix = ps->video_cnt; else max_ix = ps->audio_cnt; for (stream_ix = 0; stream_ix < max_ix; stream_ix++) { if (av == 0) sptr = ps->video_streams[stream_ix]; else sptr = ps->audio_streams[stream_ix]; // we don't open a separate file descriptor yet (only when they // start reading or seeking). Use the one from the ps. sptr->m_fd = ps->fd; // for now clear_stream_buffer(sptr); if (mpeg2ps_stream_read_frame(sptr, &buffer, &buflen, 0) == 0) { sptr->m_stream_id = 0; sptr->m_fd = FDNULL; continue; } get_info_from_frame(sptr, buffer, buflen); // here - if (sptr->first_pes_has_dts == 0) should be processed if (sptr->first_pes_has_dts == 0) { u32 frames_from_beg = 0; Bool have_frame; do { advance_frame(sptr); have_frame = mpeg2ps_stream_read_frame(sptr, &buffer, &buflen, 0); frames_from_beg++; } while (have_frame && sptr->frame_ts.have_dts == 0 && sptr->frame_ts.have_pts == 0 && frames_from_beg < 1000); if (have_frame == 0 || (sptr->frame_ts.have_dts == 0 && sptr->frame_ts.have_pts == 0)) { } else { sptr->start_dts = sptr->frame_ts.have_dts ? sptr->frame_ts.dts : sptr->frame_ts.pts; if (sptr->is_video) { sptr->start_dts -= frames_from_beg * sptr->ticks_per_frame; } else { u64 conv; conv = sptr->samples_per_frame * 90000; conv /= (u64)sptr->freq; sptr->start_dts -= conv; } } } clear_stream_buffer(sptr); sptr->m_fd = FDNULL; } } }
0
C
CWE-476
NULL Pointer Dereference
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
https://cwe.mitre.org/data/definitions/476.html
vulnerable
static u32 swf_get_32(SWFReader *read) { u32 val, res; val = swf_read_int(read, 32); res = (val&0xFF); res <<=8; res |= ((val>>8)&0xFF); res<<=8; res |= ((val>>16)&0xFF); res<<=8; res|= ((val>>24)&0xFF); return res; }
0
C
CWE-1077
Floating Point Comparison with Incorrect Operator
The code performs a comparison such as an equality test between two float (floating point) values, but it uses comparison operators that do not account for the possibility of loss of precision.
https://cwe.mitre.org/data/definitions/1077.html
vulnerable
static s16 swf_get_s16(SWFReader *read) { s16 val; u8 v1; v1 = swf_read_int(read, 8); val = swf_read_sint(read, 8); val = (val<<8)&0xFF00; val |= (v1&0xFF); return val; }
0
C
CWE-1077
Floating Point Comparison with Incorrect Operator
The code performs a comparison such as an equality test between two float (floating point) values, but it uses comparison operators that do not account for the possibility of loss of precision.
https://cwe.mitre.org/data/definitions/1077.html
vulnerable
static u16 swf_get_16(SWFReader *read) { u16 val, res; val = swf_read_int(read, 16); res = (val&0xFF); res <<=8; res |= ((val>>8)&0xFF); return res; }
0
C
CWE-1077
Floating Point Comparison with Incorrect Operator
The code performs a comparison such as an equality test between two float (floating point) values, but it uses comparison operators that do not account for the possibility of loss of precision.
https://cwe.mitre.org/data/definitions/1077.html
vulnerable
char *gf_bt_get_next(GF_BTParser *parser, Bool point_break) { u32 has_quote; Bool go = 1; s32 i; gf_bt_check_line(parser); i=0; has_quote = 0; while (go) { if (parser->line_buffer[parser->line_pos + i] == '\"') { if (!has_quote) has_quote = 1; else has_quote = 0; parser->line_pos += 1; if (parser->line_pos+i==parser->line_size) break; continue; } if (!has_quote) { switch (parser->line_buffer[parser->line_pos + i]) { case 0: case ' ': case '\t': case '\r': case '\n': case '{': case '}': case ']': case '[': case ',': go = 0; break; case '.': if (point_break) go = 0; break; } if (!go) break; } parser->cur_buffer[i] = parser->line_buffer[parser->line_pos + i]; i++; if (parser->line_pos+i==parser->line_size) break; } parser->cur_buffer[i] = 0; parser->line_pos += i; return parser->cur_buffer; }
0
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
vulnerable
GF_Err chnl_box_size(GF_Box *s) { GF_ChannelLayoutBox *ptr = (GF_ChannelLayoutBox *) s; s->size += 1; if (ptr->layout.stream_structure & 1) { s->size += 1; if (ptr->layout.definedLayout==0) { u32 i; for (i=0; i<ptr->layout.channels_count; i++) { s->size+=1; if (ptr->layout.layouts[i].position==126) s->size+=3; } } else { s->size += 8; } } if (ptr->layout.stream_structure & 2) { s->size += 1; } return GF_OK; }
0
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
vulnerable
GF_Err chnl_box_read(GF_Box *s,GF_BitStream *bs) { GF_ChannelLayoutBox *ptr = (GF_ChannelLayoutBox *) s; ISOM_DECREASE_SIZE(s, 1) ptr->layout.stream_structure = gf_bs_read_u8(bs); if (ptr->layout.stream_structure & 1) { ISOM_DECREASE_SIZE(s, 1) ptr->layout.definedLayout = gf_bs_read_u8(bs); if (ptr->layout.definedLayout==0) { u32 remain = (u32) ptr->size; if (ptr->layout.stream_structure & 2) remain--; ptr->layout.channels_count = 0; while (remain) { ISOM_DECREASE_SIZE(s, 1) ptr->layout.layouts[ptr->layout.channels_count].position = gf_bs_read_u8(bs); remain--; if (ptr->layout.layouts[ptr->layout.channels_count].position == 126) { ISOM_DECREASE_SIZE(s, 3) ptr->layout.layouts[ptr->layout.channels_count].azimuth = gf_bs_read_int(bs, 16); ptr->layout.layouts[ptr->layout.channels_count].elevation = gf_bs_read_int(bs, 8); remain-=3; } } } else { ISOM_DECREASE_SIZE(s, 8) ptr->layout.omittedChannelsMap = gf_bs_read_u64(bs); } } if (ptr->layout.stream_structure & 2) { ISOM_DECREASE_SIZE(s, 1) ptr->layout.object_count = gf_bs_read_u8(bs); } return GF_OK; }
0
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
vulnerable
GF_Err chnl_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_ChannelLayoutBox *ptr = (GF_ChannelLayoutBox *) s; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u8(bs, ptr->layout.stream_structure); if (ptr->layout.stream_structure & 1) { gf_bs_write_u8(bs, ptr->layout.definedLayout); if (ptr->layout.definedLayout==0) { u32 i; for (i=0; i<ptr->layout.channels_count; i++) { gf_bs_write_u8(bs, ptr->layout.layouts[i].position); if (ptr->layout.layouts[i].position==126) { gf_bs_write_int(bs, ptr->layout.layouts[i].azimuth, 16); gf_bs_write_int(bs, ptr->layout.layouts[i].elevation, 8); } } } else { gf_bs_write_u64(bs, ptr->layout.omittedChannelsMap); } } if (ptr->layout.stream_structure & 2) { gf_bs_write_u8(bs, ptr->layout.object_count); } return GF_OK; }
0
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
vulnerable
GF_Err gf_isom_use_compact_size(GF_ISOFile *movie, u32 trackNumber, Bool CompactionOn) { GF_TrackBox *trak; u32 i, size; GF_SampleSizeBox *stsz; GF_Err e; e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak) return GF_BAD_PARAM; if (!trak->Media || !trak->Media->information || !trak->Media->information->sampleTable || !trak->Media->information->sampleTable->SampleSize) return GF_ISOM_INVALID_FILE; stsz = trak->Media->information->sampleTable->SampleSize; //switch to regular table if (!CompactionOn) { if (stsz->type == GF_ISOM_BOX_TYPE_STSZ) return GF_OK; stsz->type = GF_ISOM_BOX_TYPE_STSZ; //invalidate the sampleSize and recompute it stsz->sampleSize = 0; if (!stsz->sampleCount) return GF_OK; //if the table is empty we can only assume the track is empty (no size indication) if (!stsz->sizes) return GF_OK; size = stsz->sizes[0]; //check whether the sizes are all the same or not for (i=1; i<stsz->sampleCount; i++) { if (size != stsz->sizes[i]) { size = 0; break; } } if (size) { gf_free(stsz->sizes); stsz->sizes = NULL; stsz->sampleSize = size; } return GF_OK; } //switch to compact table if (stsz->type == GF_ISOM_BOX_TYPE_STZ2) return GF_OK; //fill the table. Although it seems weird , this is needed in case of edition //after the function is called. NOte however than we force regular table //at write time if all samples are of same size if (stsz->sampleSize) { //this is a weird table indeed ;) if (stsz->sizes) gf_free(stsz->sizes); stsz->sizes = (u32*) gf_malloc(sizeof(u32)*stsz->sampleCount); if (!stsz->sizes) return GF_OUT_OF_MEM; memset(stsz->sizes, stsz->sampleSize, sizeof(u32)); } //set the SampleSize to 0 while the file is open stsz->sampleSize = 0; stsz->type = GF_ISOM_BOX_TYPE_STZ2; return GF_OK; }
0
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
vulnerable
static GF_Err gf_isom_set_root_iod(GF_ISOFile *movie) { GF_IsomInitialObjectDescriptor *iod; GF_IsomObjectDescriptor *od; GF_Err e; e = gf_isom_insert_moov(movie); if (e) return e; if (!movie->moov->iods) { AddMovieIOD(movie->moov, 1); return GF_OK; } //if OD, switch to IOD if (movie->moov->iods->descriptor->tag == GF_ODF_ISOM_IOD_TAG) return GF_OK; od = (GF_IsomObjectDescriptor *) movie->moov->iods->descriptor; iod = (GF_IsomInitialObjectDescriptor*)gf_malloc(sizeof(GF_IsomInitialObjectDescriptor)); if (!iod) return GF_OUT_OF_MEM; memset(iod, 0, sizeof(GF_IsomInitialObjectDescriptor)); iod->ES_ID_IncDescriptors = od->ES_ID_IncDescriptors; od->ES_ID_IncDescriptors = NULL; //not used in root OD iod->ES_ID_RefDescriptors = NULL; iod->extensionDescriptors = od->extensionDescriptors; od->extensionDescriptors = NULL; iod->IPMP_Descriptors = od->IPMP_Descriptors; od->IPMP_Descriptors = NULL; iod->objectDescriptorID = od->objectDescriptorID; iod->OCIDescriptors = od->OCIDescriptors; od->OCIDescriptors = NULL; iod->tag = GF_ODF_ISOM_IOD_TAG; iod->URLString = od->URLString; od->URLString = NULL; gf_odf_desc_del((GF_Descriptor *) od); movie->moov->iods->descriptor = (GF_Descriptor *)iod; return GF_OK; }
0
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
vulnerable
GF_Err gf_isom_update_sample_description_from_template(GF_ISOFile *file, u32 track, u32 sampleDescriptionIndex, u8 *data, u32 size) { GF_BitStream *bs; GF_TrackBox *trak; GF_Box *ent, *tpl_ent; GF_Err e; /*get orig sample desc and clone it*/ trak = gf_isom_get_track_from_file(file, track); if (!trak || !sampleDescriptionIndex) return GF_BAD_PARAM; if (!trak->Media || !trak->Media->handler || !trak->Media->information || !trak->Media->information->sampleTable || !trak->Media->information->sampleTable->SampleDescription) return GF_ISOM_INVALID_FILE; ent = gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, sampleDescriptionIndex-1); if (!ent) return GF_BAD_PARAM; bs = gf_bs_new(data, size, GF_BITSTREAM_READ); // e = gf_isom_box_parse(&tpl_ent, bs); e = gf_isom_box_parse_ex(&tpl_ent, bs, GF_ISOM_BOX_TYPE_STSD, GF_FALSE, 0); gf_bs_del(bs); if (e) return e; while (gf_list_count(tpl_ent->child_boxes)) { u32 j=0; Bool found = GF_FALSE; GF_Box *abox = gf_list_pop_front(tpl_ent->child_boxes); switch (abox->type) { case GF_ISOM_BOX_TYPE_SINF: case GF_ISOM_BOX_TYPE_RINF: case GF_ISOM_BOX_TYPE_BTRT: found = GF_TRUE; break; } if (found) { gf_isom_box_del(abox); continue; } if (!ent->child_boxes) ent->child_boxes = gf_list_new(); for (j=0; j<gf_list_count(ent->child_boxes); j++) { GF_Box *b = gf_list_get(ent->child_boxes, j); if (b->type == abox->type) { found = GF_TRUE; break; } } if (!found) { gf_list_add(ent->child_boxes, abox); } else { gf_isom_box_del(abox); } } gf_isom_box_del(tpl_ent); //patch for old export GF_Box *abox = gf_isom_box_find_child(ent->child_boxes, GF_ISOM_BOX_TYPE_SINF); if (abox) { gf_list_del_item(ent->child_boxes, abox); gf_list_add(ent->child_boxes, abox); } return GF_OK; }
0
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
vulnerable
static GF_SampleGroupDescriptionBox *get_sgdp(GF_SampleTableBox *stbl, void *traf, u32 grouping_type, Bool *is_traf_sgdp) #endif /* GPAC_DISABLE_ISOM_FRAGMENTS */ { GF_List *groupList=NULL; GF_List **parent=NULL; GF_SampleGroupDescriptionBox *sgdesc=NULL; u32 count, i; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (!stbl && traf && traf->trex->track->Media->information->sampleTable) stbl = traf->trex->track->Media->information->sampleTable; #endif if (stbl) { if (!stbl->sampleGroupsDescription && !traf) stbl->sampleGroupsDescription = gf_list_new(); groupList = stbl->sampleGroupsDescription; if (is_traf_sgdp) *is_traf_sgdp = GF_FALSE; parent = &stbl->child_boxes; count = gf_list_count(groupList); for (i=0; i<count; i++) { sgdesc = (GF_SampleGroupDescriptionBox*)gf_list_get(groupList, i); if (sgdesc->grouping_type==grouping_type) break; sgdesc = NULL; } } #ifndef GPAC_DISABLE_ISOM_FRAGMENTS /*look in stbl or traf for sample sampleGroupsDescription*/ if (!sgdesc && traf) { if (!traf->sampleGroupsDescription) traf->sampleGroupsDescription = gf_list_new(); groupList = traf->sampleGroupsDescription; parent = &traf->child_boxes; if (is_traf_sgdp) *is_traf_sgdp = GF_TRUE; count = gf_list_count(groupList); for (i=0; i<count; i++) { sgdesc = (GF_SampleGroupDescriptionBox*)gf_list_get(groupList, i); if (sgdesc->grouping_type==grouping_type) break; sgdesc = NULL; } } #endif if (!sgdesc) { sgdesc = (GF_SampleGroupDescriptionBox *) gf_isom_box_new_parent(parent, GF_ISOM_BOX_TYPE_SGPD); if (!sgdesc) return NULL; sgdesc->grouping_type = grouping_type; assert(groupList); gf_list_add(groupList, sgdesc); } return sgdesc; }
0
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
vulnerable
update_job_run (updateJobPtr job) { /* Here we decide on the source type and the proper execution methods which then do anything they want with the job and pass the processed job to update_process_finished_job() for result dequeuing */ /* everything starting with '|' is a local command */ if (*(job->request->source) == '|') { debug1 (DEBUG_UPDATE, "Recognized local command: %s", job->request->source); update_exec_cmd (job); return; } /* if it has a protocol "://" prefix, but not "file://" it is an URI */ if (strstr (job->request->source, "://") && strncmp (job->request->source, "file://", 7)) { network_process_request (job); return; } /* otherwise it must be a local file... */ { debug1 (DEBUG_UPDATE, "Recognized file URI: %s", job->request->source); update_load_file (job); return; } }
0
C
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
p_ntp_time(netdissect_options *ndo, const struct l_fixedpt *lfp) { uint32_t i; uint32_t uf; uint32_t f; double ff; i = GET_BE_U_4(lfp->int_part); uf = GET_BE_U_4(lfp->fraction); ff = uf; if (ff < 0.0) /* some compilers are buggy */ ff += FMAXINT; ff = ff / FMAXINT; /* shift radix point by 32 bits */ f = (uint32_t)(ff * 1000000000.0); /* treat fraction as parts per billion */ ND_PRINT("%u.%09u", i, f); /* * print the UTC time in human-readable format. */ if (i) { int64_t seconds_64bit = (int64_t)i - JAN_1970; time_t seconds; struct tm *tm; char time_buf[128]; seconds = (time_t)seconds_64bit; if (seconds != seconds_64bit) { /* * It doesn't fit into a time_t, so we can't hand it * to gmtime. */ ND_PRINT(" (unrepresentable)"); } else { tm = gmtime(&seconds); if (tm == NULL) { /* * gmtime() can't handle it. * (Yes, that might happen with some version of * Microsoft's C library.) */ ND_PRINT(" (unrepresentable)"); } else { /* use ISO 8601 (RFC3339) format */ strftime(time_buf, sizeof (time_buf), "%Y-%m-%dT%H:%M:%SZ", tm); ND_PRINT(" (%s)", time_buf); } } } }
0
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
vulnerable
ahcp_time_print(netdissect_options *ndo, const u_char *cp, uint8_t len) { time_t t; struct tm *tm; char buf[BUFSIZE]; if (len != 4) goto invalid; t = GET_BE_U_4(cp); if (NULL == (tm = gmtime(&t))) ND_PRINT(": gmtime() error"); else if (0 == strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm)) ND_PRINT(": strftime() error"); else ND_PRINT(": %s UTC", buf); return; invalid: nd_print_invalid(ndo); ND_TCHECK_LEN(cp, len); }
0
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
vulnerable
arista_print_date_hms_time(netdissect_options *ndo, uint32_t seconds, uint32_t nanoseconds) { time_t ts; struct tm *tm; char buf[BUFSIZE]; ts = seconds + (nanoseconds / 1000000000); nanoseconds %= 1000000000; if (NULL == (tm = gmtime(&ts))) ND_PRINT("gmtime() error"); else if (0 == strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm)) ND_PRINT("strftime() error"); else ND_PRINT("%s.%09u", buf, nanoseconds); }
0
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
vulnerable
static void zep_print_ts(netdissect_options *ndo, const u_char *p) { int32_t i; uint32_t uf; uint32_t f; float ff; i = GET_BE_U_4(p); uf = GET_BE_U_4(p + 4); ff = (float) uf; if (ff < 0.0) /* some compilers are buggy */ ff += FMAXINT; ff = (float) (ff / FMAXINT); /* shift radix point by 32 bits */ f = (uint32_t) (ff * 1000000000.0); /* treat fraction as parts per billion */ ND_PRINT("%u.%09d", i, f); /* * print the time in human-readable format. */ if (i) { time_t seconds = i - JAN_1970; struct tm *tm; char time_buf[128]; tm = localtime(&seconds); strftime(time_buf, sizeof (time_buf), "%Y/%m/%d %H:%M:%S", tm); ND_PRINT(" (%s)", time_buf); } }
0
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
vulnerable
MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars) { char *filename = malloc(PATH_MAX + 1); if (filename == NULL) error("%s: malloc", __func__); /* Process with strftime if Gflag is set. */ if (Gflag != 0) { struct tm *local_tm; /* Convert Gflag_time to a usable format */ if ((local_tm = localtime(&Gflag_time)) == NULL) { error("%s: localtime", __func__); } /* There's no good way to detect an error in strftime since a return * value of 0 isn't necessarily failure. */ strftime(filename, PATH_MAX, orig_name, local_tm); } else { strncpy(filename, orig_name, PATH_MAX); } if (cnt == 0 && max_chars == 0) strncpy(buffer, filename, PATH_MAX + 1); else if (snprintf(buffer, PATH_MAX + 1, "%s%0*d", filename, max_chars, cnt) > PATH_MAX) /* Report an error if the filename is too large */ error("too many output files or filename is too long (> %d)", PATH_MAX); free(filename); }
0
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
vulnerable
ts_date_hmsfrac_print(netdissect_options *ndo, long sec, long usec, enum date_flag date_flag, enum time_flag time_flag) { time_t Time = sec; struct tm *tm; char timestr[32]; if ((unsigned)sec & 0x80000000) { ND_PRINT("[Error converting time]"); return; } if (time_flag == LOCAL_TIME) tm = localtime(&Time); else tm = gmtime(&Time); if (!tm) { ND_PRINT("[Error converting time]"); return; } if (date_flag == WITH_DATE) strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", tm); else strftime(timestr, sizeof(timestr), "%H:%M:%S", tm); ND_PRINT("%s", timestr); ts_frac_print(ndo, usec); }
0
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
vulnerable
void hrandfieldCommand(client *c) { long l; int withvalues = 0; robj *hash; listpackEntry ele; if (c->argc >= 3) { if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return; if (c->argc > 4 || (c->argc == 4 && strcasecmp(c->argv[3]->ptr,"withvalues"))) { addReplyErrorObject(c,shared.syntaxerr); return; } else if (c->argc == 4) withvalues = 1; hrandfieldWithCountCommand(c, l, withvalues); return; } /* Handle variant without <count> argument. Reply with simple bulk string */ if ((hash = lookupKeyReadOrReply(c,c->argv[1],shared.null[c->resp]))== NULL || checkType(c,hash,OBJ_HASH)) { return; } hashTypeRandomElement(hash,hashTypeLength(hash),&ele,NULL); hashReplyFromListpackEntry(c, &ele); }
0
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
vulnerable
void zrandmemberCommand(client *c) { long l; int withscores = 0; robj *zset; listpackEntry ele; if (c->argc >= 3) { if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return; if (c->argc > 4 || (c->argc == 4 && strcasecmp(c->argv[3]->ptr,"withscores"))) { addReplyErrorObject(c,shared.syntaxerr); return; } else if (c->argc == 4) withscores = 1; zrandmemberWithCountCommand(c, l, withscores); return; } /* Handle variant without <count> argument. Reply with simple bulk string */ if ((zset = lookupKeyReadOrReply(c,c->argv[1],shared.null[c->resp]))== NULL || checkType(c,zset,OBJ_ZSET)) { return; } zsetTypeRandomElement(zset, zsetLength(zset), &ele,NULL); zsetReplyFromListpackEntry(c,&ele); }
0
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
vulnerable
void msetGenericCommand(client *c, int nx) { int j; int setkey_flags = 0; if ((c->argc % 2) == 0) { addReplyErrorArity(c); return; } /* Handle the NX flag. The MSETNX semantic is to return zero and don't * set anything if at least one key already exists. */ if (nx) { for (j = 1; j < c->argc; j += 2) { if (lookupKeyWrite(c->db,c->argv[j]) != NULL) { addReply(c, shared.czero); return; } } setkey_flags |= SETKEY_DOESNT_EXIST; } for (j = 1; j < c->argc; j += 2) { c->argv[j+1] = tryObjectEncoding(c->argv[j+1]); setKey(c, c->db, c->argv[j], c->argv[j + 1], setkey_flags); notifyKeyspaceEvent(NOTIFY_STRING,"set",c->argv[j],c->db->id); } server.dirty += (c->argc-1)/2; addReply(c, nx ? shared.cone : shared.ok); }
0
C
CWE-77
Improper Neutralization of Special Elements used in a Command ('Command Injection')
The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/77.html
vulnerable
static int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backlog) { int s = -1, rv; char _port[6]; /* strlen("65535") */ struct addrinfo hints, *servinfo, *p; snprintf(_port,6,"%d",port); memset(&hints,0,sizeof(hints)); hints.ai_family = af; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; /* No effect if bindaddr != NULL */ if (bindaddr && !strcmp("*", bindaddr)) bindaddr = NULL; if (af == AF_INET6 && bindaddr && !strcmp("::*", bindaddr)) bindaddr = NULL; if ((rv = getaddrinfo(bindaddr,_port,&hints,&servinfo)) != 0) { anetSetError(err, "%s", gai_strerror(rv)); return ANET_ERR; } for (p = servinfo; p != NULL; p = p->ai_next) { if ((s = socket(p->ai_family,p->ai_socktype,p->ai_protocol)) == -1) continue; if (af == AF_INET6 && anetV6Only(err,s) == ANET_ERR) goto error; if (anetSetReuseAddr(err,s) == ANET_ERR) goto error; if (anetListen(err,s,p->ai_addr,p->ai_addrlen,backlog) == ANET_ERR) s = ANET_ERR; goto end; } if (p == NULL) { anetSetError(err, "unable to bind socket, errno: %d", errno); goto error; } error: if (s != -1) close(s); s = ANET_ERR; end: freeaddrinfo(servinfo); return s; }
0
C
CWE-668
Exposure of Resource to Wrong Sphere
The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.
https://cwe.mitre.org/data/definitions/668.html
vulnerable
int anetUnixServer(char *err, char *path, mode_t perm, int backlog) { int s; struct sockaddr_un sa; if (strlen(path) > sizeof(sa.sun_path)-1) { anetSetError(err,"unix socket path too long (%zu), must be under %zu", strlen(path), sizeof(sa.sun_path)); return ANET_ERR; } if ((s = anetCreateSocket(err,AF_LOCAL)) == ANET_ERR) return ANET_ERR; memset(&sa,0,sizeof(sa)); sa.sun_family = AF_LOCAL; redis_strlcpy(sa.sun_path,path,sizeof(sa.sun_path)); if (anetListen(err,s,(struct sockaddr*)&sa,sizeof(sa),backlog) == ANET_ERR) return ANET_ERR; if (perm) chmod(sa.sun_path, perm); return s; }
0
C
CWE-668
Exposure of Resource to Wrong Sphere
The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.
https://cwe.mitre.org/data/definitions/668.html
vulnerable
static int anetListen(char *err, int s, struct sockaddr *sa, socklen_t len, int backlog) { if (bind(s,sa,len) == -1) { anetSetError(err, "bind: %s", strerror(errno)); close(s); return ANET_ERR; } if (listen(s, backlog) == -1) { anetSetError(err, "listen: %s", strerror(errno)); close(s); return ANET_ERR; } return ANET_OK; }
0
C
CWE-668
Exposure of Resource to Wrong Sphere
The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.
https://cwe.mitre.org/data/definitions/668.html
vulnerable
Tss2_RC_Decode(TSS2_RC rc) { static __thread char buf[TSS2_ERR_LAYER_NAME_MAX + TSS2_ERR_LAYER_ERROR_STR_MAX + 1]; clearbuf(buf); UINT8 layer = tss2_rc_layer_number_get(rc); TSS2_RC_HANDLER handler = layer_handler[layer].handler; const char *lname = layer_handler[layer].name; if (lname[0]) { catbuf(buf, "%s:", lname); } else { catbuf(buf, "%u:", layer); } handler = !handler ? unknown_layer_handler : handler; /* * Handlers only need the error bits. This way they don't * need to concern themselves with masking off the layer * bits or anything else. */ UINT16 err_bits = tpm2_error_get(rc); const char *e = err_bits ? handler(err_bits) : "success"; if (e) { catbuf(buf, "%s", e); } else { catbuf(buf, "0x%X", err_bits); } return buf; }
0
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
vulnerable
unknown_layer_handler(TSS2_RC rc) { static __thread char buf[32]; clearbuf(buf); catbuf(buf, "0x%X", tpm2_error_get(rc)); return buf; }
0
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
vulnerable
test_custom_handler(void **state) { (void) state; /* * Test registering a custom handler */ TSS2_RC_HANDLER old = Tss2_RC_SetHandler(1, "cstm", custom_err_handler); assert_null(old); /* * Test getting error strings */ unsigned i; for (i = 1; i < 4; i++) { // Make a layer 1 error with an error number of i. TSS2_RC rc = TSS2_RC_LAYER(1) | i; char buf[256]; snprintf(buf, sizeof(buf), "cstm:error %u", i); const char *e = Tss2_RC_Decode(rc); assert_string_equal(e, buf); } TSS2_RC rc = TSS2_RC_LAYER(1) | 42; /* * Test an unknown error */ const char *e = Tss2_RC_Decode(rc); assert_string_equal(e, "cstm:0x2A"); /* * Test clearing a handler */ old = Tss2_RC_SetHandler(1, "cstm", NULL); assert_ptr_equal(old, custom_err_handler); /* * Test an unknown layer */ e = Tss2_RC_Decode(rc); assert_string_equal(e, "1:0x2A"); }
0
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
vulnerable
sigterm_handler(int sig) // I - Signal number (unused) { (void)sig; fprintf(stderr, "DEBUG: beh: Job canceled.\n"); if (job_canceled) _exit(CUPS_BACKEND_OK); else job_canceled = 1; }
0
C
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
call_backend(char *uri, // I - URI of final destination int argc, // I - Number of command line // arguments char **argv, // I - Command-line arguments char *filename) // I - File name of input data { const char *cups_serverbin; // Location of programs char scheme[1024], // Scheme from URI *ptr, // Pointer into scheme cmdline[65536]; // Backend command line int retval; // // Build the backend command line... // strncpy(scheme, uri, sizeof(scheme) - 1); if (strlen(uri) > 1023) scheme[1023] = '\0'; if ((ptr = strchr(scheme, ':')) != NULL) *ptr = '\0'; if ((cups_serverbin = getenv("CUPS_SERVERBIN")) == NULL) cups_serverbin = CUPS_SERVERBIN; if (!strncasecmp(uri, "file:", 5) || uri[0] == '/') { fprintf(stderr, "ERROR: beh: Direct output into a file not supported.\n"); exit (CUPS_BACKEND_FAILED); } else snprintf(cmdline, sizeof(cmdline), "%s/backend/%s '%s' '%s' '%s' '%s' '%s' %s", cups_serverbin, scheme, argv[1], argv[2], argv[3], // Apply number of copies only if beh was called with a // file name and not with the print data in stdin, as // backends should handle copies only if they are called // with a file name (argc == 6 ? "1" : argv[4]), argv[5], filename); // // Overwrite the device URI and run the actual backend... // setenv("DEVICE_URI", uri, 1); fprintf(stderr, "DEBUG: beh: Executing backend command line \"%s\"...\n", cmdline); fprintf(stderr, "DEBUG: beh: Using device URI: %s\n", uri); retval = system(cmdline) >> 8; if (retval == -1) fprintf(stderr, "ERROR: Unable to execute backend command line: %s\n", strerror(errno)); return (retval); }
0
C
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
_pdfioDictSetValue( pdfio_dict_t *dict, // I - Dictionary const char *key, // I - Key _pdfio_value_t *value) // I - Value { _pdfio_pair_t *pair; // Current pair PDFIO_DEBUG("_pdfioDictSetValue(dict=%p, key=\"%s\", value=%p)\n", dict, key, (void *)value); // See if the key is already set... if (dict->num_pairs > 0) { _pdfio_pair_t pkey; // Search key pkey.key = key; if ((pair = (_pdfio_pair_t *)bsearch(&pkey, dict->pairs, dict->num_pairs, sizeof(_pdfio_pair_t), (int (*)(const void *, const void *))compare_pairs)) != NULL) { // Yes, replace the value... PDFIO_DEBUG("_pdfioDictSetValue: Replacing existing value.\n"); if (pair->value.type == PDFIO_VALTYPE_BINARY) free(pair->value.value.binary.data); pair->value = *value; return (true); } } // Nope, add a pair... if (dict->num_pairs >= dict->alloc_pairs) { // Expand the dictionary... _pdfio_pair_t *temp = (_pdfio_pair_t *)realloc(dict->pairs, (dict->alloc_pairs + 8) * sizeof(_pdfio_pair_t)); if (!temp) { PDFIO_DEBUG("_pdfioDictSetValue: Out of memory.\n"); return (false); } dict->pairs = temp; dict->alloc_pairs += 8; } pair = dict->pairs + dict->num_pairs; dict->num_pairs ++; pair->key = key; pair->value = *value; // Re-sort the dictionary and return... if (dict->num_pairs > 1 && compare_pairs(pair - 1, pair) > 0) qsort(dict->pairs, dict->num_pairs, sizeof(_pdfio_pair_t), (int (*)(const void *, const void *))compare_pairs); #ifdef DEBUG PDFIO_DEBUG("_pdfioDictSetValue(%p): %lu pairs\n", (void *)dict, (unsigned long)dict->num_pairs); PDFIO_DEBUG("_pdfioDictSetValue(%p): ", (void *)dict); PDFIO_DEBUG_DICT(dict); PDFIO_DEBUG("\n"); #endif // DEBUG return (true); }
0
C
CWE-835
Loop with Unreachable Exit Condition ('Infinite Loop')
The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.
https://cwe.mitre.org/data/definitions/835.html
vulnerable
_pdfioTokenGet(_pdfio_token_t *tb, // I - Token buffer/stack char *buffer, // I - String buffer size_t bufsize) // I - Size of string buffer { // See if we have a token waiting on the stack... if (tb->num_tokens > 0) { // Yes, return it... tb->num_tokens --; strncpy(buffer, tb->tokens[tb->num_tokens], bufsize - 1); buffer[bufsize - 1] = '\0'; PDFIO_DEBUG("_pdfioTokenGet(tb=%p, buffer=%p, bufsize=%u): Popping '%s' from stack.\n", tb, buffer, (unsigned)bufsize, buffer); free(tb->tokens[tb->num_tokens]); tb->tokens[tb->num_tokens] = NULL; return (true); } // No, read a new one... return (_pdfioTokenRead(tb, buffer, bufsize)); }
0
C
CWE-835
Loop with Unreachable Exit Condition ('Infinite Loop')
The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.
https://cwe.mitre.org/data/definitions/835.html
vulnerable
static void _clean_slate_datagram(gnrc_sixlowpan_frag_fb_t *fbuf) { clist_node_t new_queue = { .next = NULL }; fbuf->sfr.arq_timeout_event.msg.content.ptr = NULL; /* remove potentially scheduled timers for this datagram */ evtimer_del((evtimer_t *)(&_arq_timer), &fbuf->sfr.arq_timeout_event.event); fbuf->sfr.arq_timeout_event.event.next = NULL; if (gnrc_sixlowpan_frag_sfr_congure_snd_has_inter_frame_gap()) { for (clist_node_t *node = clist_lpop(&_frame_queue); node != NULL; node = clist_lpop(&_frame_queue)) { _frame_queue_t *entry = (_frame_queue_t *)node; /* remove frames of this datagram from frame queue */ if (entry->datagram_tag == fbuf->tag) { gnrc_pktbuf_release(entry->frame); /* unset packet just to be safe */ entry->frame = NULL; clist_rpush(&_frag_descs_free, node); } else { clist_rpush(&new_queue, node); } } /* reset frame queue with remaining frames */ _frame_queue = new_queue; } fbuf->offset = 0U; fbuf->sfr.cur_seq = 0U; fbuf->sfr.frags_sent = 0U; for (clist_node_t *node = clist_lpop(&fbuf->sfr.window); node != NULL; node = clist_lpop(&fbuf->sfr.window)) { clist_rpush(&_frag_descs_free, node); } }
0
C
CWE-362
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
The product contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.
https://cwe.mitre.org/data/definitions/362.html
vulnerable
static void _sched_arq_timeout(gnrc_sixlowpan_frag_fb_t *fbuf, uint32_t offset) { if (IS_ACTIVE(CONFIG_GNRC_SIXLOWPAN_SFR_MOCK_ARQ_TIMER)) { /* mock does not need to be scheduled */ return; } if (fbuf->sfr.arq_timeout_event.msg.content.ptr != NULL) { DEBUG("6lo sfr: ARQ timeout for datagram %u already scheduled\n", (uint8_t)fbuf->tag); return; } DEBUG("6lo sfr: arming ACK timeout in %lums for datagram %u\n", (long unsigned)offset, fbuf->tag); fbuf->sfr.arq_timeout_event.event.offset = offset; fbuf->sfr.arq_timeout_event.msg.content.ptr = fbuf; fbuf->sfr.arq_timeout_event.msg.type = GNRC_SIXLOWPAN_FRAG_SFR_ARQ_TIMEOUT_MSG; evtimer_add_msg(&_arq_timer, &fbuf->sfr.arq_timeout_event, _getpid()); }
0
C
CWE-362
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
The product contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.
https://cwe.mitre.org/data/definitions/362.html
vulnerable
compat_cipher_proposal(struct ssh *ssh, char *cipher_prop) { if (!(ssh->compat & SSH_BUG_BIGENDIANAES)) return cipher_prop; debug2_f("original cipher proposal: %s", cipher_prop); if ((cipher_prop = match_filter_denylist(cipher_prop, "aes*")) == NULL) fatal("match_filter_denylist failed"); debug2_f("compat cipher proposal: %s", cipher_prop); if (*cipher_prop == '\0') fatal("No supported ciphers found"); return cipher_prop; }
0
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
vulnerable
compat_kex_proposal(struct ssh *ssh, char *p) { if ((ssh->compat & (SSH_BUG_CURVE25519PAD|SSH_OLD_DHGEX)) == 0) return p; debug2_f("original KEX proposal: %s", p); if ((ssh->compat & SSH_BUG_CURVE25519PAD) != 0) if ((p = match_filter_denylist(p, "[email protected]")) == NULL) fatal("match_filter_denylist failed"); if ((ssh->compat & SSH_OLD_DHGEX) != 0) { if ((p = match_filter_denylist(p, "diffie-hellman-group-exchange-sha256," "diffie-hellman-group-exchange-sha1")) == NULL) fatal("match_filter_denylist failed"); } debug2_f("compat KEX proposal: %s", p); if (*p == '\0') fatal("No supported key exchange algorithms found"); return p; }
0
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
vulnerable
compat_pkalg_proposal(struct ssh *ssh, char *pkalg_prop) { if (!(ssh->compat & SSH_BUG_RSASIGMD5)) return pkalg_prop; debug2_f("original public key proposal: %s", pkalg_prop); if ((pkalg_prop = match_filter_denylist(pkalg_prop, "ssh-rsa")) == NULL) fatal("match_filter_denylist failed"); debug2_f("compat public key proposal: %s", pkalg_prop); if (*pkalg_prop == '\0') fatal("No supported PK algorithms found"); return pkalg_prop; }
0
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
vulnerable
process_request_identities(SocketEntry *e) { Identity *id; struct sshbuf *msg, *keys; int r; u_int nentries = 0; debug2_f("entering"); if ((msg = sshbuf_new()) == NULL || (keys = sshbuf_new()) == NULL) fatal_f("sshbuf_new failed"); TAILQ_FOREACH(id, &idtab->idlist, next) { /* identity not visible, don't include in response */ if (identity_permitted(id, e, NULL, NULL, NULL) != 0) continue; if ((r = sshkey_puts_opts(id->key, keys, SSHKEY_SERIALIZE_INFO)) != 0 || (r = sshbuf_put_cstring(keys, id->comment)) != 0) { error_fr(r, "compose key/comment"); continue; } nentries++; } debug2_f("replying with %u allowed of %u available keys", nentries, idtab->nentries); if ((r = sshbuf_put_u8(msg, SSH2_AGENT_IDENTITIES_ANSWER)) != 0 || (r = sshbuf_put_u32(msg, nentries)) != 0 || (r = sshbuf_putb(msg, keys)) != 0) fatal_fr(r, "compose"); if ((r = sshbuf_put_stringb(e->output, msg)) != 0) fatal_fr(r, "enqueue"); sshbuf_free(msg); sshbuf_free(keys); }
0
C
NVD-CWE-noinfo
null
null
null
vulnerable
static int ntlm_decode_u16l_str_hdr(struct ntlm_ctx *ctx, struct wire_field_hdr *str_hdr, struct ntlm_buffer *buffer, size_t payload_offs, char **str) { char *in, *out = NULL; uint16_t str_len; uint32_t str_offs; size_t outlen; int ret = 0; str_len = le16toh(str_hdr->len); if (str_len == 0) goto done; str_offs = le32toh(str_hdr->offset); if ((str_offs < payload_offs) || (str_offs > buffer->length) || (UINT32_MAX - str_offs < str_len) || (str_offs + str_len > buffer->length)) { return ERR_DECODE; } in = (char *)&buffer->data[str_offs]; out = malloc(str_len * 2 + 1); if (!out) return ENOMEM; ret = ntlm_str_convert(ctx->to_oem, in, out, str_len, &outlen); /* make sure to terminate output string */ out[outlen] = '\0'; done: if (ret) { safefree(out); } *str = out; return ret; }
0
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
vulnerable
void SetClipboardText(const char *text) { #if defined(PLATFORM_DESKTOP) glfwSetClipboardString(CORE.Window.handle, text); #endif #if defined(PLATFORM_WEB) emscripten_run_script(TextFormat("navigator.clipboard.writeText('%s')", text)); #endif }
0
C
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
const char *GetClipboardText(void) { #if defined(PLATFORM_DESKTOP) return glfwGetClipboardString(CORE.Window.handle); #endif #if defined(PLATFORM_WEB) // Accessing clipboard data from browser is tricky due to security reasons // The method to use is navigator.clipboard.readText() but this is an asynchronous method // that will return at some moment after the function is called with the required data emscripten_run_script_string("navigator.clipboard.readText() \ .then(text => { document.getElementById('clipboard').innerText = text; console.log('Pasted content: ', text); }) \ .catch(err => { console.error('Failed to read clipboard contents: ', err); });" ); // The main issue is getting that data, one approach could be using ASYNCIFY and wait // for the data but it requires adding Asyncify emscripten library on compilation // Another approach could be just copy the data in a HTML text field and try to retrieve it // later on if available... and clean it for future accesses return NULL; #endif return NULL; }
0
C
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
static memcached_return_t _read_one_response(memcached_instance_st *instance, char *buffer, const size_t buffer_length, memcached_result_st *result) { memcached_server_response_decrement(instance); if (result == NULL) { Memcached *root = (Memcached *) instance->root; result = &root->result; } memcached_return_t rc; if (memcached_is_binary(instance->root)) { do { rc = binary_read_one_response(instance, buffer, buffer_length, result); } while (rc == MEMCACHED_FETCH_NOTFINISHED); } else { rc = textual_read_one_response(instance, buffer, buffer_length, result); } if (memcached_fatal(rc) && rc != MEMCACHED_TIMEOUT) { memcached_io_reset(instance); } return rc; }
0
C
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
ascii_load_sockaddr(struct sockaddr_storage *ss, char *buf) { struct sockaddr_in6 ssin6; struct sockaddr_in ssin; memset(&ssin, 0, sizeof ssin); memset(&ssin6, 0, sizeof ssin6); if (!strcmp("local", buf)) { ss->ss_family = AF_LOCAL; } else if (buf[0] == '[' && buf[strlen(buf)-1] == ']') { buf[strlen(buf)-1] = '\0'; if (inet_pton(AF_INET6, buf+1, &ssin6.sin6_addr) != 1) return 0; ssin6.sin6_family = AF_INET6; memcpy(ss, &ssin6, sizeof(ssin6)); ss->ss_len = sizeof(struct sockaddr_in6); } else { if (inet_pton(AF_INET, buf, &ssin.sin_addr) != 1) return 0; ssin.sin_family = AF_INET; memcpy(ss, &ssin, sizeof(ssin)); ss->ss_len = sizeof(struct sockaddr_in); } return 1; }
0
C
NVD-CWE-noinfo
null
null
null
vulnerable
sshsk_open(const char *path) { struct sshsk_provider *ret = NULL; uint32_t version; if (path == NULL || *path == '\0') { error("No FIDO SecurityKeyProvider specified"); return NULL; } if ((ret = calloc(1, sizeof(*ret))) == NULL) { error_f("calloc failed"); return NULL; } if ((ret->path = strdup(path)) == NULL) { error_f("strdup failed"); goto fail; } /* Skip the rest if we're using the linked in middleware */ if (strcasecmp(ret->path, "internal") == 0) { ret->sk_enroll = ssh_sk_enroll; ret->sk_sign = ssh_sk_sign; ret->sk_load_resident_keys = ssh_sk_load_resident_keys; return ret; } if ((ret->dlhandle = dlopen(path, RTLD_NOW)) == NULL) { error("Provider \"%s\" dlopen failed: %s", path, dlerror()); goto fail; } if ((ret->sk_api_version = dlsym(ret->dlhandle, "sk_api_version")) == NULL) { error("Provider \"%s\" dlsym(sk_api_version) failed: %s", path, dlerror()); goto fail; } version = ret->sk_api_version(); debug_f("provider %s implements version 0x%08lx", ret->path, (u_long)version); if ((version & SSH_SK_VERSION_MAJOR_MASK) != SSH_SK_VERSION_MAJOR) { error("Provider \"%s\" implements unsupported " "version 0x%08lx (supported: 0x%08lx)", path, (u_long)version, (u_long)SSH_SK_VERSION_MAJOR); goto fail; } if ((ret->sk_enroll = dlsym(ret->dlhandle, "sk_enroll")) == NULL) { error("Provider %s dlsym(sk_enroll) failed: %s", path, dlerror()); goto fail; } if ((ret->sk_sign = dlsym(ret->dlhandle, "sk_sign")) == NULL) { error("Provider \"%s\" dlsym(sk_sign) failed: %s", path, dlerror()); goto fail; } if ((ret->sk_load_resident_keys = dlsym(ret->dlhandle, "sk_load_resident_keys")) == NULL) { error("Provider \"%s\" dlsym(sk_load_resident_keys) " "failed: %s", path, dlerror()); goto fail; } /* success */ return ret; fail: sshsk_free(ret); return NULL; }
0
C
CWE-428
Unquoted Search Path or Element
The product uses a search path that contains an unquoted element, in which the element contains whitespace or other separators. This can cause the product to access resources in a parent path.
https://cwe.mitre.org/data/definitions/428.html
vulnerable
wsemul_sun_output_control(struct wsemul_sun_emuldata *edp, struct wsemul_inputstate *instate) { int oargs; int rc; switch (instate->inchar) { case '0': case '1': case '2': case '3': case '4': /* argument digit */ case '5': case '6': case '7': case '8': case '9': /* * If we receive more arguments than we are expecting, * discard the earliest arguments. */ if (edp->nargs > SUN_EMUL_NARGS - 1) { bcopy(edp->args + 1, edp->args, (SUN_EMUL_NARGS - 1) * sizeof(edp->args[0])); edp->args[edp->nargs = SUN_EMUL_NARGS - 1] = 0; } edp->args[edp->nargs] = (edp->args[edp->nargs] * 10) + (instate->inchar - '0'); break; case ';': /* argument terminator */ edp->nargs++; break; default: /* end of escape sequence */ oargs = edp->nargs++; if (edp->nargs > SUN_EMUL_NARGS) edp->nargs = SUN_EMUL_NARGS; rc = wsemul_sun_control(edp, instate); if (rc != 0) { /* undo nargs progress */ edp->nargs = oargs; return rc; } edp->state = SUN_EMUL_STATE_NORMAL; break; } return 0; }
0
C
CWE-862
Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
vulnerable
wsemul_vt100_output_csi(struct wsemul_vt100_emuldata *edp, struct wsemul_inputstate *instate) { u_int newstate = VT100_EMUL_STATE_CSI; int oargs; int rc = 0; switch (instate->inchar) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* argument digit */ if (edp->nargs > VT100_EMUL_NARGS - 1) break; edp->args[edp->nargs] = (edp->args[edp->nargs] * 10) + (instate->inchar - '0'); break; case ';': /* argument terminator */ edp->nargs++; break; case '?': /* DEC specific */ case '>': /* DA query */ edp->modif1 = (char)instate->inchar; break; case '!': case '"': case '$': case '&': edp->modif2 = (char)instate->inchar; break; default: /* end of escape sequence */ oargs = edp->nargs++; if (edp->nargs > VT100_EMUL_NARGS) { #ifdef VT100_DEBUG printf("vt100: too many arguments\n"); #endif edp->nargs = VT100_EMUL_NARGS; } rc = wsemul_vt100_handle_csi(edp, instate); if (rc != 0) { edp->nargs = oargs; return rc; } newstate = VT100_EMUL_STATE_NORMAL; break; } if (COLS_LEFT != 0) edp->flags &= ~VTFL_LASTCHAR; edp->state = newstate; return 0; }
0
C
CWE-862
Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
vulnerable
wsemul_vt100_output_dcs(struct wsemul_vt100_emuldata *edp, struct wsemul_inputstate *instate) { u_int newstate = VT100_EMUL_STATE_DCS; switch (instate->inchar) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* argument digit */ if (edp->nargs > VT100_EMUL_NARGS - 1) break; edp->args[edp->nargs] = (edp->args[edp->nargs] * 10) + (instate->inchar - '0'); break; case ';': /* argument terminator */ edp->nargs++; break; default: edp->nargs++; if (edp->nargs > VT100_EMUL_NARGS) { #ifdef VT100_DEBUG printf("vt100: too many arguments\n"); #endif edp->nargs = VT100_EMUL_NARGS; } newstate = VT100_EMUL_STATE_STRING; switch (instate->inchar) { case '$': newstate = VT100_EMUL_STATE_DCS_DOLLAR; break; case '{': /* DECDLD soft charset */ /* } */ case '!': /* DECRQUPSS user preferred supplemental set */ /* 'u' must follow - need another state */ case '|': /* DECUDK program F6..F20 */ #ifdef VT100_PRINTNOTIMPL printf("DCS%c ignored\n", (char)instate->inchar); #endif break; default: #ifdef VT100_PRINTUNKNOWN printf("DCS %x (%d, %d) unknown\n", instate->inchar, ARG(0), ARG(1)); #endif break; } } edp->state = newstate; return 0; }
0
C
CWE-862
Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
vulnerable
static pj_status_t transport_destroy (pjmedia_transport *tp) { struct tp_adapter *adapter = (struct tp_adapter*)tp; /* Close the slave transport */ if (adapter->del_base) { pjmedia_transport_close(adapter->slave_tp); } /* Self destruct.. */ pj_pool_release(adapter->pool); return PJ_SUCCESS; }
0
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
vulnerable
static pj_status_t transport_destroy(pjmedia_transport *tp) { struct transport_loop *loop = (struct transport_loop*) tp; /* Sanity check */ PJ_ASSERT_RETURN(tp, PJ_EINVAL); pj_pool_release(loop->pool); return PJ_SUCCESS; }
0
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
vulnerable
static pj_status_t transport_destroy (pjmedia_transport *tp) { transport_srtp *srtp = (transport_srtp *) tp; pj_status_t status; unsigned i; PJ_ASSERT_RETURN(tp, PJ_EINVAL); /* Close all keying. Note that any keying should not be destroyed before * SRTP transport is destroyed as re-INVITE may initiate new keying method * without destroying SRTP transport. */ for (i=0; i < srtp->all_keying_cnt; i++) pjmedia_transport_close(srtp->all_keying[i]); /* Close member if configured */ if (srtp->setting.close_member_tp && srtp->member_tp) { pjmedia_transport_close(srtp->member_tp); } status = pjmedia_transport_srtp_stop(tp); /* In case mutex is being acquired by other thread */ pj_lock_acquire(srtp->mutex); pj_lock_release(srtp->mutex); pj_lock_destroy(srtp->mutex); pj_pool_release(srtp->pool); return status; }
0
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
vulnerable
static void clock_cb(const pj_timestamp *ts, void *user_data) { dtls_srtp_channel *ds_ch = (dtls_srtp_channel*)user_data; dtls_srtp *ds = ds_ch->dtls_srtp; unsigned idx = ds_ch->channel; PJ_UNUSED_ARG(ts); pj_lock_acquire(ds->ossl_lock); if (!ds->ossl_ssl[idx]) { pj_lock_release(ds->ossl_lock); return; } if (DTLSv1_handle_timeout(ds->ossl_ssl[idx]) > 0) { pj_lock_release(ds->ossl_lock); ssl_flush_wbio(ds, idx); } else { pj_lock_release(ds->ossl_lock); } }
0
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
vulnerable
static pj_status_t dtls_create(transport_srtp *srtp, pjmedia_transport **p_keying) { dtls_srtp *ds; pj_pool_t *pool; pj_status_t status; pool = pj_pool_create(srtp->pool->factory, "dtls%p", 2000, 256, NULL); ds = PJ_POOL_ZALLOC_T(pool, dtls_srtp); ds->pool = pool; pj_ansi_strxcpy(ds->base.name, pool->obj_name, PJ_MAX_OBJ_NAME); ds->base.type = (pjmedia_transport_type)PJMEDIA_SRTP_KEYING_DTLS_SRTP; ds->base.op = &dtls_op; ds->base.user_data = srtp; ds->srtp = srtp; status = pj_lock_create_simple_mutex(ds->pool, "dtls_ssl_lock%p", &ds->ossl_lock); if (status != PJ_SUCCESS) return status; *p_keying = &ds->base; PJ_LOG(5,(srtp->pool->obj_name, "SRTP keying DTLS-SRTP created")); return PJ_SUCCESS; }
0
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
vulnerable
static pj_status_t ssl_match_fingerprint(dtls_srtp *ds, unsigned idx) { X509 *rem_cert; pj_bool_t is_sha256; char buf[128]; pj_size_t buf_len = sizeof(buf); pj_status_t status; /* Check hash algo, currently we only support SHA-256 & SHA-1 */ if (!pj_strnicmp2(&ds->rem_fingerprint, "SHA-256 ", 8)) is_sha256 = PJ_TRUE; else if (!pj_strnicmp2(&ds->rem_fingerprint, "SHA-1 ", 6)) is_sha256 = PJ_FALSE; else { PJ_LOG(4,(ds->base.name, "Hash algo specified in remote SDP for " "its DTLS certificate fingerprint is not supported")); return PJ_ENOTSUP; } pj_lock_acquire(ds->ossl_lock); if (!ds->ossl_ssl[idx]) { pj_lock_release(ds->ossl_lock); return PJ_EGONE; } /* Get remote cert & calculate the hash */ rem_cert = SSL_get_peer_certificate(ds->ossl_ssl[idx]); pj_lock_release(ds->ossl_lock); if (!rem_cert) return PJMEDIA_SRTP_DTLS_EPEERNOCERT; status = ssl_get_fingerprint(rem_cert, is_sha256, buf, &buf_len); X509_free(rem_cert); if (status != PJ_SUCCESS) return status; /* Do they match? */ if (pj_stricmp2(&ds->rem_fingerprint, buf)) return PJMEDIA_SRTP_DTLS_EFPNOTMATCH; return PJ_SUCCESS; }
0
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
vulnerable
static pj_status_t ssl_on_recv_packet(dtls_srtp *ds, unsigned idx, const void *data, pj_size_t len) { char tmp[128]; pj_size_t nwritten; pj_lock_acquire(ds->ossl_lock); if (!ds->ossl_rbio[idx]) { pj_lock_release(ds->ossl_lock); return PJ_EGONE; } nwritten = BIO_write(ds->ossl_rbio[idx], data, (int)len); if (nwritten < len) { /* Error? */ pj_status_t status; status = GET_SSL_STATUS(ds); #if DTLS_DEBUG pj_perror(2, ds->base.name, status, "BIO_write() error"); #endif pj_lock_release(ds->ossl_lock); return status; } if (!ds->ossl_ssl[idx]) { pj_lock_release(ds->ossl_lock); return PJ_EGONE; } /* Consume (and ignore) the packet */ while (1) { int rc = SSL_read(ds->ossl_ssl[idx], tmp, sizeof(tmp)); if (rc <= 0) { #if DTLS_DEBUG pj_status_t status = GET_SSL_STATUS(ds); if (status != PJ_SUCCESS) pj_perror(2, ds->base.name, status, "SSL_read() error"); #endif break; } } pj_lock_release(ds->ossl_lock); /* Flush anything pending in the write BIO */ return ssl_flush_wbio(ds, idx); }
0
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
vulnerable
static pj_status_t dtls_destroy(pjmedia_transport *tp) { dtls_srtp *ds = (dtls_srtp *)tp; #if DTLS_DEBUG PJ_LOG(2,(ds->base.name, "dtls_destroy()")); #endif dtls_destroy_channel(ds, RTP_CHANNEL); dtls_destroy_channel(ds, RTCP_CHANNEL); if (ds->ossl_lock) { pj_lock_destroy(ds->ossl_lock); ds->ossl_lock = NULL; } pj_pool_safe_release(&ds->pool); return PJ_SUCCESS; }
0
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
vulnerable
static void ssl_destroy(dtls_srtp *ds, unsigned idx) { pj_lock_acquire(ds->ossl_lock); /* Destroy SSL instance */ if (ds->ossl_ssl[idx]) { /** * Avoid calling SSL_shutdown() if handshake wasn't completed. * OpenSSL 1.0.2f complains if SSL_shutdown() is called during an * SSL handshake, while previous versions always return 0. */ if (SSL_in_init(ds->ossl_ssl[idx]) == 0) { SSL_shutdown(ds->ossl_ssl[idx]); } SSL_free(ds->ossl_ssl[idx]); /* this will also close BIOs */ ds->ossl_ssl[idx] = NULL; /* thus reset the BIOs as well */ ds->ossl_rbio[idx] = NULL; ds->ossl_wbio[idx] = NULL; } /* Destroy SSL context */ if (ds->ossl_ctx[idx]) { SSL_CTX_free(ds->ossl_ctx[idx]); ds->ossl_ctx[idx] = NULL; } pj_lock_release(ds->ossl_lock); }
0
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
vulnerable
static pj_status_t transport_destroy(pjmedia_transport *tp) { struct transport_udp *udp = (struct transport_udp*) tp; /* Sanity check */ PJ_ASSERT_RETURN(tp, PJ_EINVAL); /* Must not close while application is using this */ //PJ_ASSERT_RETURN(!udp->attached, PJ_EINVALIDOP); if (udp->rtp_key) { /* This will block the execution if callback is still * being called. */ pj_ioqueue_unregister(udp->rtp_key); udp->rtp_key = NULL; udp->rtp_sock = PJ_INVALID_SOCKET; } else if (udp->rtp_sock != PJ_INVALID_SOCKET) { pj_sock_close(udp->rtp_sock); udp->rtp_sock = PJ_INVALID_SOCKET; } if (udp->rtcp_key) { pj_ioqueue_unregister(udp->rtcp_key); udp->rtcp_key = NULL; udp->rtcp_sock = PJ_INVALID_SOCKET; } else if (udp->rtcp_sock != PJ_INVALID_SOCKET) { pj_sock_close(udp->rtcp_sock); udp->rtcp_sock = PJ_INVALID_SOCKET; } PJ_LOG(4,(udp->base.name, "UDP media transport destroyed")); pj_pool_release(udp->pool); return PJ_SUCCESS; }
0
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
vulnerable
static RzList /*<RzDebugMap *>*/ *__io_maps(RzDebug *dbg) { RzList *list = rz_list_new(); char *str = dbg->iob.system(dbg->iob.io, "dm"); if (!str) { rz_list_free(list); return NULL; } char *ostr = str; ut64 map_start, map_end; char perm[32]; char name[512]; for (;;) { char *nl = strchr(str, '\n'); if (nl) { *nl = 0; *name = 0; *perm = 0; map_start = map_end = 0LL; if (!strncmp(str, "sys ", 4)) { char *sp = strchr(str + 4, ' '); if (sp) { str = sp + 1; } else { str += 4; } } char *_s_ = strstr(str, " s "); if (_s_) { memmove(_s_, _s_ + 2, strlen(_s_)); } _s_ = strstr(str, " ? "); if (_s_) { memmove(_s_, _s_ + 2, strlen(_s_)); } sscanf(str, "0x%" PFMT64x " - 0x%" PFMT64x " %s %s", &map_start, &map_end, perm, name); if (map_end != 0LL) { RzDebugMap *map = rz_debug_map_new(name, map_start, map_end, rz_str_rwx(perm), 0); rz_list_append(list, map); } str = nl + 1; } else { break; } } free(ostr); rz_cons_reset(); return list; }
0
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
vulnerable
static RzList /*<RzDebugMap *>*/ *__io_maps(RzDebug *dbg) { RzList *list = rz_list_new(); char *str = dbg->iob.system(dbg->iob.io, "dm"); if (!str) { rz_list_free(list); return NULL; } char *ostr = str; ut64 map_start, map_end; char perm[32]; char name[512]; for (;;) { char *nl = strchr(str, '\n'); if (nl) { *nl = 0; *name = 0; *perm = 0; map_start = map_end = 0LL; if (!strncmp(str, "sys ", 4)) { char *sp = strchr(str + 4, ' '); if (sp) { str = sp + 1; } else { str += 4; } } char *_s_ = strstr(str, " s "); if (_s_) { memmove(_s_, _s_ + 2, strlen(_s_)); } _s_ = strstr(str, " ? "); if (_s_) { memmove(_s_, _s_ + 2, strlen(_s_)); } sscanf(str, "0x%" PFMT64x " - 0x%" PFMT64x " %s %s", &map_start, &map_end, perm, name); if (map_end != 0LL) { RzDebugMap *map = rz_debug_map_new(name, map_start, map_end, rz_str_rwx(perm), 0); rz_list_append(list, map); } str = nl + 1; } else { break; } } free(ostr); rz_cons_reset(); return list; }
0
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
vulnerable
int delete_sdp_line( struct sip_msg * msg, char * s) { char * start,*end; if( !s ) return 1; start = s; end = s; while(*start != '\n') start--; start++; while(*end != '\n') end++; end++; /* delete the entry */ if( del_lump(msg, start - msg->buf, end - start,0) == NULL ) { return -1; } return 0; }
0
C
NVD-CWE-noinfo
null
null
null
vulnerable
int delete_sdp_line( struct sip_msg * msg, char * s, struct sdp_stream_cell *stream) { char * start,*end; if( !s ) return 1; start = s; end = s; while(*start != '\n' && start > stream->body.s) start--; start++; while(*end != '\n' && end < (stream->body.s+stream->body.len) ) end++; end++; /* delete the entry */ if( del_lump(msg, start - msg->buf, end - start,0) == NULL ) { return -1; } return 0; }
0
C
NVD-CWE-noinfo
null
null
null
vulnerable
char* parse_content_length( char* buffer, char* end, int* length) { int number; char *p; int size; p = buffer; /* search the beginning of the number */ while ( p<end && (*p==' ' || *p=='\t' || (*p=='\r' && *(p+1)=='\n') || (*p=='\n' && (*(p+1)==' '||*(p+1)=='\t')) )) p++; if (p==end) goto error; /* parse the number */ size = 0; number = 0; while (p<end && *p>='0' && *p<='9') { number = number*10 + (*p)-'0'; if (number<0) { LM_ERR("number overflow at pos %d in len number [%.*s]\n", (int)(p-buffer),(int)(end-buffer), buffer); return 0; } size ++; p++; } if (p==end || size==0) goto error; /* now we should have only spaces at the end */ while ( p<end && (*p==' ' || *p=='\t' || (*p=='\n' && (*(p+1)==' '||*(p+1)=='\t')) )) p++; if (p==end) goto error; /* the header ends proper? */ if ( (*(p++)!='\n') && (*(p-1)!='\r' || *(p++)!='\n' ) ) goto error; *length = number; return p; error: LM_ERR("parse error near char [%d][%c]\n",*p,*p); return 0; }
0
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
vulnerable
print_perm_line (int idx, GPtrArray *items, int cols) { g_autoptr(GString) res = g_string_new (NULL); int i; g_string_append_printf (res, " [%d] %s", idx, (char *) items->pdata[0]); for (i = 1; i < items->len; i++) { char *p; int len; p = strrchr (res->str, '\n'); if (!p) p = res->str; len = (res->str + strlen (res->str)) - p; if (len + strlen ((char *) items->pdata[i]) + 2 >= cols) g_string_append_printf (res, ",\n %s", (char *) items->pdata[i]); else g_string_append_printf (res, ", %s", (char *) items->pdata[i]); } g_print ("%s\n", res->str); }
0
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
vulnerable
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 to read /proc/modules: %s", error->message); return modules; } /* /proc/modules is a table of modules. * Columns are split by spaces and rows by newlines. * The first column is the name. */ start = modules_data; while (TRUE) { end = strchr (start, ' '); if (end == NULL) break; g_hash_table_add (modules, g_strndup (start, (end - start))); start = strchr (end, '\n'); if (start == NULL) break; start++; } return modules; }
0
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
vulnerable
flatpak_context_set_persistent (FlatpakContext *context, const char *path) { g_hash_table_insert (context->persistent, g_strdup (path), GINT_TO_POINTER (1)); }
0
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
vulnerable
option_persist_cb (const gchar *option_name, const gchar *value, gpointer data, GError **error) { FlatpakContext *context = data; flatpak_context_set_persistent (context, value); return TRUE; }
0
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
vulnerable
context_parse_args (FlatpakContext *context, ...) { g_autoptr(GError) local_error = NULL; 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_list ap; g_ptr_array_add (args, g_strdup ("argv[0]")); va_start (ap, context); while ((arg = va_arg (ap, const char *)) != NULL) g_ptr_array_add (args, g_strdup (arg)); va_end (ap); g_ptr_array_add (args, NULL); argv = (GStrv) g_ptr_array_free (g_steal_pointer (&args), FALSE); oc = g_option_context_new (""); group = flatpak_context_get_options (context); g_option_context_add_group (oc, group); g_option_context_parse_strv (oc, &argv, &local_error); g_assert_no_error (local_error); }
0
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
vulnerable
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); context->sock = sock; context->last_msg_in = db.now_s; context->next_msg_out = db.now_s + 60; context->keepalive = 60; /* Default to 60s */ context->clean_start = true; context->id = NULL; context->last_mid = 0; context->will = NULL; context->username = NULL; context->password = NULL; context->listener = NULL; context->acl_list = NULL; context->retain_available = true; /* is_bridge records whether this client is a bridge or not. This could be * done by looking at context->bridge for bridges that we create ourself, * but incoming bridges need some other way of being recorded. */ context->is_bridge = false; context->in_packet.payload = NULL; packet__cleanup(&context->in_packet); context->out_packet = NULL; context->current_out_packet = NULL; context->out_packet_count = 0; context->address = NULL; if((int)sock >= 0){ if(!net__socket_get_address(sock, address, 1024, &context->remote_port)){ context->address = mosquitto__strdup(address); } if(!context->address){ /* getpeername and inet_ntop failed and not a bridge */ mosquitto__free(context); return NULL; } } context->bridge = NULL; context->msgs_in.inflight_maximum = db.config->max_inflight_messages; context->msgs_out.inflight_maximum = db.config->max_inflight_messages; context->msgs_in.inflight_quota = db.config->max_inflight_messages; context->msgs_out.inflight_quota = db.config->max_inflight_messages; context->max_qos = 2; #ifdef WITH_TLS context->ssl = NULL; #endif if((int)context->sock >= 0){ HASH_ADD(hh_sock, db.contexts_by_sock, sock, sizeof(context->sock), context); } return context; }
0
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
vulnerable
void context__cleanup(struct mosquitto *context, bool force_free) { struct mosquitto__packet *packet; if(!context) return; if(force_free){ context->clean_start = true; } #ifdef WITH_BRIDGE if(context->bridge){ bridge__cleanup(context); } #endif alias__free_all(context); mosquitto__free(context->auth_method); context->auth_method = NULL; mosquitto__free(context->username); context->username = NULL; mosquitto__free(context->password); context->password = NULL; net__socket_close(context); if(force_free){ sub__clean_session(context); } db__messages_delete(context, force_free); mosquitto__free(context->address); context->address = NULL; context__send_will(context); if(context->id){ context__remove_from_by_id(context); mosquitto__free(context->id); context->id = NULL; } packet__cleanup(&(context->in_packet)); 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_packet){ packet__cleanup(context->out_packet); packet = context->out_packet; context->out_packet = context->out_packet->next; mosquitto__free(packet); } context->out_packet_count = 0; #if defined(WITH_BROKER) && defined(__GLIBC__) && defined(WITH_ADNS) if(context->adns){ gai_cancel(context->adns); mosquitto__free((struct addrinfo *)context->adns->ar_request); mosquitto__free(context->adns); } #endif if(force_free){ mosquitto__free(context); } }
0
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
vulnerable
int db__message_store_find(struct mosquitto *context, uint16_t mid, struct mosquitto_msg_store **stored) { struct mosquitto_client_msg *tail; if(!context) return MOSQ_ERR_INVAL; *stored = NULL; DL_FOREACH(context->msgs_in.inflight, tail){ if(tail->store->source_mid == mid){ *stored = tail->store; return MOSQ_ERR_SUCCESS; } } DL_FOREACH(context->msgs_in.queued, tail){ if(tail->store->source_mid == mid){ *stored = tail->store; return MOSQ_ERR_SUCCESS; } } return 1; }
0
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
vulnerable
match_expr(struct search_node_list *head, struct eventlog *evlog, bool last_match) { struct search_node *sn; bool res = false, matched = last_match; int rc; debug_decl(match_expr, SUDO_DEBUG_UTIL); STAILQ_FOREACH(sn, head, entries) { switch (sn->type) { case ST_EXPR: res = match_expr(&sn->u.expr, evlog, matched); break; case ST_CWD: if (evlog->cwd != NULL) res = strcmp(sn->u.cwd, evlog->cwd) == 0; break; case ST_HOST: if (evlog->submithost != NULL) res = strcmp(sn->u.host, evlog->submithost) == 0; break; case ST_TTY: if (evlog->ttyname != NULL) res = strcmp(sn->u.tty, evlog->ttyname) == 0; break; case ST_RUNASGROUP: if (evlog->rungroup != NULL) res = strcmp(sn->u.runas_group, evlog->rungroup) == 0; break; case ST_RUNASUSER: if (evlog->runuser != NULL) res = strcmp(sn->u.runas_user, evlog->runuser) == 0; break; case ST_USER: if (evlog->submituser != NULL) res = strcmp(sn->u.user, evlog->submituser) == 0; break; case ST_PATTERN: rc = regexec(&sn->u.cmdre, evlog->command, 0, NULL, 0); if (rc && rc != REG_NOMATCH) { char buf[BUFSIZ]; regerror(rc, &sn->u.cmdre, buf, sizeof(buf)); sudo_fatalx("%s", buf); } res = rc == REG_NOMATCH ? 0 : 1; break; case ST_FROMDATE: res = sudo_timespeccmp(&evlog->submit_time, &sn->u.tstamp, >=); break; case ST_TODATE: res = sudo_timespeccmp(&evlog->submit_time, &sn->u.tstamp, <=); break; default: sudo_fatalx(U_("unknown search type %d"), sn->type); /* NOTREACHED */ } if (sn->negated) res = !res; matched = sn->or ? (res || last_match) : (res && last_match); last_match = matched; } debug_return_bool(matched); }
0
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
vulnerable
match_expr(struct search_node_list *head, struct eventlog *evlog, bool last_match) { struct search_node *sn; bool res = false, matched = last_match; int rc; debug_decl(match_expr, SUDO_DEBUG_UTIL); STAILQ_FOREACH(sn, head, entries) { switch (sn->type) { case ST_EXPR: res = match_expr(&sn->u.expr, evlog, matched); break; case ST_CWD: if (evlog->cwd != NULL) res = strcmp(sn->u.cwd, evlog->cwd) == 0; break; case ST_HOST: if (evlog->submithost != NULL) res = strcmp(sn->u.host, evlog->submithost) == 0; break; case ST_TTY: if (evlog->ttyname != NULL) res = strcmp(sn->u.tty, evlog->ttyname) == 0; break; case ST_RUNASGROUP: if (evlog->rungroup != NULL) res = strcmp(sn->u.runas_group, evlog->rungroup) == 0; break; case ST_RUNASUSER: if (evlog->runuser != NULL) res = strcmp(sn->u.runas_user, evlog->runuser) == 0; break; case ST_USER: if (evlog->submituser != NULL) res = strcmp(sn->u.user, evlog->submituser) == 0; break; case ST_PATTERN: rc = regexec(&sn->u.cmdre, evlog->command, 0, NULL, 0); if (rc && rc != REG_NOMATCH) { char buf[BUFSIZ]; regerror(rc, &sn->u.cmdre, buf, sizeof(buf)); sudo_fatalx("%s", buf); } res = rc == REG_NOMATCH ? 0 : 1; break; case ST_FROMDATE: res = sudo_timespeccmp(&evlog->submit_time, &sn->u.tstamp, >=); break; case ST_TODATE: res = sudo_timespeccmp(&evlog->submit_time, &sn->u.tstamp, <=); break; default: sudo_fatalx(U_("unknown search type %d"), sn->type); /* NOTREACHED */ } if (sn->negated) res = !res; matched = sn->or ? (res || last_match) : (res && last_match); last_match = matched; } debug_return_bool(matched); }
0
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
vulnerable
list_session(char *log_dir, regex_t *re, const char *user, const char *tty) { char idbuf[7], *idstr, *cp; struct eventlog *evlog = NULL; const char *timestr; int ret = -1; debug_decl(list_session, SUDO_DEBUG_UTIL); if ((evlog = iolog_parse_loginfo(-1, log_dir)) == NULL) goto done; if (evlog->command == NULL || evlog->submituser == NULL || evlog->runuser == NULL) { goto done; } /* Match on search expression if there is one. */ if (!STAILQ_EMPTY(&search_expr) && !match_expr(&search_expr, evlog, true)) goto done; /* Convert from /var/log/sudo-sessions/00/00/01 to 000001 */ cp = log_dir + strlen(session_dir) + 1; if (IS_IDLOG(cp)) { idbuf[0] = cp[0]; idbuf[1] = cp[1]; idbuf[2] = cp[3]; idbuf[3] = cp[4]; idbuf[4] = cp[6]; idbuf[5] = cp[7]; idbuf[6] = '\0'; idstr = idbuf; } else { /* Not an id, use as-is. */ idstr = cp; } /* XXX - print lines + cols? */ timestr = get_timestr(evlog->submit_time.tv_sec, 1); printf("%s : %s : ", timestr ? timestr : "invalid date", evlog->submituser); if (evlog->submithost != NULL) printf("HOST=%s ; ", evlog->submithost); if (evlog->ttyname != NULL) printf("TTY=%s ; ", evlog->ttyname); if (evlog->runchroot != NULL) printf("CHROOT=%s ; ", evlog->runchroot); if (evlog->runcwd != NULL || evlog->cwd != NULL) printf("CWD=%s ; ", evlog->runcwd ? evlog->runcwd : evlog->cwd); printf("USER=%s ; ", evlog->runuser); if (evlog->rungroup != NULL) printf("GROUP=%s ; ", evlog->rungroup); printf("TSID=%s ; COMMAND=%s\n", idstr, evlog->command); ret = 0; done: eventlog_free(evlog); debug_return_int(ret); }
0
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
vulnerable
list_session(char *log_dir, regex_t *re, const char *user, const char *tty) { char idbuf[7], *idstr, *cp; struct eventlog *evlog = NULL; const char *timestr; int ret = -1; debug_decl(list_session, SUDO_DEBUG_UTIL); if ((evlog = iolog_parse_loginfo(-1, log_dir)) == NULL) goto done; if (evlog->command == NULL || evlog->submituser == NULL || evlog->runuser == NULL) { goto done; } /* Match on search expression if there is one. */ if (!STAILQ_EMPTY(&search_expr) && !match_expr(&search_expr, evlog, true)) goto done; /* Convert from /var/log/sudo-sessions/00/00/01 to 000001 */ cp = log_dir + strlen(session_dir) + 1; if (IS_IDLOG(cp)) { idbuf[0] = cp[0]; idbuf[1] = cp[1]; idbuf[2] = cp[3]; idbuf[3] = cp[4]; idbuf[4] = cp[6]; idbuf[5] = cp[7]; idbuf[6] = '\0'; idstr = idbuf; } else { /* Not an id, use as-is. */ idstr = cp; } /* XXX - print lines + cols? */ timestr = get_timestr(evlog->submit_time.tv_sec, 1); printf("%s : %s : ", timestr ? timestr : "invalid date", evlog->submituser); if (evlog->submithost != NULL) printf("HOST=%s ; ", evlog->submithost); if (evlog->ttyname != NULL) printf("TTY=%s ; ", evlog->ttyname); if (evlog->runchroot != NULL) printf("CHROOT=%s ; ", evlog->runchroot); if (evlog->runcwd != NULL || evlog->cwd != NULL) printf("CWD=%s ; ", evlog->runcwd ? evlog->runcwd : evlog->cwd); printf("USER=%s ; ", evlog->runuser); if (evlog->rungroup != NULL) printf("GROUP=%s ; ", evlog->rungroup); printf("TSID=%s ; COMMAND=%s\n", idstr, evlog->command); ret = 0; done: eventlog_free(evlog); debug_return_int(ret); }
0
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
vulnerable