[ { "id": 3136, "func": "char *Hub::inflate(char *data, size_t &length) {\n dynamicInflationBuffer.clear();\n\n inflationStream.next_in = (Bytef *) data;\n inflationStream.avail_in = length;\n\n int err;\n do {\n inflationStream.next_out = (Bytef *) inflationBuffer;\n inflationStream.avail_out = LARGE_BUFFER_SIZE;\n err = ::inflate(&inflationStream, Z_FINISH);\n if (!inflationStream.avail_in) {\n break;\n }\n dynamicInflationBuffer.append(inflationBuffer, LARGE_BUFFER_SIZE - inflationStream.avail_out);\n } while (err == Z_BUF_ERROR);\n\n inflateReset(&inflationStream);\n\n if (err != Z_BUF_ERROR && err != Z_OK) {\n length = 0;\n return nullptr;\n }\n\n if (dynamicInflationBuffer.length()) {\n dynamicInflationBuffer.append(inflationBuffer, LARGE_BUFFER_SIZE - inflationStream.avail_out);\n\n length = dynamicInflationBuffer.length();\n return (char *) dynamicInflationBuffer.data();\n }\n\n length = LARGE_BUFFER_SIZE - inflationStream.avail_out;\n return inflationBuffer;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10544", "cwe_id": "CWE-20" }, { "id": 3136, "func": "char *Hub::inflate(char *data, size_t &length) {\n dynamicInflationBuffer.clear();\n\n inflationStream.next_in = (Bytef *) data;\n inflationStream.avail_in = length;\n\n int err;\n do {\n inflationStream.next_out = (Bytef *) inflationBuffer;\n inflationStream.avail_out = LARGE_BUFFER_SIZE;\n err = ::inflate(&inflationStream, Z_FINISH);\n if (!inflationStream.avail_in) {\n break;\n }\n\n dynamicInflationBuffer.append(inflationBuffer, LARGE_BUFFER_SIZE - inflationStream.avail_out);\n } while (err == Z_BUF_ERROR && dynamicInflationBuffer.length() <= INFLATE_LESS_THAN_ROUGHLY);\n\n inflateReset(&inflationStream);\n\n if ((err != Z_BUF_ERROR && err != Z_OK) || dynamicInflationBuffer.length() > INFLATE_LESS_THAN_ROUGHLY) {\n length = 0;\n return nullptr;\n }\n\n if (dynamicInflationBuffer.length()) {\n dynamicInflationBuffer.append(inflationBuffer, LARGE_BUFFER_SIZE - inflationStream.avail_out);\n\n length = dynamicInflationBuffer.length();\n return (char *) dynamicInflationBuffer.data();\n }\n\n length = LARGE_BUFFER_SIZE - inflationStream.avail_out;\n return inflationBuffer;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10544", "cwe_id": "CWE-20" }, { "id": 2515, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n auto* params = reinterpret_cast(node->builtin_data);\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n if (output->type == kTfLiteFloat32 || output->type == kTfLiteInt32) {\n EvalDiv(context, node, params, data, input1, input2, output);\n } else if (output->type == kTfLiteUInt8) {\n TF_LITE_ENSURE_OK(\n context, EvalQuantized(context, node, params, data, input1,\n input2, output));\n } else {\n context->ReportError(\n context,\n \"Div only supports FLOAT32, INT32 and quantized UINT8 now, got %d.\",\n output->type);\n return kTfLiteError;\n }\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2515, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n auto* params = reinterpret_cast(node->builtin_data);\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n if (output->type == kTfLiteFloat32 || output->type == kTfLiteInt32) {\n EvalDiv(context, node, params, data, input1, input2, output);\n } else if (output->type == kTfLiteUInt8) {\n TF_LITE_ENSURE_OK(\n context, EvalQuantized(context, node, params, data, input1,\n input2, output));\n } else {\n context->ReportError(\n context,\n \"Div only supports FLOAT32, INT32 and quantized UINT8 now, got %d.\",\n output->type);\n return kTfLiteError;\n }\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3217, "func": "void * pvPortMalloc( size_t xWantedSize )\r\n{\r\n BlockLink_t * pxBlock, * pxPreviousBlock, * pxNewBlockLink;\r\n void * pvReturn = NULL;\r\n\r\n vTaskSuspendAll();\r\n {\r\n /* If this is the first call to malloc then the heap will require\r\n * initialisation to setup the list of free blocks. */\r\n if( pxEnd == NULL )\r\n {\r\n prvHeapInit();\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n\r\n /* Check the requested block size is not so large that the top bit is\r\n * set. The top bit of the block size member of the BlockLink_t structure\r\n * is used to determine who owns the block - the application or the\r\n * kernel, so it must be free. */\r\n if( ( xWantedSize & xBlockAllocatedBit ) == 0 )\r\n {\r\n /* The wanted size is increased so it can contain a BlockLink_t\r\n * structure in addition to the requested amount of bytes. */\r\n if( xWantedSize > 0 )\r\n {\r\n xWantedSize += xHeapStructSize;\r\n\r\n /* Ensure that blocks are always aligned to the required number\r\n * of bytes. */\r\n if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )\r\n {\r\n /* Byte alignment required. */\r\n xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r\n configASSERT( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) == 0 );\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n\r\n if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )\r\n {\r\n /* Traverse the list from the start\t(lowest address) block until\r\n * one\tof adequate size is found. */\r\n pxPreviousBlock = &xStart;\r\n pxBlock = xStart.pxNextFreeBlock;\r\n\r\n while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )\r\n {\r\n pxPreviousBlock = pxBlock;\r\n pxBlock = pxBlock->pxNextFreeBlock;\r\n }\r\n\r\n /* If the end marker was reached then a block of adequate size\r\n * was\tnot found. */\r\n if( pxBlock != pxEnd )\r\n {\r\n /* Return the memory space pointed to - jumping over the\r\n * BlockLink_t structure at its start. */\r\n pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize );\r\n\r\n /* This block is being returned for use so must be taken out\r\n * of the list of free blocks. */\r\n pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;\r\n\r\n /* If the block is larger than required it can be split into\r\n * two. */\r\n if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )\r\n {\r\n /* This block is to be split into two. Create a new\r\n * block following the number of bytes requested. The void\r\n * cast is used to prevent byte alignment warnings from the\r\n * compiler. */\r\n pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );\r\n configASSERT( ( ( ( size_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 );\r\n\r\n /* Calculate the sizes of two blocks split from the\r\n * single block. */\r\n pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;\r\n pxBlock->xBlockSize = xWantedSize;\r\n\r\n /* Insert the new block into the list of free blocks. */\r\n prvInsertBlockIntoFreeList( pxNewBlockLink );\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n\r\n xFreeBytesRemaining -= pxBlock->xBlockSize;\r\n\r\n if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining )\r\n {\r\n xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n\r\n /* The block is being returned - it is allocated and owned\r\n * by the application and has no \"next\" block. */\r\n pxBlock->xBlockSize |= xBlockAllocatedBit;\r\n pxBlock->pxNextFreeBlock = NULL;\r\n xNumberOfSuccessfulAllocations++;\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n\r\n traceMALLOC( pvReturn, xWantedSize );\r\n }\r\n ( void ) xTaskResumeAll();\r\n\r\n #if ( configUSE_MALLOC_FAILED_HOOK == 1 )\r\n {\r\n if( pvReturn == NULL )\r\n {\r\n extern void vApplicationMallocFailedHook( void );\r\n vApplicationMallocFailedHook();\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n }\r\n #endif /* if ( configUSE_MALLOC_FAILED_HOOK == 1 ) */\r\n\r\n configASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) portBYTE_ALIGNMENT_MASK ) == 0 );\r\n return pvReturn;\r\n}\r", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-32020", "cwe_id": "CWE-119" }, { "id": 3217, "func": "void * pvPortMalloc( size_t xWantedSize )\r\n{\r\n BlockLink_t * pxBlock, * pxPreviousBlock, * pxNewBlockLink;\r\n void * pvReturn = NULL;\r\n\r\n vTaskSuspendAll();\r\n {\r\n /* If this is the first call to malloc then the heap will require\r\n * initialisation to setup the list of free blocks. */\r\n if( pxEnd == NULL )\r\n {\r\n prvHeapInit();\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n\r\n /* Check the requested block size is not so large that the top bit is\r\n * set. The top bit of the block size member of the BlockLink_t structure\r\n * is used to determine who owns the block - the application or the\r\n * kernel, so it must be free. */\r\n if( ( xWantedSize & xBlockAllocatedBit ) == 0 )\r\n {\r\n /* The wanted size must be increased so it can contain a BlockLink_t\r\n * structure in addition to the requested amount of bytes. */\r\n if( ( xWantedSize > 0 ) && \r\n ( ( xWantedSize + xHeapStructSize ) > xWantedSize ) ) /* Overflow check */\r\n {\r\n xWantedSize += xHeapStructSize;\r\n\r\n /* Ensure that blocks are always aligned. */\r\n if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )\r\n {\r\n /* Byte alignment required. Check for overflow. */\r\n if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ) \r\n > xWantedSize )\r\n {\r\n xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r\n configASSERT( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) == 0 );\r\n }\r\n else\r\n {\r\n xWantedSize = 0;\r\n } \r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n } \r\n else \r\n {\r\n xWantedSize = 0;\r\n }\r\n\r\n if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )\r\n {\r\n /* Traverse the list from the start\t(lowest address) block until\r\n * one of adequate size is found. */\r\n pxPreviousBlock = &xStart;\r\n pxBlock = xStart.pxNextFreeBlock;\r\n\r\n while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )\r\n {\r\n pxPreviousBlock = pxBlock;\r\n pxBlock = pxBlock->pxNextFreeBlock;\r\n }\r\n\r\n /* If the end marker was reached then a block of adequate size\r\n * was not found. */\r\n if( pxBlock != pxEnd )\r\n {\r\n /* Return the memory space pointed to - jumping over the\r\n * BlockLink_t structure at its start. */\r\n pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize );\r\n\r\n /* This block is being returned for use so must be taken out\r\n * of the list of free blocks. */\r\n pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;\r\n\r\n /* If the block is larger than required it can be split into\r\n * two. */\r\n if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )\r\n {\r\n /* This block is to be split into two. Create a new\r\n * block following the number of bytes requested. The void\r\n * cast is used to prevent byte alignment warnings from the\r\n * compiler. */\r\n pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );\r\n configASSERT( ( ( ( size_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 );\r\n\r\n /* Calculate the sizes of two blocks split from the\r\n * single block. */\r\n pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;\r\n pxBlock->xBlockSize = xWantedSize;\r\n\r\n /* Insert the new block into the list of free blocks. */\r\n prvInsertBlockIntoFreeList( pxNewBlockLink );\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n\r\n xFreeBytesRemaining -= pxBlock->xBlockSize;\r\n\r\n if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining )\r\n {\r\n xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n\r\n /* The block is being returned - it is allocated and owned\r\n * by the application and has no \"next\" block. */\r\n pxBlock->xBlockSize |= xBlockAllocatedBit;\r\n pxBlock->pxNextFreeBlock = NULL;\r\n xNumberOfSuccessfulAllocations++;\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n\r\n traceMALLOC( pvReturn, xWantedSize );\r\n }\r\n ( void ) xTaskResumeAll();\r\n\r\n #if ( configUSE_MALLOC_FAILED_HOOK == 1 )\r\n {\r\n if( pvReturn == NULL )\r\n {\r\n extern void vApplicationMallocFailedHook( void );\r\n vApplicationMallocFailedHook();\r\n }\r\n else\r\n {\r\n mtCOVERAGE_TEST_MARKER();\r\n }\r\n }\r\n #endif /* if ( configUSE_MALLOC_FAILED_HOOK == 1 ) */\r\n\r\n configASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) portBYTE_ALIGNMENT_MASK ) == 0 );\r\n return pvReturn;\r\n}\r", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-32020", "cwe_id": "CWE-119" }, { "id": 2529, "func": "static void __exit xfrm6_tunnel_fini(void)\n{\n\tunregister_pernet_subsys(&xfrm6_tunnel_net_ops);\n\txfrm6_tunnel_spi_fini();\n\txfrm6_tunnel_deregister(&xfrm46_tunnel_handler, AF_INET);\n\txfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6);\n\txfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-1768", "cwe_id": "CWE-362" }, { "id": 2529, "func": "static void __exit xfrm6_tunnel_fini(void)\n{\n\txfrm6_tunnel_deregister(&xfrm46_tunnel_handler, AF_INET);\n\txfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6);\n\txfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);\n\tunregister_pernet_subsys(&xfrm6_tunnel_net_ops);\n\tkmem_cache_destroy(xfrm6_tunnel_spi_kmem);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-1768", "cwe_id": "CWE-362" }, { "id": 2660, "func": "static int http_read_stream(URLContext *h, uint8_t *buf, int size)\n{\n HTTPContext *s = h->priv_data;\n int err, new_location, read_ret;\n int64_t seek_ret;\n\n if (!s->hd)\n return AVERROR_EOF;\n\n if (s->end_chunked_post && !s->end_header) {\n err = http_read_header(h, &new_location);\n if (err < 0)\n return err;\n }\n\n if (s->chunksize >= 0) {\n if (!s->chunksize) {\n char line[32];\n\n do {\n if ((err = http_get_line(s, line, sizeof(line))) < 0)\n return err;\n } while (!*line); /* skip CR LF from last chunk */\n\n s->chunksize = strtoll(line, NULL, 16);\n\n av_log(NULL, AV_LOG_TRACE, \"Chunked encoding data size: %\"PRId64\"'\\n\",\n s->chunksize);\n\n if (!s->chunksize)\n return 0;\n }\n size = FFMIN(size, s->chunksize);\n }\n#if CONFIG_ZLIB\n if (s->compressed)\n return http_buf_read_compressed(h, buf, size);\n#endif /* CONFIG_ZLIB */\n read_ret = http_buf_read(h, buf, size);\n if ( (read_ret < 0 && s->reconnect && (!h->is_streamed || s->reconnect_streamed) && s->filesize > 0 && s->off < s->filesize)\n || (read_ret == 0 && s->reconnect_at_eof && (!h->is_streamed || s->reconnect_streamed))) {\n int64_t target = h->is_streamed ? 0 : s->off;\n\n if (s->reconnect_delay > s->reconnect_delay_max)\n return AVERROR(EIO);\n\n av_log(h, AV_LOG_INFO, \"Will reconnect at %\"PRId64\" error=%s.\\n\", s->off, av_err2str(read_ret));\n av_usleep(1000U*1000*s->reconnect_delay);\n s->reconnect_delay = 1 + 2*s->reconnect_delay;\n seek_ret = http_seek_internal(h, target, SEEK_SET, 1);\n if (seek_ret != target) {\n av_log(h, AV_LOG_ERROR, \"Failed to reconnect at %\"PRId64\".\\n\", target);\n return read_ret;\n }\n\n read_ret = http_buf_read(h, buf, size);\n } else\n s->reconnect_delay = 0;\n\n return read_ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10190", "cwe_id": "CWE-119" }, { "id": 2660, "func": "static int http_read_stream(URLContext *h, uint8_t *buf, int size)\n{\n HTTPContext *s = h->priv_data;\n int err, new_location, read_ret;\n int64_t seek_ret;\n\n if (!s->hd)\n return AVERROR_EOF;\n\n if (s->end_chunked_post && !s->end_header) {\n err = http_read_header(h, &new_location);\n if (err < 0)\n return err;\n }\n\n if (s->chunksize != UINT64_MAX) {\n if (!s->chunksize) {\n char line[32];\n\n do {\n if ((err = http_get_line(s, line, sizeof(line))) < 0)\n return err;\n } while (!*line); /* skip CR LF from last chunk */\n\n s->chunksize = strtoull(line, NULL, 16);\n\n av_log(h, AV_LOG_TRACE,\n \"Chunked encoding data size: %\"PRIu64\"'\\n\",\n s->chunksize);\n\n if (!s->chunksize)\n return 0;\n else if (s->chunksize == UINT64_MAX) {\n av_log(h, AV_LOG_ERROR, \"Invalid chunk size %\"PRIu64\"\\n\",\n s->chunksize);\n return AVERROR(EINVAL);\n }\n }\n size = FFMIN(size, s->chunksize);\n }\n#if CONFIG_ZLIB\n if (s->compressed)\n return http_buf_read_compressed(h, buf, size);\n#endif /* CONFIG_ZLIB */\n read_ret = http_buf_read(h, buf, size);\n if ( (read_ret < 0 && s->reconnect && (!h->is_streamed || s->reconnect_streamed) && s->filesize > 0 && s->off < s->filesize)\n || (read_ret == 0 && s->reconnect_at_eof && (!h->is_streamed || s->reconnect_streamed))) {\n uint64_t target = h->is_streamed ? 0 : s->off;\n\n if (s->reconnect_delay > s->reconnect_delay_max)\n return AVERROR(EIO);\n\n av_log(h, AV_LOG_INFO, \"Will reconnect at %\"PRIu64\" error=%s.\\n\", s->off, av_err2str(read_ret));\n av_usleep(1000U*1000*s->reconnect_delay);\n s->reconnect_delay = 1 + 2*s->reconnect_delay;\n seek_ret = http_seek_internal(h, target, SEEK_SET, 1);\n if (seek_ret != target) {\n av_log(h, AV_LOG_ERROR, \"Failed to reconnect at %\"PRIu64\".\\n\", target);\n return read_ret;\n }\n\n read_ret = http_buf_read(h, buf, size);\n } else\n s->reconnect_delay = 0;\n\n return read_ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10190", "cwe_id": "CWE-119" }, { "id": 2265, "func": "static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)\n{\n\tstruct uvesafb_pal_entry *entries;\n\tint shift = 16 - dac_width;\n\tint i, err = 0;\n\n\tif (info->var.bits_per_pixel == 8) {\n\t\tif (cmap->start + cmap->len > info->cmap.start +\n\t\t info->cmap.len || cmap->start < info->cmap.start)\n\t\t\treturn -EINVAL;\n\n\t\tentries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL);\n\t\tif (!entries)\n\t\t\treturn -ENOMEM;\n\n\t\tfor (i = 0; i < cmap->len; i++) {\n\t\t\tentries[i].red = cmap->red[i] >> shift;\n\t\t\tentries[i].green = cmap->green[i] >> shift;\n\t\t\tentries[i].blue = cmap->blue[i] >> shift;\n\t\t\tentries[i].pad = 0;\n\t\t}\n\t\terr = uvesafb_setpalette(entries, cmap->len, cmap->start, info);\n\t\tkfree(entries);\n\t} else {\n\t\t/*\n\t\t * For modes with bpp > 8, we only set the pseudo palette in\n\t\t * the fb_info struct. We rely on uvesafb_setcolreg to do all\n\t\t * sanity checking.\n\t\t */\n\t\tfor (i = 0; i < cmap->len; i++) {\n\t\t\terr |= uvesafb_setcolreg(cmap->start + i, cmap->red[i],\n\t\t\t\t\t\tcmap->green[i], cmap->blue[i],\n\t\t\t\t\t\t0, info);\n\t\t}\n\t}\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-13406", "cwe_id": "CWE-190" }, { "id": 2265, "func": "static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)\n{\n\tstruct uvesafb_pal_entry *entries;\n\tint shift = 16 - dac_width;\n\tint i, err = 0;\n\n\tif (info->var.bits_per_pixel == 8) {\n\t\tif (cmap->start + cmap->len > info->cmap.start +\n\t\t info->cmap.len || cmap->start < info->cmap.start)\n\t\t\treturn -EINVAL;\n\n\t\tentries = kmalloc_array(cmap->len, sizeof(*entries),\n\t\t\t\t\tGFP_KERNEL);\n\t\tif (!entries)\n\t\t\treturn -ENOMEM;\n\n\t\tfor (i = 0; i < cmap->len; i++) {\n\t\t\tentries[i].red = cmap->red[i] >> shift;\n\t\t\tentries[i].green = cmap->green[i] >> shift;\n\t\t\tentries[i].blue = cmap->blue[i] >> shift;\n\t\t\tentries[i].pad = 0;\n\t\t}\n\t\terr = uvesafb_setpalette(entries, cmap->len, cmap->start, info);\n\t\tkfree(entries);\n\t} else {\n\t\t/*\n\t\t * For modes with bpp > 8, we only set the pseudo palette in\n\t\t * the fb_info struct. We rely on uvesafb_setcolreg to do all\n\t\t * sanity checking.\n\t\t */\n\t\tfor (i = 0; i < cmap->len; i++) {\n\t\t\terr |= uvesafb_setcolreg(cmap->start + i, cmap->red[i],\n\t\t\t\t\t\tcmap->green[i], cmap->blue[i],\n\t\t\t\t\t\t0, info);\n\t\t}\n\t}\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-13406", "cwe_id": "CWE-190" }, { "id": 1465, "func": "ast2obj_keyword(void* _o)\n{\n keyword_ty o = (keyword_ty)_o;\n PyObject *result = NULL, *value = NULL;\n if (!o) {\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n result = PyType_GenericNew(keyword_type, NULL, NULL);\n if (!result) return NULL;\n value = ast2obj_identifier(o->arg);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_expr(o->value);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)\n goto failed;\n Py_DECREF(value);\n return result;\nfailed:\n Py_XDECREF(value);\n Py_XDECREF(result);\n return NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1465, "func": "ast2obj_keyword(void* _o)\n{\n keyword_ty o = (keyword_ty)_o;\n PyObject *result = NULL, *value = NULL;\n if (!o) {\n Py_RETURN_NONE;\n }\n\n result = PyType_GenericNew(keyword_type, NULL, NULL);\n if (!result) return NULL;\n value = ast2obj_identifier(o->arg);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_expr(o->value);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)\n goto failed;\n Py_DECREF(value);\n return result;\nfailed:\n Py_XDECREF(value);\n Py_XDECREF(result);\n return NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 3151, "func": "static inline int xrstor_state(struct xsave_struct *fx, u64 mask)\n{\n\tint err = 0;\n\tu32 lmask = mask;\n\tu32 hmask = mask >> 32;\n\n\t/*\n\t * Use xrstors to restore context if it is enabled. xrstors supports\n\t * compacted format of xsave area which is not supported by xrstor.\n\t */\n\talternative_input(\n\t\t\"1: \" XRSTOR,\n\t\t\"1: \" XRSTORS,\n\t\tX86_FEATURE_XSAVES,\n\t\t\"D\" (fx), \"m\" (*fx), \"a\" (lmask), \"d\" (hmask)\n\t\t: \"memory\");\n\n\tasm volatile(\"2:\\n\"\n\t\t xstate_fault\n\t\t : \"0\" (0)\n\t\t : \"memory\");\n\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-2672", "cwe_id": "CWE-20" }, { "id": 3151, "func": "static inline int xrstor_state(struct xsave_struct *fx, u64 mask)\n{\n\tint err = 0;\n\tu32 lmask = mask;\n\tu32 hmask = mask >> 32;\n\n\t/*\n\t * Use xrstors to restore context if it is enabled. xrstors supports\n\t * compacted format of xsave area which is not supported by xrstor.\n\t */\n\talternative_input(\n\t\t\"1: \" XRSTOR,\n\t\tXRSTORS,\n\t\tX86_FEATURE_XSAVES,\n\t\t\"D\" (fx), \"m\" (*fx), \"a\" (lmask), \"d\" (hmask)\n\t\t: \"memory\");\n\n\tasm volatile(\"2:\\n\"\n\t\t xstate_fault\n\t\t : \"0\" (0)\n\t\t : \"memory\");\n\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-2672", "cwe_id": "CWE-20" }, { "id": 902, "func": "static void show_object(struct object *obj,\n\t\t\tstruct strbuf *path, const char *last,\n\t\t\tvoid *data)\n{\n\tchar *name = path_name(path, last);\n\n\tadd_preferred_base_object(name);\n\tadd_object_entry(obj->oid.hash, obj->type, name, 0);\n\tobj->flags |= OBJECT_ADDED;\n\n\t/*\n\t * We will have generated the hash from the name,\n\t * but not saved a pointer to it - we can free it\n\t */\n\tfree((char *)name);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 902, "func": "static void show_object(struct object *obj, const char *name, void *data)\n{\n\tadd_preferred_base_object(name);\n\tadd_object_entry(obj->oid.hash, obj->type, name, 0);\n\tobj->flags |= OBJECT_ADDED;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 218, "func": "zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)\n{\n\tspl_filesystem_iterator *iterator;\n\tspl_filesystem_object *dir_object;\n\n\tif (by_ref) {\n\t\tzend_error(E_ERROR, \"An iterator cannot be used with foreach by reference\");\n\t}\n\tdir_object = (spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);\n\titerator = spl_filesystem_object_to_iterator(dir_object);\n\n\t/* initialize iterator if wasn't gotten before */\n\tif (iterator->intern.data == NULL) {\n\t\titerator->intern.data = object;\n\t\titerator->intern.funcs = &spl_filesystem_tree_it_funcs;\n\t}\n\tzval_add_ref(&object);\n\t\n\treturn (zend_object_iterator*)iterator;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 218, "func": "zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)\n{\n\tspl_filesystem_iterator *iterator;\n\tspl_filesystem_object *dir_object;\n\n\tif (by_ref) {\n\t\tzend_error(E_ERROR, \"An iterator cannot be used with foreach by reference\");\n\t}\n\tdir_object = (spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);\n\titerator = spl_filesystem_object_to_iterator(dir_object);\n\n\t/* initialize iterator if wasn't gotten before */\n\tif (iterator->intern.data == NULL) {\n\t\titerator->intern.data = object;\n\t\titerator->intern.funcs = &spl_filesystem_tree_it_funcs;\n\t}\n\tzval_add_ref(&object);\n\n\treturn (zend_object_iterator*)iterator;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5770", "cwe_id": "CWE-190" }, { "id": 2919, "func": "vqp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)\n{\n const struct vqp_common_header_t *vqp_common_header;\n const struct vqp_obj_tlv_t *vqp_obj_tlv;\n\n const u_char *tptr;\n uint16_t vqp_obj_len;\n uint32_t vqp_obj_type;\n int tlen;\n uint8_t nitems;\n\n tptr=pptr;\n tlen = len;\n vqp_common_header = (const struct vqp_common_header_t *)pptr;\n ND_TCHECK(*vqp_common_header);\n\n /*\n * Sanity checking of the header.\n */\n if (VQP_EXTRACT_VERSION(vqp_common_header->version) != VQP_VERSION) {\n\tND_PRINT((ndo, \"VQP version %u packet not supported\",\n VQP_EXTRACT_VERSION(vqp_common_header->version)));\n\treturn;\n }\n\n /* in non-verbose mode just lets print the basic Message Type */\n if (ndo->ndo_vflag < 1) {\n ND_PRINT((ndo, \"VQPv%u %s Message, error-code %s (%u), length %u\",\n VQP_EXTRACT_VERSION(vqp_common_header->version),\n tok2str(vqp_msg_type_values, \"unknown (%u)\",vqp_common_header->msg_type),\n tok2str(vqp_error_code_values, \"unknown (%u)\",vqp_common_header->error_code),\n\t vqp_common_header->error_code,\n len));\n return;\n }\n\n /* ok they seem to want to know everything - lets fully decode it */\n nitems = vqp_common_header->nitems;\n ND_PRINT((ndo, \"\\n\\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u\",\n VQP_EXTRACT_VERSION(vqp_common_header->version),\n\t tok2str(vqp_msg_type_values, \"unknown (%u)\",vqp_common_header->msg_type),\n\t tok2str(vqp_error_code_values, \"unknown (%u)\",vqp_common_header->error_code),\n\t vqp_common_header->error_code,\n EXTRACT_32BITS(&vqp_common_header->sequence),\n nitems,\n len));\n\n /* skip VQP Common header */\n tptr+=sizeof(const struct vqp_common_header_t);\n tlen-=sizeof(const struct vqp_common_header_t);\n\n while (nitems > 0 && tlen > 0) {\n\n vqp_obj_tlv = (const struct vqp_obj_tlv_t *)tptr;\n vqp_obj_type = EXTRACT_32BITS(vqp_obj_tlv->obj_type);\n vqp_obj_len = EXTRACT_16BITS(vqp_obj_tlv->obj_length);\n tptr+=sizeof(struct vqp_obj_tlv_t);\n tlen-=sizeof(struct vqp_obj_tlv_t);\n\n ND_PRINT((ndo, \"\\n\\t %s Object (0x%08x), length %u, value: \",\n tok2str(vqp_obj_values, \"Unknown\", vqp_obj_type),\n vqp_obj_type, vqp_obj_len));\n\n /* basic sanity check */\n if (vqp_obj_type == 0 || vqp_obj_len ==0) {\n return;\n }\n\n /* did we capture enough for fully decoding the object ? */\n ND_TCHECK2(*tptr, vqp_obj_len);\n\n switch(vqp_obj_type) {\n\tcase VQP_OBJ_IP_ADDRESS:\n ND_PRINT((ndo, \"%s (0x%08x)\", ipaddr_string(ndo, tptr), EXTRACT_32BITS(tptr)));\n break;\n /* those objects have similar semantics - fall through */\n case VQP_OBJ_PORT_NAME:\n\tcase VQP_OBJ_VLAN_NAME:\n\tcase VQP_OBJ_VTP_DOMAIN:\n\tcase VQP_OBJ_ETHERNET_PKT:\n safeputs(ndo, tptr, vqp_obj_len);\n break;\n /* those objects have similar semantics - fall through */\n\tcase VQP_OBJ_MAC_ADDRESS:\n\tcase VQP_OBJ_MAC_NULL:\n\t ND_PRINT((ndo, \"%s\", etheraddr_string(ndo, tptr)));\n break;\n default:\n if (ndo->ndo_vflag <= 1)\n print_unknown_data(ndo,tptr, \"\\n\\t \", vqp_obj_len);\n break;\n }\n\ttptr += vqp_obj_len;\n\ttlen -= vqp_obj_len;\n\tnitems--;\n }\n return;\ntrunc:\n ND_PRINT((ndo, \"\\n\\t[|VQP]\"));\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13045", "cwe_id": "CWE-125" }, { "id": 2919, "func": "vqp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)\n{\n const struct vqp_common_header_t *vqp_common_header;\n const struct vqp_obj_tlv_t *vqp_obj_tlv;\n\n const u_char *tptr;\n uint16_t vqp_obj_len;\n uint32_t vqp_obj_type;\n u_int tlen;\n uint8_t nitems;\n\n tptr=pptr;\n tlen = len;\n vqp_common_header = (const struct vqp_common_header_t *)pptr;\n ND_TCHECK(*vqp_common_header);\n if (sizeof(struct vqp_common_header_t) > tlen)\n goto trunc;\n\n /*\n * Sanity checking of the header.\n */\n if (VQP_EXTRACT_VERSION(vqp_common_header->version) != VQP_VERSION) {\n\tND_PRINT((ndo, \"VQP version %u packet not supported\",\n VQP_EXTRACT_VERSION(vqp_common_header->version)));\n\treturn;\n }\n\n /* in non-verbose mode just lets print the basic Message Type */\n if (ndo->ndo_vflag < 1) {\n ND_PRINT((ndo, \"VQPv%u %s Message, error-code %s (%u), length %u\",\n VQP_EXTRACT_VERSION(vqp_common_header->version),\n tok2str(vqp_msg_type_values, \"unknown (%u)\",vqp_common_header->msg_type),\n tok2str(vqp_error_code_values, \"unknown (%u)\",vqp_common_header->error_code),\n\t vqp_common_header->error_code,\n len));\n return;\n }\n\n /* ok they seem to want to know everything - lets fully decode it */\n nitems = vqp_common_header->nitems;\n ND_PRINT((ndo, \"\\n\\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u\",\n VQP_EXTRACT_VERSION(vqp_common_header->version),\n\t tok2str(vqp_msg_type_values, \"unknown (%u)\",vqp_common_header->msg_type),\n\t tok2str(vqp_error_code_values, \"unknown (%u)\",vqp_common_header->error_code),\n\t vqp_common_header->error_code,\n EXTRACT_32BITS(&vqp_common_header->sequence),\n nitems,\n len));\n\n /* skip VQP Common header */\n tptr+=sizeof(const struct vqp_common_header_t);\n tlen-=sizeof(const struct vqp_common_header_t);\n\n while (nitems > 0 && tlen > 0) {\n\n vqp_obj_tlv = (const struct vqp_obj_tlv_t *)tptr;\n ND_TCHECK(*vqp_obj_tlv);\n if (sizeof(struct vqp_obj_tlv_t) > tlen)\n goto trunc;\n vqp_obj_type = EXTRACT_32BITS(vqp_obj_tlv->obj_type);\n vqp_obj_len = EXTRACT_16BITS(vqp_obj_tlv->obj_length);\n tptr+=sizeof(struct vqp_obj_tlv_t);\n tlen-=sizeof(struct vqp_obj_tlv_t);\n\n ND_PRINT((ndo, \"\\n\\t %s Object (0x%08x), length %u, value: \",\n tok2str(vqp_obj_values, \"Unknown\", vqp_obj_type),\n vqp_obj_type, vqp_obj_len));\n\n /* basic sanity check */\n if (vqp_obj_type == 0 || vqp_obj_len ==0) {\n return;\n }\n\n /* did we capture enough for fully decoding the object ? */\n ND_TCHECK2(*tptr, vqp_obj_len);\n if (vqp_obj_len > tlen)\n goto trunc;\n\n switch(vqp_obj_type) {\n\tcase VQP_OBJ_IP_ADDRESS:\n if (vqp_obj_len != 4)\n goto trunc;\n ND_PRINT((ndo, \"%s (0x%08x)\", ipaddr_string(ndo, tptr), EXTRACT_32BITS(tptr)));\n break;\n /* those objects have similar semantics - fall through */\n case VQP_OBJ_PORT_NAME:\n\tcase VQP_OBJ_VLAN_NAME:\n\tcase VQP_OBJ_VTP_DOMAIN:\n\tcase VQP_OBJ_ETHERNET_PKT:\n safeputs(ndo, tptr, vqp_obj_len);\n break;\n /* those objects have similar semantics - fall through */\n\tcase VQP_OBJ_MAC_ADDRESS:\n\tcase VQP_OBJ_MAC_NULL:\n if (vqp_obj_len != ETHER_ADDR_LEN)\n goto trunc;\n\t ND_PRINT((ndo, \"%s\", etheraddr_string(ndo, tptr)));\n break;\n default:\n if (ndo->ndo_vflag <= 1)\n print_unknown_data(ndo,tptr, \"\\n\\t \", vqp_obj_len);\n break;\n }\n\ttptr += vqp_obj_len;\n\ttlen -= vqp_obj_len;\n\tnitems--;\n }\n return;\ntrunc:\n ND_PRINT((ndo, \"\\n\\t[|VQP]\"));\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13045", "cwe_id": "CWE-125" }, { "id": 2822, "func": "R_API RBinJavaAttrInfo *r_bin_java_inner_classes_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tRBinJavaClassesAttribute *icattr;\n\tRBinJavaAttrInfo *attr = NULL;\n\tRBinJavaCPTypeObj *obj;\n\tut32 i = 0;\n\tut64 offset = 0, curpos;\n\tattr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (attr == NULL) {\n\t\t// TODO eprintf\n\t\treturn attr;\n\t}\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_INNER_CLASSES_ATTR;\n\tattr->info.inner_classes_attr.number_of_classes = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.inner_classes_attr.classes = r_list_newf (r_bin_java_inner_classes_attr_entry_free);\n\tfor (i = 0; i < attr->info.inner_classes_attr.number_of_classes; i++) {\n\t\tcurpos = buf_offset + offset;\n\t\tif (offset + 8 > sz) {\n\t\t\teprintf (\"Invalid amount of inner classes\\n\");\n\t\t\tbreak;\n\t\t}\n\t\ticattr = R_NEW0 (RBinJavaClassesAttribute);\n\t\tif (!icattr) {\n\t\t\tbreak;\n\t\t}\n\t\ticattr->inner_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->outer_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_name_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_class_access_flags = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->flags_str = retrieve_class_method_access_string (icattr->inner_class_access_flags);\n\t\ticattr->file_offset = curpos;\n\t\ticattr->size = 8;\n\n\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_name_idx);\n\t\tif (obj == NULL) {\n\t\t\teprintf (\"BINCPLIS IS HULL %d\\n\", icattr->inner_name_idx);\n\t\t}\n\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\tif (!icattr->name) {\n\t\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_class_info_idx);\n\t\t\tif (!obj) {\n\t\t\t\teprintf (\"BINCPLIST IS NULL %d\\n\", icattr->inner_class_info_idx);\n\t\t\t}\n\t\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\t\tif (!icattr->name) {\n\t\t\t\ticattr->name = r_str_dup (NULL, \"NULL\");\n\t\t\t\teprintf (\"r_bin_java_inner_classes_attr: Unable to find the name for %d index.\\n\", icattr->inner_name_idx);\n\t\t\t\tfree (icattr);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tIFDBG eprintf(\"r_bin_java_inner_classes_attr: Inner class name %d is %s.\\n\", icattr->inner_name_idx, icattr->name);\n\t\tr_list_append (attr->info.inner_classes_attr.classes, (void *) icattr);\n\t}\n\tattr->size = offset;\n\t// IFDBG r_bin_java_print_inner_classes_attr_summary(attr);\n\treturn attr;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-0518", "cwe_id": "CWE-787" }, { "id": 2822, "func": "R_API RBinJavaAttrInfo *r_bin_java_inner_classes_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tRBinJavaClassesAttribute *icattr;\n\tRBinJavaAttrInfo *attr = NULL;\n\tRBinJavaCPTypeObj *obj;\n\tut32 i = 0;\n\tut64 offset = 0, curpos;\n\tattr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (buf_offset + offset + 8 > sz) {\n\t\teprintf (\"Invalid amount of inner classes\\n\");\n\t\treturn NULL;\n\t}\n\tif (attr == NULL) {\n\t\t// TODO eprintf\n\t\treturn attr;\n\t}\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_INNER_CLASSES_ATTR;\n\tattr->info.inner_classes_attr.number_of_classes = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.inner_classes_attr.classes = r_list_newf (r_bin_java_inner_classes_attr_entry_free);\n\tfor (i = 0; i < attr->info.inner_classes_attr.number_of_classes; i++) {\n\t\tcurpos = buf_offset + offset;\n\t\tif (buf_offset + offset + 8 > sz) {\n\t\t\teprintf (\"Invalid amount of inner classes\\n\");\n\t\t\tbreak;\n\t\t}\n\t\ticattr = R_NEW0 (RBinJavaClassesAttribute);\n\t\tif (!icattr) {\n\t\t\tbreak;\n\t\t}\n\t\ticattr->inner_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->outer_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_name_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_class_access_flags = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->flags_str = retrieve_class_method_access_string (icattr->inner_class_access_flags);\n\t\ticattr->file_offset = curpos;\n\t\ticattr->size = 8;\n\n\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_name_idx);\n\t\tif (obj == NULL) {\n\t\t\teprintf (\"BINCPLIS IS HULL %d\\n\", icattr->inner_name_idx);\n\t\t}\n\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\tif (!icattr->name) {\n\t\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_class_info_idx);\n\t\t\tif (!obj) {\n\t\t\t\teprintf (\"BINCPLIST IS NULL %d\\n\", icattr->inner_class_info_idx);\n\t\t\t}\n\t\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\t\tif (!icattr->name) {\n\t\t\t\ticattr->name = r_str_dup (NULL, \"NULL\");\n\t\t\t\teprintf (\"r_bin_java_inner_classes_attr: Unable to find the name for %d index.\\n\", icattr->inner_name_idx);\n\t\t\t\tfree (icattr);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tIFDBG eprintf(\"r_bin_java_inner_classes_attr: Inner class name %d is %s.\\n\", icattr->inner_name_idx, icattr->name);\n\t\tr_list_append (attr->info.inner_classes_attr.classes, (void *) icattr);\n\t}\n\tattr->size = offset;\n\t// IFDBG r_bin_java_print_inner_classes_attr_summary(attr);\n\treturn attr;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-0518", "cwe_id": "CWE-787" }, { "id": 865, "func": "ProcessTCPHeader(tTcpIpPacketParsingResult _res, PVOID pIpHeader, ULONG len, USHORT ipHeaderSize)\n{\n ULONG tcpipDataAt;\n tTcpIpPacketParsingResult res = _res;\n tcpipDataAt = ipHeaderSize + sizeof(TCPHeader);\n res.xxpStatus = ppresXxpIncomplete;\n res.TcpUdp = ppresIsTCP;\n\n if (len >= tcpipDataAt)\n {\n TCPHeader *pTcpHeader = (TCPHeader *)RtlOffsetToPointer(pIpHeader, ipHeaderSize);\n res.xxpStatus = ppresXxpKnown;\n tcpipDataAt = ipHeaderSize + TCP_HEADER_LENGTH(pTcpHeader);\n res.XxpIpHeaderSize = tcpipDataAt;\n }\n else\n {\n DPrintf(2, (\"tcp: %d < min headers %d\\n\", len, tcpipDataAt));\n }\n return res;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-3215", "cwe_id": "CWE-20" }, { "id": 865, "func": "ProcessTCPHeader(tTcpIpPacketParsingResult _res, PVOID pIpHeader, ULONG len, USHORT ipHeaderSize)\n{\n ULONG tcpipDataAt;\n tTcpIpPacketParsingResult res = _res;\n tcpipDataAt = ipHeaderSize + sizeof(TCPHeader);\n res.TcpUdp = ppresIsTCP;\n\n if (len >= tcpipDataAt)\n {\n TCPHeader *pTcpHeader = (TCPHeader *)RtlOffsetToPointer(pIpHeader, ipHeaderSize);\n res.xxpStatus = ppresXxpKnown;\n res.xxpFull = TRUE;\n tcpipDataAt = ipHeaderSize + TCP_HEADER_LENGTH(pTcpHeader);\n res.XxpIpHeaderSize = tcpipDataAt;\n }\n else\n {\n DPrintf(2, (\"tcp: %d < min headers %d\\n\", len, tcpipDataAt));\n res.xxpFull = FALSE;\n res.xxpStatus = ppresXxpIncomplete;\n }\n return res;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-3215", "cwe_id": "CWE-20" }, { "id": 1630, "func": "static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s,\n uint32_t length)\n{\n int v, i;\n\n if (s->color_type == PNG_COLOR_TYPE_PALETTE) {\n if (length > 256 || !(s->state & PNG_PLTE))\n return AVERROR_INVALIDDATA;\n\n for (i = 0; i < length; i++) {\n v = bytestream2_get_byte(&s->gb);\n s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);\n }\n } else if (s->color_type == PNG_COLOR_TYPE_GRAY || s->color_type == PNG_COLOR_TYPE_RGB) {\n if ((s->color_type == PNG_COLOR_TYPE_GRAY && length != 2) ||\n (s->color_type == PNG_COLOR_TYPE_RGB && length != 6))\n return AVERROR_INVALIDDATA;\n\n for (i = 0; i < length / 2; i++) {\n /* only use the least significant bits */\n v = av_mod_uintp2(bytestream2_get_be16(&s->gb), s->bit_depth);\n\n if (s->bit_depth > 8)\n AV_WB16(&s->transparent_color_be[2 * i], v);\n else\n s->transparent_color_be[i] = v;\n }\n } else {\n return AVERROR_INVALIDDATA;\n }\n\n bytestream2_skip(&s->gb, 4); /* crc */\n s->has_trns = 1;\n\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7863", "cwe_id": "CWE-787" }, { "id": 1630, "func": "static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s,\n uint32_t length)\n{\n int v, i;\n\n if (!(s->state & PNG_IHDR)) {\n av_log(avctx, AV_LOG_ERROR, \"trns before IHDR\\n\");\n return AVERROR_INVALIDDATA;\n }\n\n if (s->state & PNG_IDAT) {\n av_log(avctx, AV_LOG_ERROR, \"trns after IDAT\\n\");\n return AVERROR_INVALIDDATA;\n }\n\n if (s->color_type == PNG_COLOR_TYPE_PALETTE) {\n if (length > 256 || !(s->state & PNG_PLTE))\n return AVERROR_INVALIDDATA;\n\n for (i = 0; i < length; i++) {\n v = bytestream2_get_byte(&s->gb);\n s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);\n }\n } else if (s->color_type == PNG_COLOR_TYPE_GRAY || s->color_type == PNG_COLOR_TYPE_RGB) {\n if ((s->color_type == PNG_COLOR_TYPE_GRAY && length != 2) ||\n (s->color_type == PNG_COLOR_TYPE_RGB && length != 6) ||\n s->bit_depth == 1)\n return AVERROR_INVALIDDATA;\n\n for (i = 0; i < length / 2; i++) {\n /* only use the least significant bits */\n v = av_mod_uintp2(bytestream2_get_be16(&s->gb), s->bit_depth);\n\n if (s->bit_depth > 8)\n AV_WB16(&s->transparent_color_be[2 * i], v);\n else\n s->transparent_color_be[i] = v;\n }\n } else {\n return AVERROR_INVALIDDATA;\n }\n\n bytestream2_skip(&s->gb, 4); /* crc */\n s->has_trns = 1;\n\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7863", "cwe_id": "CWE-787" }, { "id": 2552, "func": " void publish(Topic *iterator, size_t start, size_t stop, std::string_view topic, std::pair message) {\n /* If we already have 64 triggered topics make sure to drain it here */\n if (numTriggeredTopics == 64) {\n drain();\n }\n\n /* Iterate over all segments in given topic */\n for (; stop != std::string::npos; start = stop + 1) {\n stop = topic.find('/', start);\n std::string_view segment = topic.substr(start, stop - start);\n\n /* It is very important to disallow wildcards when publishing.\n * We will not catch EVERY misuse this lazy way, but enough to hinder\n * explosive recursion.\n * Terminating wildcards MAY still get triggered along the way, if for\n * instace the error is found late while iterating the topic segments. */\n if (segment.length() == 1) {\n if (segment[0] == '+' || segment[0] == '#') {\n return;\n }\n }\n\n /* Do we have a terminating wildcard child? */\n if (iterator->terminatingWildcardChild) {\n iterator->terminatingWildcardChild->messages[messageId] = message;\n\n /* Add this topic to triggered */\n if (!iterator->terminatingWildcardChild->triggered) {\n triggeredTopics[numTriggeredTopics++] = iterator->terminatingWildcardChild;\n iterator->terminatingWildcardChild->triggered = true;\n }\n }\n\n /* Do we have a wildcard child? */\n if (iterator->wildcardChild) {\n publish(iterator->wildcardChild, stop + 1, stop, topic, message);\n }\n\n std::map::iterator it = iterator->children.find(segment);\n if (it == iterator->children.end()) {\n /* Stop trying to match by exact string */\n return;\n }\n\n iterator = it->second;\n }\n\n /* If we went all the way we matched exactly */\n iterator->messages[messageId] = message;\n\n /* Add this topic to triggered */\n if (!iterator->triggered) {\n triggeredTopics[numTriggeredTopics++] = iterator;\n iterator->triggered = true;\n }\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-36406", "cwe_id": "CWE-787" }, { "id": 2552, "func": " void publish(Topic *iterator, size_t start, size_t stop, std::string_view topic, std::pair message) {\n\n /* Iterate over all segments in given topic */\n for (; stop != std::string::npos; start = stop + 1) {\n stop = topic.find('/', start);\n std::string_view segment = topic.substr(start, stop - start);\n\n /* It is very important to disallow wildcards when publishing.\n * We will not catch EVERY misuse this lazy way, but enough to hinder\n * explosive recursion.\n * Terminating wildcards MAY still get triggered along the way, if for\n * instace the error is found late while iterating the topic segments. */\n if (segment.length() == 1) {\n if (segment[0] == '+' || segment[0] == '#') {\n return;\n }\n }\n\n /* Do we have a terminating wildcard child? */\n if (iterator->terminatingWildcardChild) {\n iterator->terminatingWildcardChild->messages[messageId] = message;\n\n /* Add this topic to triggered */\n if (!iterator->terminatingWildcardChild->triggered) {\n /* If we already have 64 triggered topics make sure to drain it here */\n if (numTriggeredTopics == 64) {\n drain();\n }\n\n triggeredTopics[numTriggeredTopics++] = iterator->terminatingWildcardChild;\n iterator->terminatingWildcardChild->triggered = true;\n }\n }\n\n /* Do we have a wildcard child? */\n if (iterator->wildcardChild) {\n publish(iterator->wildcardChild, stop + 1, stop, topic, message);\n }\n\n std::map::iterator it = iterator->children.find(segment);\n if (it == iterator->children.end()) {\n /* Stop trying to match by exact string */\n return;\n }\n\n iterator = it->second;\n }\n\n /* If we went all the way we matched exactly */\n iterator->messages[messageId] = message;\n\n /* Add this topic to triggered */\n if (!iterator->triggered) {\n /* If we already have 64 triggered topics make sure to drain it here */\n if (numTriggeredTopics == 64) {\n drain();\n }\n\n triggeredTopics[numTriggeredTopics++] = iterator;\n iterator->triggered = true;\n }\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-36406", "cwe_id": "CWE-787" }, { "id": 1942, "func": "\nstatic SDL_Surface *Create_Surface_Blended(int width, int height, SDL_Color fg, Uint32 *color)\n{\n const int alignment = Get_Alignement() - 1;\n SDL_Surface *textbuf = NULL;\n Uint32 bgcolor;\n\n /* Background color */\n bgcolor = (fg.r << 16) | (fg.g << 8) | fg.b;\n\n /* Underline/Strikethrough color style */\n *color = bgcolor | (fg.a << 24);\n\n /* Create the target surface if required */\n if (width != 0) {\n /* Create a surface with memory:\n * - pitch is rounded to alignment\n * - adress is aligned\n */\n Sint64 size;\n void *pixels, *ptr;\n /* Worse case at the end of line pulling 'alignment' extra blank pixels */\n Sint64 pitch = (width + alignment) * 4;\n pitch += alignment;\n pitch &= ~alignment;\n size = height * pitch + sizeof (void *) + alignment;\n if (size < 0 || size > SDL_MAX_SINT32) {\n /* Overflow... */\n return NULL;\n }\n\n ptr = SDL_malloc((size_t)size);\n if (ptr == NULL) {\n return NULL;\n }\n\n /* address is aligned */\n pixels = (void *)(((uintptr_t)ptr + sizeof(void *) + alignment) & ~alignment);\n ((void **)pixels)[-1] = ptr;\n\n textbuf = SDL_CreateRGBSurfaceWithFormatFrom(pixels, width, height, 0, pitch, SDL_PIXELFORMAT_ARGB8888);\n if (textbuf == NULL) {\n SDL_free(ptr);\n return NULL;\n }\n\n /* Let SDL handle the memory allocation */\n textbuf->flags &= ~SDL_PREALLOC;\n textbuf->flags |= SDL_SIMD_ALIGNED;\n\n /* Initialize with fg and 0 alpha */\n SDL_memset4(pixels, bgcolor, (height * pitch) / 4);\n\n /* Support alpha blending */\n if (fg.a != SDL_ALPHA_OPAQUE) {\n SDL_SetSurfaceBlendMode(textbuf, SDL_BLENDMODE_BLEND);\n }\n }\n\n return textbuf;", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-27470", "cwe_id": "CWE-787" }, { "id": 1942, "func": "\nstatic SDL_Surface *Create_Surface_Blended(int width, int height, SDL_Color fg, Uint32 *color)\n{\n const int alignment = Get_Alignement() - 1;\n SDL_Surface *textbuf = NULL;\n Uint32 bgcolor;\n\n /* Background color */\n bgcolor = (fg.r << 16) | (fg.g << 8) | fg.b;\n\n /* Underline/Strikethrough color style */\n *color = bgcolor | (fg.a << 24);\n\n /* Create the target surface if required */\n if (width != 0) {\n /* Create a surface with memory:\n * - pitch is rounded to alignment\n * - adress is aligned\n */\n Sint64 size;\n void *pixels, *ptr;\n /* Worse case at the end of line pulling 'alignment' extra blank pixels */\n Sint64 pitch = ((Sint64)width + (Sint64)alignment) * 4;\n pitch += alignment;\n pitch &= ~alignment;\n size = height * pitch + sizeof (void *) + alignment;\n if (size < 0 || size > SDL_MAX_SINT32) {\n /* Overflow... */\n return NULL;\n }\n\n ptr = SDL_malloc((size_t)size);\n if (ptr == NULL) {\n return NULL;\n }\n\n /* address is aligned */\n pixels = (void *)(((uintptr_t)ptr + sizeof(void *) + alignment) & ~alignment);\n ((void **)pixels)[-1] = ptr;\n\n textbuf = SDL_CreateRGBSurfaceWithFormatFrom(pixels, width, height, 0, pitch, SDL_PIXELFORMAT_ARGB8888);\n if (textbuf == NULL) {\n SDL_free(ptr);\n return NULL;\n }\n\n /* Let SDL handle the memory allocation */\n textbuf->flags &= ~SDL_PREALLOC;\n textbuf->flags |= SDL_SIMD_ALIGNED;\n\n /* Initialize with fg and 0 alpha */\n SDL_memset4(pixels, bgcolor, (height * pitch) / 4);\n\n /* Support alpha blending */\n if (fg.a != SDL_ALPHA_OPAQUE) {\n SDL_SetSurfaceBlendMode(textbuf, SDL_BLENDMODE_BLEND);\n }\n }\n\n return textbuf;", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-27470", "cwe_id": "CWE-787" }, { "id": 3101, "func": "GF_Err latm_dmx_process(GF_Filter *filter)\n{\n\tGF_LATMDmxCtx *ctx = gf_filter_get_udta(filter);\n\tGF_FilterPacket *pck, *dst_pck;\n\tu32 pos;\n\tu8 *data, *output;\n\tu32 pck_size, prev_pck_size;\n\tu64 cts = GF_FILTER_NO_TS;\n\n\tif (ctx->in_error)\n\t\treturn ctx->in_error;\n\n\t//always reparse duration\n\tif (!ctx->duration.num)\n\t\tlatm_dmx_check_dur(filter, ctx);\n\n\tif (ctx->opid && !ctx->is_playing)\n\t\treturn GF_OK;\n\n\tpck = gf_filter_pid_get_packet(ctx->ipid);\n\tif (!pck) {\n\t\tif (gf_filter_pid_is_eos(ctx->ipid)) {\n\t\t\tif (!ctx->latm_buffer_size) {\n\t\t\t\tif (ctx->opid)\n\t\t\t\t\tgf_filter_pid_set_eos(ctx->opid);\n\t\t\t\tif (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);\n\t\t\t\tctx->src_pck = NULL;\n\t\t\t\treturn GF_EOS;\n\t\t\t}\n\t\t} else {\n\t\t\treturn GF_OK;\n\t\t}\n\t}\n\n\tdata = (char *) gf_filter_pck_get_data(pck, &pck_size);\n\n\t//input pid sets some timescale - we flushed pending data , update cts\n\tif (ctx->timescale && pck) {\n\t\tcts = gf_filter_pck_get_cts(pck);\n\t}\n\n\tprev_pck_size = ctx->latm_buffer_size;\n\n\tif (pck && !ctx->resume_from) {\n\t\tif (ctx->latm_buffer_size + pck_size > ctx->latm_buffer_alloc) {\n\t\t\tctx->latm_buffer_alloc = ctx->latm_buffer_size + pck_size;\n\t\t\tctx->latm_buffer = gf_realloc(ctx->latm_buffer, ctx->latm_buffer_alloc);\n\t\t}\n\t\tmemcpy(ctx->latm_buffer + ctx->latm_buffer_size, data, pck_size);\n\t\tctx->latm_buffer_size += pck_size;\n\t}\n\n\tif (!ctx->bs) ctx->bs = gf_bs_new(ctx->latm_buffer, ctx->latm_buffer_size, GF_BITSTREAM_READ);\n\telse gf_bs_reassign_buffer(ctx->bs, ctx->latm_buffer, ctx->latm_buffer_size);\n\n\tif (ctx->resume_from) {\n\t\tgf_bs_seek(ctx->bs, ctx->resume_from-1);\n\t\tctx->resume_from = 0;\n\t}\n\n\tif (cts == GF_FILTER_NO_TS)\n\t\tprev_pck_size = 0;\n\n\n\twhile (1) {\n\t\tpos = (u32) gf_bs_get_position(ctx->bs);\n\t\tu8 latm_buffer[4096];\n\t\tu32 latm_frame_size = 4096;\n\t\tif (!latm_dmx_sync_frame_bs(ctx->bs,&ctx->acfg, &latm_frame_size, latm_buffer, NULL)) break;\n\n\t\tif (ctx->in_seek) {\n\t\t\tu64 nb_samples_at_seek = (u64) (ctx->start_range * GF_M4ASampleRates[ctx->sr_idx]);\n\t\t\tif (ctx->cts + ctx->dts_inc >= nb_samples_at_seek) {\n\t\t\t\t//u32 samples_to_discard = (ctx->cts + ctx->dts_inc) - nb_samples_at_seek;\n\t\t\t\tctx->in_seek = GF_FALSE;\n\t\t\t}\n\t\t}\n\n\t\tlatm_dmx_check_pid(filter, ctx);\n\n\t\tif (!ctx->is_playing) {\n\t\t\tctx->resume_from = pos+1;\n\t\t\treturn GF_OK;\n\t\t}\n\n\t\tif (!ctx->in_seek) {\n\t\t\tGF_FilterSAPType sap = GF_FILTER_SAP_1;\n\n\t\t\tdst_pck = gf_filter_pck_new_alloc(ctx->opid, latm_frame_size, &output);\n\t\t\tif (ctx->src_pck) gf_filter_pck_merge_properties(ctx->src_pck, dst_pck);\n\n\t\t\tmemcpy(output, latm_buffer, latm_frame_size);\n\n\t\t\tgf_filter_pck_set_cts(dst_pck, ctx->cts);\n\t\t\tgf_filter_pck_set_duration(dst_pck, ctx->dts_inc);\n\t\t\tgf_filter_pck_set_framing(dst_pck, GF_TRUE, GF_TRUE);\n\n\t\t\t/*xHE-AAC, check RAP*/\n\t\t\tif (ctx->acfg.base_object_type==GF_CODECID_USAC) {\n\t\t\t\tif (latm_frame_size && (output[0] & 0x80) && !ctx->prev_sap) {\n\t\t\t\t\tsap = GF_FILTER_SAP_1;\n\t\t\t\t\tctx->prev_sap = GF_TRUE;\n\t\t\t\t} else {\n\t\t\t\t\tsap = GF_FILTER_SAP_NONE;\n\t\t\t\t\tctx->prev_sap = GF_FALSE;\n\t\t\t\t}\n\t\t\t}\n\t\t\tgf_filter_pck_set_sap(dst_pck, sap);\n\n\t\t\tgf_filter_pck_send(dst_pck);\n\t\t}\n\t\tlatm_dmx_update_cts(ctx);\n\n\t\tif (prev_pck_size) {\n\t\t\tpos = (u32) gf_bs_get_position(ctx->bs);\n\t\t\tif (prev_pck_size<=pos) {\n\t\t\t\tprev_pck_size=0;\n\t\t\t\tif (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);\n\t\t\t\tctx->src_pck = pck;\n\t\t\t\tif (pck)\n\t\t\t\t\tgf_filter_pck_ref_props(&ctx->src_pck);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (pck) {\n\t\tpos = (u32) gf_bs_get_position(ctx->bs);\n\t\tassert(ctx->latm_buffer_size >= pos);\n\t\tmemmove(ctx->latm_buffer, ctx->latm_buffer+pos, ctx->latm_buffer_size - pos);\n\t\tctx->latm_buffer_size -= pos;\n\t\tgf_filter_pid_drop_packet(ctx->ipid);\n\t\tassert(!ctx->resume_from);\n\t} else {\n\t\tctx->latm_buffer_size = 0;\n\t\treturn latm_dmx_process(filter);\n\t}\n\treturn GF_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-30199", "cwe_id": "CWE-476" }, { "id": 3101, "func": "GF_Err latm_dmx_process(GF_Filter *filter)\n{\n\tGF_LATMDmxCtx *ctx = gf_filter_get_udta(filter);\n\tGF_FilterPacket *pck, *dst_pck;\n\tu32 pos;\n\tu8 *data=NULL, *output;\n\tu32 pck_size=0, prev_pck_size;\n\tu64 cts = GF_FILTER_NO_TS;\n\n\tif (ctx->in_error)\n\t\treturn ctx->in_error;\n\n\t//always reparse duration\n\tif (!ctx->duration.num)\n\t\tlatm_dmx_check_dur(filter, ctx);\n\n\tif (ctx->opid && !ctx->is_playing)\n\t\treturn GF_OK;\n\n\tpck = gf_filter_pid_get_packet(ctx->ipid);\n\tif (!pck) {\n\t\tif (gf_filter_pid_is_eos(ctx->ipid)) {\n\t\t\tif (!ctx->latm_buffer_size) {\n\t\t\t\tif (ctx->opid)\n\t\t\t\t\tgf_filter_pid_set_eos(ctx->opid);\n\t\t\t\tif (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);\n\t\t\t\tctx->src_pck = NULL;\n\t\t\t\treturn GF_EOS;\n\t\t\t}\n\t\t} else {\n\t\t\treturn GF_OK;\n\t\t}\n\t} else {\n\t\tdata = (char *) gf_filter_pck_get_data(pck, &pck_size);\n\t}\n\n\t//input pid sets some timescale - we flushed pending data , update cts\n\tif (ctx->timescale && pck) {\n\t\tcts = gf_filter_pck_get_cts(pck);\n\t}\n\n\tprev_pck_size = ctx->latm_buffer_size;\n\n\tif (pck && !ctx->resume_from) {\n\t\tif (ctx->latm_buffer_size + pck_size > ctx->latm_buffer_alloc) {\n\t\t\tctx->latm_buffer_alloc = ctx->latm_buffer_size + pck_size;\n\t\t\tctx->latm_buffer = gf_realloc(ctx->latm_buffer, ctx->latm_buffer_alloc);\n\t\t}\n\t\tmemcpy(ctx->latm_buffer + ctx->latm_buffer_size, data, pck_size);\n\t\tctx->latm_buffer_size += pck_size;\n\t}\n\n\tif (!ctx->bs) ctx->bs = gf_bs_new(ctx->latm_buffer, ctx->latm_buffer_size, GF_BITSTREAM_READ);\n\telse gf_bs_reassign_buffer(ctx->bs, ctx->latm_buffer, ctx->latm_buffer_size);\n\n\tif (ctx->resume_from) {\n\t\tgf_bs_seek(ctx->bs, ctx->resume_from-1);\n\t\tctx->resume_from = 0;\n\t}\n\n\tif (cts == GF_FILTER_NO_TS)\n\t\tprev_pck_size = 0;\n\n\n\twhile (1) {\n\t\tpos = (u32) gf_bs_get_position(ctx->bs);\n\t\tu8 latm_buffer[4096];\n\t\tu32 latm_frame_size = 4096;\n\t\tif (!latm_dmx_sync_frame_bs(ctx->bs,&ctx->acfg, &latm_frame_size, latm_buffer, NULL)) break;\n\n\t\tif (ctx->in_seek) {\n\t\t\tu64 nb_samples_at_seek = (u64) (ctx->start_range * GF_M4ASampleRates[ctx->sr_idx]);\n\t\t\tif (ctx->cts + ctx->dts_inc >= nb_samples_at_seek) {\n\t\t\t\t//u32 samples_to_discard = (ctx->cts + ctx->dts_inc) - nb_samples_at_seek;\n\t\t\t\tctx->in_seek = GF_FALSE;\n\t\t\t}\n\t\t}\n\n\t\tlatm_dmx_check_pid(filter, ctx);\n\n\t\tif (!ctx->is_playing) {\n\t\t\tctx->resume_from = pos+1;\n\t\t\treturn GF_OK;\n\t\t}\n\n\t\tif (!ctx->in_seek) {\n\t\t\tGF_FilterSAPType sap = GF_FILTER_SAP_1;\n\n\t\t\tdst_pck = gf_filter_pck_new_alloc(ctx->opid, latm_frame_size, &output);\n\t\t\tif (ctx->src_pck) gf_filter_pck_merge_properties(ctx->src_pck, dst_pck);\n\n\t\t\tmemcpy(output, latm_buffer, latm_frame_size);\n\n\t\t\tgf_filter_pck_set_cts(dst_pck, ctx->cts);\n\t\t\tgf_filter_pck_set_duration(dst_pck, ctx->dts_inc);\n\t\t\tgf_filter_pck_set_framing(dst_pck, GF_TRUE, GF_TRUE);\n\n\t\t\t/*xHE-AAC, check RAP*/\n\t\t\tif (ctx->acfg.base_object_type==GF_CODECID_USAC) {\n\t\t\t\tif (latm_frame_size && (output[0] & 0x80) && !ctx->prev_sap) {\n\t\t\t\t\tsap = GF_FILTER_SAP_1;\n\t\t\t\t\tctx->prev_sap = GF_TRUE;\n\t\t\t\t} else {\n\t\t\t\t\tsap = GF_FILTER_SAP_NONE;\n\t\t\t\t\tctx->prev_sap = GF_FALSE;\n\t\t\t\t}\n\t\t\t}\n\t\t\tgf_filter_pck_set_sap(dst_pck, sap);\n\n\t\t\tgf_filter_pck_send(dst_pck);\n\t\t}\n\t\tlatm_dmx_update_cts(ctx);\n\n\t\tif (prev_pck_size) {\n\t\t\tpos = (u32) gf_bs_get_position(ctx->bs);\n\t\t\tif (prev_pck_size<=pos) {\n\t\t\t\tprev_pck_size=0;\n\t\t\t\tif (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);\n\t\t\t\tctx->src_pck = pck;\n\t\t\t\tif (pck)\n\t\t\t\t\tgf_filter_pck_ref_props(&ctx->src_pck);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (pck) {\n\t\tpos = (u32) gf_bs_get_position(ctx->bs);\n\t\tassert(ctx->latm_buffer_size >= pos);\n\t\tmemmove(ctx->latm_buffer, ctx->latm_buffer+pos, ctx->latm_buffer_size - pos);\n\t\tctx->latm_buffer_size -= pos;\n\t\tgf_filter_pid_drop_packet(ctx->ipid);\n\t\tassert(!ctx->resume_from);\n\t} else {\n\t\tctx->latm_buffer_size = 0;\n\t\treturn latm_dmx_process(filter);\n\t}\n\treturn GF_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-30199", "cwe_id": "CWE-476" }, { "id": 1378, "func": "GF_Err urn_Read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i, to_read;\n\tchar *tmpName;\n\tGF_DataEntryURNBox *ptr = (GF_DataEntryURNBox *)s;\n\tif (! ptr->size ) return GF_OK;\n\n\t//here we have to handle that in a clever way\n\tto_read = (u32) ptr->size;\n\ttmpName = (char*)gf_malloc(sizeof(char) * to_read);\n\tif (!tmpName) return GF_OUT_OF_MEM;\n\t//get the data\n\tgf_bs_read_data(bs, tmpName, to_read);\n\n\t//then get the break\n\ti = 0;\n\twhile ( (tmpName[i] != 0) && (i < to_read) ) {\n\t\ti++;\n\t}\n\t//check the data is consistent\n\tif (i == to_read) {\n\t\tgf_free(tmpName);\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\t//no NULL char, URL is not specified\n\tif (i == to_read - 1) {\n\t\tptr->nameURN = tmpName;\n\t\tptr->location = NULL;\n\t\treturn GF_OK;\n\t}\n\t//OK, this has both URN and URL\n\tptr->nameURN = (char*)gf_malloc(sizeof(char) * (i+1));\n\tif (!ptr->nameURN) {\n\t\tgf_free(tmpName);\n\t\treturn GF_OUT_OF_MEM;\n\t}\n\tptr->location = (char*)gf_malloc(sizeof(char) * (to_read - i - 1));\n\tif (!ptr->location) {\n\t\tgf_free(tmpName);\n\t\tgf_free(ptr->nameURN);\n\t\tptr->nameURN = NULL;\n\t\treturn GF_OUT_OF_MEM;\n\t}\n\tmemcpy(ptr->nameURN, tmpName, i + 1);\n\tmemcpy(ptr->location, tmpName + i + 1, (to_read - i - 1));\n\tgf_free(tmpName);\n\treturn GF_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-13006", "cwe_id": "CWE-125" }, { "id": 1378, "func": "GF_Err urn_Read(GF_Box *s, GF_BitStream *bs)\n{\n\tu32 i, to_read;\n\tchar *tmpName;\n\tGF_DataEntryURNBox *ptr = (GF_DataEntryURNBox *)s;\n\tif (! ptr->size ) return GF_OK;\n\n\t//here we have to handle that in a clever way\n\tto_read = (u32) ptr->size;\n\ttmpName = (char*)gf_malloc(sizeof(char) * to_read);\n\tif (!tmpName) return GF_OUT_OF_MEM;\n\t//get the data\n\tgf_bs_read_data(bs, tmpName, to_read);\n\n\t//then get the break\n\ti = 0;\n\twhile ( (i < to_read) && (tmpName[i] != 0) ) {\n\t\ti++;\n\t}\n\t//check the data is consistent\n\tif (i == to_read) {\n\t\tgf_free(tmpName);\n\t\treturn GF_ISOM_INVALID_FILE;\n\t}\n\t//no NULL char, URL is not specified\n\tif (i == to_read - 1) {\n\t\tptr->nameURN = tmpName;\n\t\tptr->location = NULL;\n\t\treturn GF_OK;\n\t}\n\t//OK, this has both URN and URL\n\tptr->nameURN = (char*)gf_malloc(sizeof(char) * (i+1));\n\tif (!ptr->nameURN) {\n\t\tgf_free(tmpName);\n\t\treturn GF_OUT_OF_MEM;\n\t}\n\tptr->location = (char*)gf_malloc(sizeof(char) * (to_read - i - 1));\n\tif (!ptr->location) {\n\t\tgf_free(tmpName);\n\t\tgf_free(ptr->nameURN);\n\t\tptr->nameURN = NULL;\n\t\treturn GF_OUT_OF_MEM;\n\t}\n\tmemcpy(ptr->nameURN, tmpName, i + 1);\n\tmemcpy(ptr->location, tmpName + i + 1, (to_read - i - 1));\n\tgf_free(tmpName);\n\treturn GF_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-13006", "cwe_id": "CWE-125" }, { "id": 3201, "func": "gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)\n{\n\tTIFF* tif = img->tif;\n\ttileSeparateRoutine put = img->put.separate;\n\tunsigned char *buf = NULL;\n\tunsigned char *p0 = NULL, *p1 = NULL, *p2 = NULL, *pa = NULL;\n\tuint32 row, y, nrow, rowstoread;\n\ttmsize_t pos;\n\ttmsize_t scanline;\n\tuint32 rowsperstrip, offset_row;\n\tuint32 imagewidth = img->width;\n\ttmsize_t stripsize;\n\ttmsize_t bufsize;\n\tint32 fromskew, toskew;\n\tint alpha = img->alpha;\n\tint ret = 1, flip;\n uint16 colorchannels;\n\n\tstripsize = TIFFStripSize(tif); \n\tbufsize = _TIFFMultiplySSize(tif,alpha?4:3,stripsize, \"gtStripSeparate\");\n\tif (bufsize == 0) {\n\t\treturn (0);\n\t}\n\n\tflip = setorientation(img);\n\tif (flip & FLIP_VERTICALLY) {\n\t\ty = h - 1;\n\t\ttoskew = -(int32)(w + w);\n\t}\n\telse {\n\t\ty = 0;\n\t\ttoskew = -(int32)(w - w);\n\t}\n\n switch( img->photometric )\n {\n case PHOTOMETRIC_MINISWHITE:\n case PHOTOMETRIC_MINISBLACK:\n case PHOTOMETRIC_PALETTE:\n colorchannels = 1;\n break;\n\n default:\n colorchannels = 3;\n break;\n }\n\n\tTIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);\n\tscanline = TIFFScanlineSize(tif); \n\tfromskew = (w < imagewidth ? imagewidth - w : 0);\n\tfor (row = 0; row < h; row += nrow)\n\t{\n\t\trowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip;\n\t\tnrow = (row + rowstoread > h ? h - row : rowstoread);\n\t\toffset_row = row + img->row_offset;\n if( buf == NULL )\n {\n if (_TIFFReadEncodedStripAndAllocBuffer(\n tif, TIFFComputeStrip(tif, offset_row, 0),\n (void**) &buf, bufsize,\n ((row + img->row_offset)%rowsperstrip + nrow) * scanline)==(tmsize_t)(-1)\n && (buf == NULL || img->stoponerr))\n {\n ret = 0;\n break;\n }\n p0 = buf;\n if( colorchannels == 1 )\n {\n p2 = p1 = p0;\n pa = (alpha?(p0+3*stripsize):NULL);\n }\n else\n {\n p1 = p0 + stripsize;\n p2 = p1 + stripsize;\n pa = (alpha?(p2+stripsize):NULL);\n }\n }\n\t\telse if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0),\n\t\t p0, ((row + img->row_offset)%rowsperstrip + nrow) * scanline)==(tmsize_t)(-1)\n\t\t && img->stoponerr)\n\t\t{\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\t\tif (colorchannels > 1 \n && TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1),\n p1, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) == (tmsize_t)(-1)\n\t\t && img->stoponerr)\n\t\t{\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\t\tif (colorchannels > 1 \n && TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2),\n p2, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) == (tmsize_t)(-1)\n\t\t && img->stoponerr)\n\t\t{\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\t\tif (alpha)\n\t\t{\n\t\t\tif (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, colorchannels),\n\t\t\t pa, ((row + img->row_offset)%rowsperstrip + nrow) * scanline)==(tmsize_t)(-1)\n\t\t\t && img->stoponerr)\n\t\t\t{\n\t\t\t\tret = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tpos = ((row + img->row_offset) % rowsperstrip) * scanline + \\\n\t\t\t((tmsize_t) img->col_offset * img->samplesperpixel);\n\t\t(*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, p0 + pos, p1 + pos,\n\t\t p2 + pos, (alpha?(pa+pos):NULL));\n\t\ty += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow);\n\t}\n\n\tif (flip & FLIP_HORIZONTALLY) {\n\t\tuint32 line;\n\n\t\tfor (line = 0; line < h; line++) {\n\t\t\tuint32 *left = raster + (line * w);\n\t\t\tuint32 *right = left + w - 1;\n\n\t\t\twhile ( left < right ) {\n\t\t\t\tuint32 temp = *left;\n\t\t\t\t*left = *right;\n\t\t\t\t*right = temp;\n\t\t\t\tleft++;\n\t\t\t\tright--;\n\t\t\t}\n\t\t}\n\t}\n\n\t_TIFFfree(buf);\n\treturn (ret);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-17546", "cwe_id": "CWE-787" }, { "id": 3201, "func": "gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)\n{\n\tTIFF* tif = img->tif;\n\ttileSeparateRoutine put = img->put.separate;\n\tunsigned char *buf = NULL;\n\tunsigned char *p0 = NULL, *p1 = NULL, *p2 = NULL, *pa = NULL;\n\tuint32 row, y, nrow, rowstoread;\n\ttmsize_t pos;\n\ttmsize_t scanline;\n\tuint32 rowsperstrip, offset_row;\n\tuint32 imagewidth = img->width;\n\ttmsize_t stripsize;\n\ttmsize_t bufsize;\n\tint32 fromskew, toskew;\n\tint alpha = img->alpha;\n\tint ret = 1, flip;\n uint16 colorchannels;\n\n\tstripsize = TIFFStripSize(tif); \n\tbufsize = _TIFFMultiplySSize(tif,alpha?4:3,stripsize, \"gtStripSeparate\");\n\tif (bufsize == 0) {\n\t\treturn (0);\n\t}\n\n\tflip = setorientation(img);\n\tif (flip & FLIP_VERTICALLY) {\n\t\ty = h - 1;\n\t\ttoskew = -(int32)(w + w);\n\t}\n\telse {\n\t\ty = 0;\n\t\ttoskew = -(int32)(w - w);\n\t}\n\n switch( img->photometric )\n {\n case PHOTOMETRIC_MINISWHITE:\n case PHOTOMETRIC_MINISBLACK:\n case PHOTOMETRIC_PALETTE:\n colorchannels = 1;\n break;\n\n default:\n colorchannels = 3;\n break;\n }\n\n\tTIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);\n\tscanline = TIFFScanlineSize(tif); \n\tfromskew = (w < imagewidth ? imagewidth - w : 0);\n\tfor (row = 0; row < h; row += nrow)\n\t{\n uint32 temp;\n\t\trowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip;\n\t\tnrow = (row + rowstoread > h ? h - row : rowstoread);\n\t\toffset_row = row + img->row_offset;\n temp = (row + img->row_offset)%rowsperstrip + nrow;\n if( scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline) )\n {\n TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), \"Integer overflow in gtStripSeparate\");\n return 0;\n }\n if( buf == NULL )\n {\n if (_TIFFReadEncodedStripAndAllocBuffer(\n tif, TIFFComputeStrip(tif, offset_row, 0),\n (void**) &buf, bufsize,\n temp * scanline)==(tmsize_t)(-1)\n && (buf == NULL || img->stoponerr))\n {\n ret = 0;\n break;\n }\n p0 = buf;\n if( colorchannels == 1 )\n {\n p2 = p1 = p0;\n pa = (alpha?(p0+3*stripsize):NULL);\n }\n else\n {\n p1 = p0 + stripsize;\n p2 = p1 + stripsize;\n pa = (alpha?(p2+stripsize):NULL);\n }\n }\n\t\telse if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0),\n\t\t p0, temp * scanline)==(tmsize_t)(-1)\n\t\t && img->stoponerr)\n\t\t{\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\t\tif (colorchannels > 1 \n && TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1),\n p1, temp * scanline) == (tmsize_t)(-1)\n\t\t && img->stoponerr)\n\t\t{\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\t\tif (colorchannels > 1 \n && TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2),\n p2, temp * scanline) == (tmsize_t)(-1)\n\t\t && img->stoponerr)\n\t\t{\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\t\tif (alpha)\n\t\t{\n\t\t\tif (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, colorchannels),\n\t\t\t pa, temp * scanline)==(tmsize_t)(-1)\n\t\t\t && img->stoponerr)\n\t\t\t{\n\t\t\t\tret = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tpos = ((row + img->row_offset) % rowsperstrip) * scanline + \\\n\t\t\t((tmsize_t) img->col_offset * img->samplesperpixel);\n\t\t(*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, p0 + pos, p1 + pos,\n\t\t p2 + pos, (alpha?(pa+pos):NULL));\n\t\ty += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow);\n\t}\n\n\tif (flip & FLIP_HORIZONTALLY) {\n\t\tuint32 line;\n\n\t\tfor (line = 0; line < h; line++) {\n\t\t\tuint32 *left = raster + (line * w);\n\t\t\tuint32 *right = left + w - 1;\n\n\t\t\twhile ( left < right ) {\n\t\t\t\tuint32 temp = *left;\n\t\t\t\t*left = *right;\n\t\t\t\t*right = temp;\n\t\t\t\tleft++;\n\t\t\t\tright--;\n\t\t\t}\n\t\t}\n\t}\n\n\t_TIFFfree(buf);\n\treturn (ret);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-17546", "cwe_id": "CWE-787" }, { "id": 576, "func": "static inline int map_from_unicode(unsigned code, enum entity_charset charset, unsigned *res)\n{\n\tunsigned char found;\n\tconst uni_to_enc *table;\n\tsize_t table_size;\n\n\tswitch (charset) {\n\tcase cs_8859_1:\n\t\t/* identity mapping of code points to unicode */\n\t\tif (code > 0xFF) {\n\t\t\treturn FAILURE;\n\t\t} \n\t\t*res = code;\n\t\tbreak;\n\n\tcase cs_8859_5:\n\t\tif (code <= 0xA0 || code == 0xAD /* soft hyphen */) {\n\t\t\t*res = code;\n\t\t} else if (code == 0x2116) {\n\t\t\t*res = 0xF0; /* numero sign */\n\t\t} else if (code == 0xA7) {\n\t\t\t*res = 0xFD; /* section sign */\n\t\t} else if (code >= 0x0401 && code <= 0x044F) {\n\t\t\tif (code == 0x040D || code == 0x0450 || code == 0x045D)\n\t\t\t\treturn FAILURE;\n\t\t\t*res = code - 0x360;\n\t\t} else {\n\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\t\t\n\tcase cs_8859_15:\n\t\tif (code < 0xA4 || (code > 0xBE && code <= 0xFF)) {\n\t\t\t*res = code;\n\t\t} else { /* between A4 and 0xBE */\n\t\t\tfound = unimap_bsearch(unimap_iso885915,\n\t\t\t\tcode, sizeof(unimap_iso885915) / sizeof(*unimap_iso885915));\n\t\t\tif (found)\n\t\t\t\t*res = found;\n\t\t\telse\n\t\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\tcase cs_cp1252:\n\t\tif (code <= 0x7F || (code >= 0xA0 && code <= 0xFF)) {\n\t\t\t*res = code;\n\t\t} else {\n\t\t\tfound = unimap_bsearch(unimap_win1252,\n\t\t\t\tcode, sizeof(unimap_win1252) / sizeof(*unimap_win1252));\n\t\t\tif (found)\n\t\t\t\t*res = found;\n\t\t\telse\n\t\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\tcase cs_macroman:\n\t\tif (code == 0x7F)\n\t\t\treturn FAILURE;\n\t\ttable = unimap_macroman;\n\t\ttable_size = sizeof(unimap_macroman) / sizeof(*unimap_macroman);\n\t\tgoto table_over_7F;\n\tcase cs_cp1251:\n\t\ttable = unimap_win1251;\n\t\ttable_size = sizeof(unimap_win1251) / sizeof(*unimap_win1251);\n\t\tgoto table_over_7F;\n\tcase cs_koi8r:\n\t\ttable = unimap_koi8r;\n\t\ttable_size = sizeof(unimap_koi8r) / sizeof(*unimap_koi8r);\n\t\tgoto table_over_7F;\n\tcase cs_cp866:\n\t\ttable = unimap_cp866;\n\t\ttable_size = sizeof(unimap_cp866) / sizeof(*unimap_cp866);\n\t\t\ntable_over_7F:\n\t\tif (code <= 0x7F) {\n\t\t\t*res = code;\n\t\t} else {\n\t\t\tfound = unimap_bsearch(table, code, table_size);\n\t\t\tif (found)\n\t\t\t\t*res = found;\n\t\t\telse\n\t\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\t/* from here on, only map the possible characters in the ASCII range.\n\t * to improve support here, it's a matter of building the unicode mappings.\n\t * See */\n\tcase cs_sjis:\n\tcase cs_eucjp:\n\t\t/* we interpret 0x5C as the Yen symbol. This is not universal.\n\t\t * See */\n\t\tif (code >= 0x20 && code <= 0x7D) {\n\t\t\tif (code == 0x5C)\n\t\t\t\treturn FAILURE;\n\t\t\t*res = code;\n\t\t} else {\n\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\tcase cs_big5:\n\tcase cs_big5hkscs:\n\tcase cs_gb2312:\n\t\tif (code >= 0x20 && code <= 0x7D) {\n\t\t\t*res = code;\n\t\t} else {\n\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\treturn FAILURE;\n\t}\n\n\treturn SUCCESS;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5094", "cwe_id": "CWE-190" }, { "id": 576, "func": "static inline int map_from_unicode(unsigned code, enum entity_charset charset, unsigned *res)\n{\n\tunsigned char found;\n\tconst uni_to_enc *table;\n\tsize_t table_size;\n\n\tswitch (charset) {\n\tcase cs_8859_1:\n\t\t/* identity mapping of code points to unicode */\n\t\tif (code > 0xFF) {\n\t\t\treturn FAILURE;\n\t\t}\n\t\t*res = code;\n\t\tbreak;\n\n\tcase cs_8859_5:\n\t\tif (code <= 0xA0 || code == 0xAD /* soft hyphen */) {\n\t\t\t*res = code;\n\t\t} else if (code == 0x2116) {\n\t\t\t*res = 0xF0; /* numero sign */\n\t\t} else if (code == 0xA7) {\n\t\t\t*res = 0xFD; /* section sign */\n\t\t} else if (code >= 0x0401 && code <= 0x044F) {\n\t\t\tif (code == 0x040D || code == 0x0450 || code == 0x045D)\n\t\t\t\treturn FAILURE;\n\t\t\t*res = code - 0x360;\n\t\t} else {\n\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\tcase cs_8859_15:\n\t\tif (code < 0xA4 || (code > 0xBE && code <= 0xFF)) {\n\t\t\t*res = code;\n\t\t} else { /* between A4 and 0xBE */\n\t\t\tfound = unimap_bsearch(unimap_iso885915,\n\t\t\t\tcode, sizeof(unimap_iso885915) / sizeof(*unimap_iso885915));\n\t\t\tif (found)\n\t\t\t\t*res = found;\n\t\t\telse\n\t\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\tcase cs_cp1252:\n\t\tif (code <= 0x7F || (code >= 0xA0 && code <= 0xFF)) {\n\t\t\t*res = code;\n\t\t} else {\n\t\t\tfound = unimap_bsearch(unimap_win1252,\n\t\t\t\tcode, sizeof(unimap_win1252) / sizeof(*unimap_win1252));\n\t\t\tif (found)\n\t\t\t\t*res = found;\n\t\t\telse\n\t\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\tcase cs_macroman:\n\t\tif (code == 0x7F)\n\t\t\treturn FAILURE;\n\t\ttable = unimap_macroman;\n\t\ttable_size = sizeof(unimap_macroman) / sizeof(*unimap_macroman);\n\t\tgoto table_over_7F;\n\tcase cs_cp1251:\n\t\ttable = unimap_win1251;\n\t\ttable_size = sizeof(unimap_win1251) / sizeof(*unimap_win1251);\n\t\tgoto table_over_7F;\n\tcase cs_koi8r:\n\t\ttable = unimap_koi8r;\n\t\ttable_size = sizeof(unimap_koi8r) / sizeof(*unimap_koi8r);\n\t\tgoto table_over_7F;\n\tcase cs_cp866:\n\t\ttable = unimap_cp866;\n\t\ttable_size = sizeof(unimap_cp866) / sizeof(*unimap_cp866);\n\ntable_over_7F:\n\t\tif (code <= 0x7F) {\n\t\t\t*res = code;\n\t\t} else {\n\t\t\tfound = unimap_bsearch(table, code, table_size);\n\t\t\tif (found)\n\t\t\t\t*res = found;\n\t\t\telse\n\t\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\t/* from here on, only map the possible characters in the ASCII range.\n\t * to improve support here, it's a matter of building the unicode mappings.\n\t * See */\n\tcase cs_sjis:\n\tcase cs_eucjp:\n\t\t/* we interpret 0x5C as the Yen symbol. This is not universal.\n\t\t * See */\n\t\tif (code >= 0x20 && code <= 0x7D) {\n\t\t\tif (code == 0x5C)\n\t\t\t\treturn FAILURE;\n\t\t\t*res = code;\n\t\t} else {\n\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\tcase cs_big5:\n\tcase cs_big5hkscs:\n\tcase cs_gb2312:\n\t\tif (code >= 0x20 && code <= 0x7D) {\n\t\t\t*res = code;\n\t\t} else {\n\t\t\treturn FAILURE;\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\treturn FAILURE;\n\t}\n\n\treturn SUCCESS;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5094", "cwe_id": "CWE-190" }, { "id": 830, "func": "void RegKey::setBinary(const TCHAR* valname, const void* value, int length) const {\n LONG result = RegSetValueEx(key, valname, 0, REG_BINARY, (const BYTE*)value, length);\n if (result != ERROR_SUCCESS) throw rdr::SystemException(\"setBinary\", result);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 830, "func": "void RegKey::setBinary(const TCHAR* valname, const void* value, size_t length) const {\n LONG result = RegSetValueEx(key, valname, 0, REG_BINARY, (const BYTE*)value, length);\n if (result != ERROR_SUCCESS) throw rdr::SystemException(\"setBinary\", result);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 1774, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n const TfLiteTensor* diag = GetInput(context, node, kDiagonalTensor);\n FillDiagHelper(input, diag, output);\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1774, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n const TfLiteTensor* diag;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kDiagonalTensor, &diag));\n FillDiagHelper(input, diag, output);\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3283, "func": "R_API RBinJavaVerificationObj *r_bin_java_verification_info_from_type(RBinJavaObj *bin, R_BIN_JAVA_STACKMAP_TYPE type, ut32 value) {\n\tRBinJavaVerificationObj *se = R_NEW0 (RBinJavaVerificationObj);\n\tif (!se) {\n\t\treturn NULL;\n\t}\n\tse->tag = type;\n\tif (se->tag == R_BIN_JAVA_STACKMAP_OBJECT) {\n\t\tse->info.obj_val_cp_idx = (ut16) value;\n\t} else if (se->tag == R_BIN_JAVA_STACKMAP_UNINIT) {\n\t\t/*if (bin->offset_sz == 4) {\n\t\tse->info.uninit_offset = value;\n\t\t} else {\n\t\tse->info.uninit_offset = (ut16) value;\n\t\t}*/\n\t\tse->info.uninit_offset = (ut16) value;\n\t}\n\treturn se;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-0519", "cwe_id": "CWE-119" }, { "id": 3283, "func": "R_API RBinJavaVerificationObj *r_bin_java_verification_info_from_type(RBinJavaObj *bin, R_BIN_JAVA_STACKMAP_TYPE type, ut32 value) {\n\tRBinJavaVerificationObj *se = R_NEW0 (RBinJavaVerificationObj);\n\tif (se) {\n\t\tse->tag = type;\n\t\tif (se->tag == R_BIN_JAVA_STACKMAP_OBJECT) {\n\t\t\tse->info.obj_val_cp_idx = (ut16) value;\n\t\t} else if (se->tag == R_BIN_JAVA_STACKMAP_UNINIT) {\n\t\t\tse->info.uninit_offset = (ut16) value;\n\t\t}\n\t}\n\treturn se;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-0519", "cwe_id": "CWE-119" }, { "id": 170, "func": "header_put_marker (SF_PRIVATE *psf, int x)\n{\tif (psf->headindex < SIGNED_SIZEOF (psf->header) - 4)\n\t{\tpsf->header [psf->headindex++] = (x >> 24) ;\n\t\tpsf->header [psf->headindex++] = (x >> 16) ;\n\t\tpsf->header [psf->headindex++] = (x >> 8) ;\n\t\tpsf->header [psf->headindex++] = x ;\n\t\t} ;\n} /* header_put_marker */", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 170, "func": "header_put_marker (SF_PRIVATE *psf, int x)\n{\tpsf->header.ptr [psf->header.indx++] = (x >> 24) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 16) ;\n\tpsf->header.ptr [psf->header.indx++] = (x >> 8) ;\n\tpsf->header.ptr [psf->header.indx++] = x ;\n} /* header_put_marker */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 1236, "func": "int64 CSteamNetworkConnectionBase::SNP_SendMessage( CSteamNetworkingMessage *pSendMessage, SteamNetworkingMicroseconds usecNow, bool *pbThinkImmediately )\n{\n\tint cbData = (int)pSendMessage->m_cbSize;\n\n\t// Assume we won't want to wake up immediately\n\tif ( pbThinkImmediately )\n\t\t*pbThinkImmediately = false;\n\n\t// Check if we're full\n\tif ( m_senderState.PendingBytesTotal() + cbData > m_connectionConfig.m_SendBufferSize.Get() )\n\t{\n\t\tSpewWarningRateLimited( usecNow, \"Connection already has %u bytes pending, cannot queue any more messages\\n\", m_senderState.PendingBytesTotal() );\n\t\tpSendMessage->Release();\n\t\treturn -k_EResultLimitExceeded; \n\t}\n\n\t// Check if they try to send a really large message\n\tif ( cbData > k_cbMaxUnreliableMsgSize && !( pSendMessage->m_nFlags & k_nSteamNetworkingSend_Reliable ) )\n\t{\n\t\tSpewWarningRateLimited( usecNow, \"Trying to send a very large (%d bytes) unreliable message. Sending as reliable instead.\\n\", cbData );\n\t\tpSendMessage->m_nFlags |= k_nSteamNetworkingSend_Reliable;\n\t}\n\n\tif ( pSendMessage->m_nFlags & k_nSteamNetworkingSend_NoDelay )\n\t{\n\t\t// FIXME - need to check how much data is currently pending, and return\n\t\t// k_EResultIgnored if we think it's going to be a while before this\n\t\t// packet goes on the wire.\n\t}\n\n\t// First, accumulate tokens, and also limit to reasonable burst\n\t// if we weren't already waiting to send\n\tSNP_ClampSendRate();\n\tSNP_TokenBucket_Accumulate( usecNow );\n\n\t// Assign a message number\n\tpSendMessage->m_nMessageNumber = ++m_senderState.m_nLastSentMsgNum;\n\n\t// Reliable, or unreliable?\n\tif ( pSendMessage->m_nFlags & k_nSteamNetworkingSend_Reliable )\n\t{\n\t\tpSendMessage->SNPSend_SetReliableStreamPos( m_senderState.m_nReliableStreamPos );\n\n\t\t// Generate the header\n\t\tbyte *hdr = pSendMessage->SNPSend_ReliableHeader();\n\t\thdr[0] = 0;\n\t\tbyte *hdrEnd = hdr+1;\n\t\tint64 nMsgNumGap = pSendMessage->m_nMessageNumber - m_senderState.m_nLastSendMsgNumReliable;\n\t\tAssert( nMsgNumGap >= 1 );\n\t\tif ( nMsgNumGap > 1 )\n\t\t{\n\t\t\thdrEnd = SerializeVarInt( hdrEnd, (uint64)nMsgNumGap );\n\t\t\thdr[0] |= 0x40;\n\t\t}\n\t\tif ( cbData < 0x20 )\n\t\t{\n\t\t\thdr[0] |= (byte)cbData;\n\t\t}\n\t\telse\n\t\t{\n\t\t\thdr[0] |= (byte)( 0x20 | ( cbData & 0x1f ) );\n\t\t\thdrEnd = SerializeVarInt( hdrEnd, cbData>>5U );\n\t\t}\n\t\tpSendMessage->m_cbSNPSendReliableHeader = hdrEnd - hdr;\n\n\t\t// Grow the total size of the message by the header\n\t\tpSendMessage->m_cbSize += pSendMessage->m_cbSNPSendReliableHeader;\n\n\t\t// Advance stream pointer\n\t\tm_senderState.m_nReliableStreamPos += pSendMessage->m_cbSize;\n\n\t\t// Update stats\n\t\t++m_senderState.m_nMessagesSentReliable;\n\t\tm_senderState.m_cbPendingReliable += pSendMessage->m_cbSize;\n\n\t\t// Remember last sent reliable message number, so we can know how to\n\t\t// encode the next one\n\t\tm_senderState.m_nLastSendMsgNumReliable = pSendMessage->m_nMessageNumber;\n\n\t\tAssert( pSendMessage->SNPSend_IsReliable() );\n\t}\n\telse\n\t{\n\t\tpSendMessage->SNPSend_SetReliableStreamPos( 0 );\n\t\tpSendMessage->m_cbSNPSendReliableHeader = 0;\n\n\t\t++m_senderState.m_nMessagesSentUnreliable;\n\t\tm_senderState.m_cbPendingUnreliable += pSendMessage->m_cbSize;\n\n\t\tAssert( !pSendMessage->SNPSend_IsReliable() );\n\t}\n\n\t// Add to pending list\n\tm_senderState.m_messagesQueued.push_back( pSendMessage );\n\tSpewVerboseGroup( m_connectionConfig.m_LogLevel_Message.Get(), \"[%s] SendMessage %s: MsgNum=%lld sz=%d\\n\",\n\t\t\t\t GetDescription(),\n\t\t\t\t pSendMessage->SNPSend_IsReliable() ? \"RELIABLE\" : \"UNRELIABLE\",\n\t\t\t\t (long long)pSendMessage->m_nMessageNumber,\n\t\t\t\t pSendMessage->m_cbSize );\n\n\t// Use Nagle?\n\t// We always set the Nagle timer, even if we immediately clear it. This makes our clearing code simpler,\n\t// since we can always safely assume that once we find a message with the nagle timer cleared, all messages\n\t// queued earlier than this also have it cleared.\n\t// FIXME - Don't think this works if the configuration value is changing. Since changing the\n\t// config value could violate the assumption that nagle times are increasing. Probably not worth\n\t// fixing.\n\tpSendMessage->SNPSend_SetUsecNagle( usecNow + m_connectionConfig.m_NagleTime.Get() );\n\tif ( pSendMessage->m_nFlags & k_nSteamNetworkingSend_NoNagle )\n\t\tm_senderState.ClearNagleTimers();\n\n\t// Save the message number. The code below might end up deleting the message we just queued\n\tint64 result = pSendMessage->m_nMessageNumber;\n\n\t// Schedule wakeup at the appropriate time. (E.g. right now, if we're ready to send, \n\t// or at the Nagle time, if Nagle is active.)\n\t//\n\t// NOTE: Right now we might not actually be capable of sending end to end data.\n\t// But that case is relatievly rare, and nothing will break if we try to right now.\n\t// On the other hand, just asking the question involved a virtual function call,\n\t// and it will return success most of the time, so let's not make the check here.\n\tif ( GetState() == k_ESteamNetworkingConnectionState_Connected )\n\t{\n\t\tSteamNetworkingMicroseconds usecNextThink = SNP_GetNextThinkTime( usecNow );\n\n\t\t// Ready to send now?\n\t\tif ( usecNextThink > usecNow )\n\t\t{\n\n\t\t\t// We are rate limiting. Spew about it?\n\t\t\tif ( m_senderState.m_messagesQueued.m_pFirst->SNPSend_UsecNagle() == 0 )\n\t\t\t{\n\t\t\t\tSpewVerbose( \"[%s] RATELIM QueueTime is %.1fms, SendRate=%.1fk, BytesQueued=%d\\n\", \n\t\t\t\t\tGetDescription(),\n\t\t\t\t\tm_senderState.CalcTimeUntilNextSend() * 1e-3,\n\t\t\t\t\tm_senderState.m_n_x * ( 1.0/1024.0),\n\t\t\t\t\tm_senderState.PendingBytesTotal()\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Set a wakeup call.\n\t\t\tEnsureMinThinkTime( usecNextThink );\n\t\t}\n\t\telse\n\t\t{\n\n\t\t\t// We're ready to send right now. Check if we should!\n\t\t\tif ( pSendMessage->m_nFlags & k_nSteamNetworkingSend_UseCurrentThread )\n\t\t\t{\n\n\t\t\t\t// We should send in this thread, before the API entry point\n\t\t\t\t// that the app used returns. Is the caller gonna handle this?\n\t\t\t\tif ( pbThinkImmediately )\n\t\t\t\t{\n\t\t\t\t\t// Caller says they will handle it\n\t\t\t\t\t*pbThinkImmediately = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t// Caller wants us to just do it here.\n\t\t\t\t\tCheckConnectionStateAndSetNextThinkTime( usecNow );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// Wake up the service thread ASAP to send this in the background thread\n\t\t\t\tSetNextThinkTimeASAP();\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-6016", "cwe_id": "CWE-787" }, { "id": 1236, "func": "int64 CSteamNetworkConnectionBase::SNP_SendMessage( CSteamNetworkingMessage *pSendMessage, SteamNetworkingMicroseconds usecNow, bool *pbThinkImmediately )\n{\n\tint cbData = (int)pSendMessage->m_cbSize;\n\n\t// Assume we won't want to wake up immediately\n\tif ( pbThinkImmediately )\n\t\t*pbThinkImmediately = false;\n\n\t// Check if we're full\n\tif ( m_senderState.PendingBytesTotal() + cbData > m_connectionConfig.m_SendBufferSize.Get() )\n\t{\n\t\tSpewWarningRateLimited( usecNow, \"Connection already has %u bytes pending, cannot queue any more messages\\n\", m_senderState.PendingBytesTotal() );\n\t\tpSendMessage->Release();\n\t\treturn -k_EResultLimitExceeded; \n\t}\n\n\t// Check if they try to send a really large message\n\tif ( cbData > k_cbMaxUnreliableMsgSizeSend && !( pSendMessage->m_nFlags & k_nSteamNetworkingSend_Reliable ) )\n\t{\n\t\tSpewWarningRateLimited( usecNow, \"Trying to send a very large (%d bytes) unreliable message. Sending as reliable instead.\\n\", cbData );\n\t\tpSendMessage->m_nFlags |= k_nSteamNetworkingSend_Reliable;\n\t}\n\n\tif ( pSendMessage->m_nFlags & k_nSteamNetworkingSend_NoDelay )\n\t{\n\t\t// FIXME - need to check how much data is currently pending, and return\n\t\t// k_EResultIgnored if we think it's going to be a while before this\n\t\t// packet goes on the wire.\n\t}\n\n\t// First, accumulate tokens, and also limit to reasonable burst\n\t// if we weren't already waiting to send\n\tSNP_ClampSendRate();\n\tSNP_TokenBucket_Accumulate( usecNow );\n\n\t// Assign a message number\n\tpSendMessage->m_nMessageNumber = ++m_senderState.m_nLastSentMsgNum;\n\n\t// Reliable, or unreliable?\n\tif ( pSendMessage->m_nFlags & k_nSteamNetworkingSend_Reliable )\n\t{\n\t\tpSendMessage->SNPSend_SetReliableStreamPos( m_senderState.m_nReliableStreamPos );\n\n\t\t// Generate the header\n\t\tbyte *hdr = pSendMessage->SNPSend_ReliableHeader();\n\t\thdr[0] = 0;\n\t\tbyte *hdrEnd = hdr+1;\n\t\tint64 nMsgNumGap = pSendMessage->m_nMessageNumber - m_senderState.m_nLastSendMsgNumReliable;\n\t\tAssert( nMsgNumGap >= 1 );\n\t\tif ( nMsgNumGap > 1 )\n\t\t{\n\t\t\thdrEnd = SerializeVarInt( hdrEnd, (uint64)nMsgNumGap );\n\t\t\thdr[0] |= 0x40;\n\t\t}\n\t\tif ( cbData < 0x20 )\n\t\t{\n\t\t\thdr[0] |= (byte)cbData;\n\t\t}\n\t\telse\n\t\t{\n\t\t\thdr[0] |= (byte)( 0x20 | ( cbData & 0x1f ) );\n\t\t\thdrEnd = SerializeVarInt( hdrEnd, cbData>>5U );\n\t\t}\n\t\tpSendMessage->m_cbSNPSendReliableHeader = hdrEnd - hdr;\n\n\t\t// Grow the total size of the message by the header\n\t\tpSendMessage->m_cbSize += pSendMessage->m_cbSNPSendReliableHeader;\n\n\t\t// Advance stream pointer\n\t\tm_senderState.m_nReliableStreamPos += pSendMessage->m_cbSize;\n\n\t\t// Update stats\n\t\t++m_senderState.m_nMessagesSentReliable;\n\t\tm_senderState.m_cbPendingReliable += pSendMessage->m_cbSize;\n\n\t\t// Remember last sent reliable message number, so we can know how to\n\t\t// encode the next one\n\t\tm_senderState.m_nLastSendMsgNumReliable = pSendMessage->m_nMessageNumber;\n\n\t\tAssert( pSendMessage->SNPSend_IsReliable() );\n\t}\n\telse\n\t{\n\t\tpSendMessage->SNPSend_SetReliableStreamPos( 0 );\n\t\tpSendMessage->m_cbSNPSendReliableHeader = 0;\n\n\t\t++m_senderState.m_nMessagesSentUnreliable;\n\t\tm_senderState.m_cbPendingUnreliable += pSendMessage->m_cbSize;\n\n\t\tAssert( !pSendMessage->SNPSend_IsReliable() );\n\t}\n\n\t// Add to pending list\n\tm_senderState.m_messagesQueued.push_back( pSendMessage );\n\tSpewVerboseGroup( m_connectionConfig.m_LogLevel_Message.Get(), \"[%s] SendMessage %s: MsgNum=%lld sz=%d\\n\",\n\t\t\t\t GetDescription(),\n\t\t\t\t pSendMessage->SNPSend_IsReliable() ? \"RELIABLE\" : \"UNRELIABLE\",\n\t\t\t\t (long long)pSendMessage->m_nMessageNumber,\n\t\t\t\t pSendMessage->m_cbSize );\n\n\t// Use Nagle?\n\t// We always set the Nagle timer, even if we immediately clear it. This makes our clearing code simpler,\n\t// since we can always safely assume that once we find a message with the nagle timer cleared, all messages\n\t// queued earlier than this also have it cleared.\n\t// FIXME - Don't think this works if the configuration value is changing. Since changing the\n\t// config value could violate the assumption that nagle times are increasing. Probably not worth\n\t// fixing.\n\tpSendMessage->SNPSend_SetUsecNagle( usecNow + m_connectionConfig.m_NagleTime.Get() );\n\tif ( pSendMessage->m_nFlags & k_nSteamNetworkingSend_NoNagle )\n\t\tm_senderState.ClearNagleTimers();\n\n\t// Save the message number. The code below might end up deleting the message we just queued\n\tint64 result = pSendMessage->m_nMessageNumber;\n\n\t// Schedule wakeup at the appropriate time. (E.g. right now, if we're ready to send, \n\t// or at the Nagle time, if Nagle is active.)\n\t//\n\t// NOTE: Right now we might not actually be capable of sending end to end data.\n\t// But that case is relatievly rare, and nothing will break if we try to right now.\n\t// On the other hand, just asking the question involved a virtual function call,\n\t// and it will return success most of the time, so let's not make the check here.\n\tif ( GetState() == k_ESteamNetworkingConnectionState_Connected )\n\t{\n\t\tSteamNetworkingMicroseconds usecNextThink = SNP_GetNextThinkTime( usecNow );\n\n\t\t// Ready to send now?\n\t\tif ( usecNextThink > usecNow )\n\t\t{\n\n\t\t\t// We are rate limiting. Spew about it?\n\t\t\tif ( m_senderState.m_messagesQueued.m_pFirst->SNPSend_UsecNagle() == 0 )\n\t\t\t{\n\t\t\t\tSpewVerbose( \"[%s] RATELIM QueueTime is %.1fms, SendRate=%.1fk, BytesQueued=%d\\n\", \n\t\t\t\t\tGetDescription(),\n\t\t\t\t\tm_senderState.CalcTimeUntilNextSend() * 1e-3,\n\t\t\t\t\tm_senderState.m_n_x * ( 1.0/1024.0),\n\t\t\t\t\tm_senderState.PendingBytesTotal()\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Set a wakeup call.\n\t\t\tEnsureMinThinkTime( usecNextThink );\n\t\t}\n\t\telse\n\t\t{\n\n\t\t\t// We're ready to send right now. Check if we should!\n\t\t\tif ( pSendMessage->m_nFlags & k_nSteamNetworkingSend_UseCurrentThread )\n\t\t\t{\n\n\t\t\t\t// We should send in this thread, before the API entry point\n\t\t\t\t// that the app used returns. Is the caller gonna handle this?\n\t\t\t\tif ( pbThinkImmediately )\n\t\t\t\t{\n\t\t\t\t\t// Caller says they will handle it\n\t\t\t\t\t*pbThinkImmediately = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t// Caller wants us to just do it here.\n\t\t\t\t\tCheckConnectionStateAndSetNextThinkTime( usecNow );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// Wake up the service thread ASAP to send this in the background thread\n\t\t\t\tSetNextThinkTimeASAP();\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-6016", "cwe_id": "CWE-787" }, { "id": 2692, "func": "static inline bool unconditional(const struct arpt_arp *arp)\n{\n\tstatic const struct arpt_arp uncond;\n\n\treturn memcmp(arp, &uncond, sizeof(uncond)) == 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-3134", "cwe_id": "CWE-119" }, { "id": 2692, "func": "static inline bool unconditional(const struct arpt_entry *e)\n{\n\tstatic const struct arpt_arp uncond;\n\n\treturn e->target_offset == sizeof(struct arpt_entry) &&\n\t memcmp(&e->arp, &uncond, sizeof(uncond)) == 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-3134", "cwe_id": "CWE-119" }, { "id": 940, "func": "int ntlm_construct_authenticate_target_info(NTLM_CONTEXT* context)\n{\n\tULONG size;\n\tULONG AvPairsCount;\n\tULONG AvPairsValueLength;\n\tNTLM_AV_PAIR* AvTimestamp;\n\tNTLM_AV_PAIR* AvNbDomainName;\n\tNTLM_AV_PAIR* AvNbComputerName;\n\tNTLM_AV_PAIR* AvDnsDomainName;\n\tNTLM_AV_PAIR* AvDnsComputerName;\n\tNTLM_AV_PAIR* AvDnsTreeName;\n\tNTLM_AV_PAIR* ChallengeTargetInfo;\n\tNTLM_AV_PAIR* AuthenticateTargetInfo;\n\tsize_t cbAvTimestamp;\n\tsize_t cbAvNbDomainName;\n\tsize_t cbAvNbComputerName;\n\tsize_t cbAvDnsDomainName;\n\tsize_t cbAvDnsComputerName;\n\tsize_t cbAvDnsTreeName;\n\tsize_t cbChallengeTargetInfo;\n\tsize_t cbAuthenticateTargetInfo;\n\tAvPairsCount = 1;\n\tAvPairsValueLength = 0;\n\tChallengeTargetInfo = (NTLM_AV_PAIR*)context->ChallengeTargetInfo.pvBuffer;\n\tcbChallengeTargetInfo = context->ChallengeTargetInfo.cbBuffer;\n\tAvNbDomainName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvNbDomainName,\n\t &cbAvNbDomainName);\n\tAvNbComputerName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo,\n\t MsvAvNbComputerName, &cbAvNbComputerName);\n\tAvDnsDomainName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo,\n\t MsvAvDnsDomainName, &cbAvDnsDomainName);\n\tAvDnsComputerName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo,\n\t MsvAvDnsComputerName, &cbAvDnsComputerName);\n\tAvDnsTreeName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvDnsTreeName,\n\t &cbAvDnsTreeName);\n\tAvTimestamp = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvTimestamp,\n\t &cbAvTimestamp);\n\n\tif (AvNbDomainName)\n\t{\n\t\tAvPairsCount++; /* MsvAvNbDomainName */\n\t\tAvPairsValueLength += ntlm_av_pair_get_len(AvNbDomainName);\n\t}\n\n\tif (AvNbComputerName)\n\t{\n\t\tAvPairsCount++; /* MsvAvNbComputerName */\n\t\tAvPairsValueLength += ntlm_av_pair_get_len(AvNbComputerName);\n\t}\n\n\tif (AvDnsDomainName)\n\t{\n\t\tAvPairsCount++; /* MsvAvDnsDomainName */\n\t\tAvPairsValueLength += ntlm_av_pair_get_len(AvDnsDomainName);\n\t}\n\n\tif (AvDnsComputerName)\n\t{\n\t\tAvPairsCount++; /* MsvAvDnsComputerName */\n\t\tAvPairsValueLength += ntlm_av_pair_get_len(AvDnsComputerName);\n\t}\n\n\tif (AvDnsTreeName)\n\t{\n\t\tAvPairsCount++; /* MsvAvDnsTreeName */\n\t\tAvPairsValueLength += ntlm_av_pair_get_len(AvDnsTreeName);\n\t}\n\n\tAvPairsCount++; /* MsvAvTimestamp */\n\tAvPairsValueLength += 8;\n\n\tif (context->UseMIC)\n\t{\n\t\tAvPairsCount++; /* MsvAvFlags */\n\t\tAvPairsValueLength += 4;\n\t}\n\n\tif (context->SendSingleHostData)\n\t{\n\t\tAvPairsCount++; /* MsvAvSingleHost */\n\t\tntlm_compute_single_host_data(context);\n\t\tAvPairsValueLength += context->SingleHostData.Size;\n\t}\n\n\t/**\n\t * Extended Protection for Authentication:\n\t * http://blogs.technet.com/b/srd/archive/2009/12/08/extended-protection-for-authentication.aspx\n\t */\n\n\tif (!context->SuppressExtendedProtection)\n\t{\n\t\t/**\n\t\t * SEC_CHANNEL_BINDINGS structure\n\t\t * http://msdn.microsoft.com/en-us/library/windows/desktop/dd919963/\n\t\t */\n\t\tAvPairsCount++; /* MsvChannelBindings */\n\t\tAvPairsValueLength += 16;\n\t\tntlm_compute_channel_bindings(context);\n\n\t\tif (context->ServicePrincipalName.Length > 0)\n\t\t{\n\t\t\tAvPairsCount++; /* MsvAvTargetName */\n\t\t\tAvPairsValueLength += context->ServicePrincipalName.Length;\n\t\t}\n\t}\n\n\tsize = ntlm_av_pair_list_size(AvPairsCount, AvPairsValueLength);\n\n\tif (context->NTLMv2)\n\t\tsize += 8; /* unknown 8-byte padding */\n\n\tif (!sspi_SecBufferAlloc(&context->AuthenticateTargetInfo, size))\n\t\tgoto fail;\n\n\tAuthenticateTargetInfo = (NTLM_AV_PAIR*)context->AuthenticateTargetInfo.pvBuffer;\n\tcbAuthenticateTargetInfo = context->AuthenticateTargetInfo.cbBuffer;\n\n\tif (!ntlm_av_pair_list_init(AuthenticateTargetInfo, cbAuthenticateTargetInfo))\n\t\tgoto fail;\n\n\tif (AvNbDomainName)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo, AvNbDomainName,\n\t\t cbAvNbDomainName))\n\t\t\tgoto fail;\n\t}\n\n\tif (AvNbComputerName)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo,\n\t\t AvNbComputerName, cbAvNbComputerName))\n\t\t\tgoto fail;\n\t}\n\n\tif (AvDnsDomainName)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo,\n\t\t AvDnsDomainName, cbAvDnsDomainName))\n\t\t\tgoto fail;\n\t}\n\n\tif (AvDnsComputerName)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo,\n\t\t AvDnsComputerName, cbAvDnsComputerName))\n\t\t\tgoto fail;\n\t}\n\n\tif (AvDnsTreeName)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo, AvDnsTreeName,\n\t\t cbAvDnsTreeName))\n\t\t\tgoto fail;\n\t}\n\n\tif (AvTimestamp)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo, AvTimestamp,\n\t\t cbAvTimestamp))\n\t\t\tgoto fail;\n\t}\n\n\tif (context->UseMIC)\n\t{\n\t\tUINT32 flags;\n\t\tData_Write_UINT32(&flags, MSV_AV_FLAGS_MESSAGE_INTEGRITY_CHECK);\n\n\t\tif (!ntlm_av_pair_add(AuthenticateTargetInfo, cbAuthenticateTargetInfo, MsvAvFlags,\n\t\t (PBYTE)&flags, 4))\n\t\t\tgoto fail;\n\t}\n\n\tif (context->SendSingleHostData)\n\t{\n\t\tif (!ntlm_av_pair_add(AuthenticateTargetInfo, cbAuthenticateTargetInfo, MsvAvSingleHost,\n\t\t (PBYTE)&context->SingleHostData, context->SingleHostData.Size))\n\t\t\tgoto fail;\n\t}\n\n\tif (!context->SuppressExtendedProtection)\n\t{\n\t\tif (!ntlm_av_pair_add(AuthenticateTargetInfo, cbAuthenticateTargetInfo, MsvChannelBindings,\n\t\t context->ChannelBindingsHash, 16))\n\t\t\tgoto fail;\n\n\t\tif (context->ServicePrincipalName.Length > 0)\n\t\t{\n\t\t\tif (!ntlm_av_pair_add(AuthenticateTargetInfo, cbAuthenticateTargetInfo, MsvAvTargetName,\n\t\t\t (PBYTE)context->ServicePrincipalName.Buffer,\n\t\t\t context->ServicePrincipalName.Length))\n\t\t\t\tgoto fail;\n\t\t}\n\t}\n\n\tif (context->NTLMv2)\n\t{\n\t\tNTLM_AV_PAIR* AvEOL;\n\t\tAvEOL = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvEOL, NULL);\n\n\t\tif (!AvEOL)\n\t\t\tgoto fail;\n\n\t\tZeroMemory(AvEOL, sizeof(NTLM_AV_PAIR));\n\t}\n\n\treturn 1;\nfail:\n\tsspi_SecBufferFree(&context->AuthenticateTargetInfo);\n\treturn -1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-11097", "cwe_id": "CWE-125" }, { "id": 940, "func": "int ntlm_construct_authenticate_target_info(NTLM_CONTEXT* context)\n{\n\tULONG size;\n\tULONG AvPairsCount;\n\tULONG AvPairsValueLength;\n\tNTLM_AV_PAIR* AvTimestamp;\n\tNTLM_AV_PAIR* AvNbDomainName;\n\tNTLM_AV_PAIR* AvNbComputerName;\n\tNTLM_AV_PAIR* AvDnsDomainName;\n\tNTLM_AV_PAIR* AvDnsComputerName;\n\tNTLM_AV_PAIR* AvDnsTreeName;\n\tNTLM_AV_PAIR* ChallengeTargetInfo;\n\tNTLM_AV_PAIR* AuthenticateTargetInfo;\n\tsize_t cbAvTimestamp;\n\tsize_t cbAvNbDomainName;\n\tsize_t cbAvNbComputerName;\n\tsize_t cbAvDnsDomainName;\n\tsize_t cbAvDnsComputerName;\n\tsize_t cbAvDnsTreeName;\n\tsize_t cbChallengeTargetInfo;\n\tsize_t cbAuthenticateTargetInfo;\n\tAvPairsCount = 1;\n\tAvPairsValueLength = 0;\n\tChallengeTargetInfo = (NTLM_AV_PAIR*)context->ChallengeTargetInfo.pvBuffer;\n\tcbChallengeTargetInfo = context->ChallengeTargetInfo.cbBuffer;\n\tAvNbDomainName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvNbDomainName,\n\t &cbAvNbDomainName);\n\tAvNbComputerName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo,\n\t MsvAvNbComputerName, &cbAvNbComputerName);\n\tAvDnsDomainName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo,\n\t MsvAvDnsDomainName, &cbAvDnsDomainName);\n\tAvDnsComputerName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo,\n\t MsvAvDnsComputerName, &cbAvDnsComputerName);\n\tAvDnsTreeName = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvDnsTreeName,\n\t &cbAvDnsTreeName);\n\tAvTimestamp = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvTimestamp,\n\t &cbAvTimestamp);\n\n\tif (AvNbDomainName)\n\t{\n\t\tsize_t avLen;\n\t\tif (!ntlm_av_pair_get_len(AvNbDomainName, cbAvNbDomainName, &avLen))\n\t\t\tgoto fail;\n\t\tAvPairsCount++; /* MsvAvNbDomainName */\n\t\tAvPairsValueLength += avLen;\n\t}\n\n\tif (AvNbComputerName)\n\t{\n\t\tsize_t avLen;\n\t\tif (!ntlm_av_pair_get_len(AvNbComputerName, cbAvNbComputerName, &avLen))\n\t\t\tgoto fail;\n\t\tAvPairsCount++; /* MsvAvNbComputerName */\n\t\tAvPairsValueLength += avLen;\n\t}\n\n\tif (AvDnsDomainName)\n\t{\n\t\tsize_t avLen;\n\t\tif (!ntlm_av_pair_get_len(AvDnsDomainName, cbAvDnsDomainName, &avLen))\n\t\t\tgoto fail;\n\t\tAvPairsCount++; /* MsvAvDnsDomainName */\n\t\tAvPairsValueLength += avLen;\n\t}\n\n\tif (AvDnsComputerName)\n\t{\n\t\tsize_t avLen;\n\t\tif (!ntlm_av_pair_get_len(AvDnsComputerName, cbAvDnsComputerName, &avLen))\n\t\t\tgoto fail;\n\t\tAvPairsCount++; /* MsvAvDnsComputerName */\n\t\tAvPairsValueLength += avLen;\n\t}\n\n\tif (AvDnsTreeName)\n\t{\n\t\tsize_t avLen;\n\t\tif (!ntlm_av_pair_get_len(AvDnsTreeName, cbAvDnsTreeName, &avLen))\n\t\t\tgoto fail;\n\t\tAvPairsCount++; /* MsvAvDnsTreeName */\n\t\tAvPairsValueLength += avLen;\n\t}\n\n\tAvPairsCount++; /* MsvAvTimestamp */\n\tAvPairsValueLength += 8;\n\n\tif (context->UseMIC)\n\t{\n\t\tAvPairsCount++; /* MsvAvFlags */\n\t\tAvPairsValueLength += 4;\n\t}\n\n\tif (context->SendSingleHostData)\n\t{\n\t\tAvPairsCount++; /* MsvAvSingleHost */\n\t\tntlm_compute_single_host_data(context);\n\t\tAvPairsValueLength += context->SingleHostData.Size;\n\t}\n\n\t/**\n\t * Extended Protection for Authentication:\n\t * http://blogs.technet.com/b/srd/archive/2009/12/08/extended-protection-for-authentication.aspx\n\t */\n\n\tif (!context->SuppressExtendedProtection)\n\t{\n\t\t/**\n\t\t * SEC_CHANNEL_BINDINGS structure\n\t\t * http://msdn.microsoft.com/en-us/library/windows/desktop/dd919963/\n\t\t */\n\t\tAvPairsCount++; /* MsvChannelBindings */\n\t\tAvPairsValueLength += 16;\n\t\tntlm_compute_channel_bindings(context);\n\n\t\tif (context->ServicePrincipalName.Length > 0)\n\t\t{\n\t\t\tAvPairsCount++; /* MsvAvTargetName */\n\t\t\tAvPairsValueLength += context->ServicePrincipalName.Length;\n\t\t}\n\t}\n\n\tsize = ntlm_av_pair_list_size(AvPairsCount, AvPairsValueLength);\n\n\tif (context->NTLMv2)\n\t\tsize += 8; /* unknown 8-byte padding */\n\n\tif (!sspi_SecBufferAlloc(&context->AuthenticateTargetInfo, size))\n\t\tgoto fail;\n\n\tAuthenticateTargetInfo = (NTLM_AV_PAIR*)context->AuthenticateTargetInfo.pvBuffer;\n\tcbAuthenticateTargetInfo = context->AuthenticateTargetInfo.cbBuffer;\n\n\tif (!ntlm_av_pair_list_init(AuthenticateTargetInfo, cbAuthenticateTargetInfo))\n\t\tgoto fail;\n\n\tif (AvNbDomainName)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo, AvNbDomainName,\n\t\t cbAvNbDomainName))\n\t\t\tgoto fail;\n\t}\n\n\tif (AvNbComputerName)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo,\n\t\t AvNbComputerName, cbAvNbComputerName))\n\t\t\tgoto fail;\n\t}\n\n\tif (AvDnsDomainName)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo,\n\t\t AvDnsDomainName, cbAvDnsDomainName))\n\t\t\tgoto fail;\n\t}\n\n\tif (AvDnsComputerName)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo,\n\t\t AvDnsComputerName, cbAvDnsComputerName))\n\t\t\tgoto fail;\n\t}\n\n\tif (AvDnsTreeName)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo, AvDnsTreeName,\n\t\t cbAvDnsTreeName))\n\t\t\tgoto fail;\n\t}\n\n\tif (AvTimestamp)\n\t{\n\t\tif (!ntlm_av_pair_add_copy(AuthenticateTargetInfo, cbAuthenticateTargetInfo, AvTimestamp,\n\t\t cbAvTimestamp))\n\t\t\tgoto fail;\n\t}\n\n\tif (context->UseMIC)\n\t{\n\t\tUINT32 flags;\n\t\tData_Write_UINT32(&flags, MSV_AV_FLAGS_MESSAGE_INTEGRITY_CHECK);\n\n\t\tif (!ntlm_av_pair_add(AuthenticateTargetInfo, cbAuthenticateTargetInfo, MsvAvFlags,\n\t\t (PBYTE)&flags, 4))\n\t\t\tgoto fail;\n\t}\n\n\tif (context->SendSingleHostData)\n\t{\n\t\tif (!ntlm_av_pair_add(AuthenticateTargetInfo, cbAuthenticateTargetInfo, MsvAvSingleHost,\n\t\t (PBYTE)&context->SingleHostData, context->SingleHostData.Size))\n\t\t\tgoto fail;\n\t}\n\n\tif (!context->SuppressExtendedProtection)\n\t{\n\t\tif (!ntlm_av_pair_add(AuthenticateTargetInfo, cbAuthenticateTargetInfo, MsvChannelBindings,\n\t\t context->ChannelBindingsHash, 16))\n\t\t\tgoto fail;\n\n\t\tif (context->ServicePrincipalName.Length > 0)\n\t\t{\n\t\t\tif (!ntlm_av_pair_add(AuthenticateTargetInfo, cbAuthenticateTargetInfo, MsvAvTargetName,\n\t\t\t (PBYTE)context->ServicePrincipalName.Buffer,\n\t\t\t context->ServicePrincipalName.Length))\n\t\t\t\tgoto fail;\n\t\t}\n\t}\n\n\tif (context->NTLMv2)\n\t{\n\t\tNTLM_AV_PAIR* AvEOL;\n\t\tAvEOL = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvEOL, NULL);\n\n\t\tif (!AvEOL)\n\t\t\tgoto fail;\n\n\t\tZeroMemory(AvEOL, sizeof(NTLM_AV_PAIR));\n\t}\n\n\treturn 1;\nfail:\n\tsspi_SecBufferFree(&context->AuthenticateTargetInfo);\n\treturn -1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-11097", "cwe_id": "CWE-125" }, { "id": 1591, "func": "int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,\n\t struct inode *new_dir, struct dentry *new_dentry,\n\t struct inode **delegated_inode, unsigned int flags)\n{\n\tint error;\n\tbool is_dir = d_is_dir(old_dentry);\n\tconst unsigned char *old_name;\n\tstruct inode *source = old_dentry->d_inode;\n\tstruct inode *target = new_dentry->d_inode;\n\tbool new_is_dir = false;\n\tunsigned max_links = new_dir->i_sb->s_max_links;\n\n\tif (source == target)\n\t\treturn 0;\n\n\terror = may_delete(old_dir, old_dentry, is_dir);\n\tif (error)\n\t\treturn error;\n\n\tif (!target) {\n\t\terror = may_create(new_dir, new_dentry);\n\t} else {\n\t\tnew_is_dir = d_is_dir(new_dentry);\n\n\t\tif (!(flags & RENAME_EXCHANGE))\n\t\t\terror = may_delete(new_dir, new_dentry, is_dir);\n\t\telse\n\t\t\terror = may_delete(new_dir, new_dentry, new_is_dir);\n\t}\n\tif (error)\n\t\treturn error;\n\n\tif (!old_dir->i_op->rename)\n\t\treturn -EPERM;\n\n\t/*\n\t * If we are going to change the parent - check write permissions,\n\t * we'll need to flip '..'.\n\t */\n\tif (new_dir != old_dir) {\n\t\tif (is_dir) {\n\t\t\terror = inode_permission(source, MAY_WRITE);\n\t\t\tif (error)\n\t\t\t\treturn error;\n\t\t}\n\t\tif ((flags & RENAME_EXCHANGE) && new_is_dir) {\n\t\t\terror = inode_permission(target, MAY_WRITE);\n\t\t\tif (error)\n\t\t\t\treturn error;\n\t\t}\n\t}\n\n\terror = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry,\n\t\t\t\t flags);\n\tif (error)\n\t\treturn error;\n\n\told_name = fsnotify_oldname_init(old_dentry->d_name.name);\n\tdget(new_dentry);\n\tif (!is_dir || (flags & RENAME_EXCHANGE))\n\t\tlock_two_nondirectories(source, target);\n\telse if (target)\n\t\tinode_lock(target);\n\n\terror = -EBUSY;\n\tif (is_local_mountpoint(old_dentry) || is_local_mountpoint(new_dentry))\n\t\tgoto out;\n\n\tif (max_links && new_dir != old_dir) {\n\t\terror = -EMLINK;\n\t\tif (is_dir && !new_is_dir && new_dir->i_nlink >= max_links)\n\t\t\tgoto out;\n\t\tif ((flags & RENAME_EXCHANGE) && !is_dir && new_is_dir &&\n\t\t old_dir->i_nlink >= max_links)\n\t\t\tgoto out;\n\t}\n\tif (is_dir && !(flags & RENAME_EXCHANGE) && target)\n\t\tshrink_dcache_parent(new_dentry);\n\tif (!is_dir) {\n\t\terror = try_break_deleg(source, delegated_inode);\n\t\tif (error)\n\t\t\tgoto out;\n\t}\n\tif (target && !new_is_dir) {\n\t\terror = try_break_deleg(target, delegated_inode);\n\t\tif (error)\n\t\t\tgoto out;\n\t}\n\terror = old_dir->i_op->rename(old_dir, old_dentry,\n\t\t\t\t new_dir, new_dentry, flags);\n\tif (error)\n\t\tgoto out;\n\n\tif (!(flags & RENAME_EXCHANGE) && target) {\n\t\tif (is_dir)\n\t\t\ttarget->i_flags |= S_DEAD;\n\t\tdont_mount(new_dentry);\n\t\tdetach_mounts(new_dentry);\n\t}\n\tif (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) {\n\t\tif (!(flags & RENAME_EXCHANGE))\n\t\t\td_move(old_dentry, new_dentry);\n\t\telse\n\t\t\td_exchange(old_dentry, new_dentry);\n\t}\nout:\n\tif (!is_dir || (flags & RENAME_EXCHANGE))\n\t\tunlock_two_nondirectories(source, target);\n\telse if (target)\n\t\tinode_unlock(target);\n\tdput(new_dentry);\n\tif (!error) {\n\t\tfsnotify_move(old_dir, new_dir, old_name, is_dir,\n\t\t\t !(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry);\n\t\tif (flags & RENAME_EXCHANGE) {\n\t\t\tfsnotify_move(new_dir, old_dir, old_dentry->d_name.name,\n\t\t\t\t new_is_dir, NULL, new_dentry);\n\t\t}\n\t}\n\tfsnotify_oldname_free(old_name);\n\n\treturn error;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7533", "cwe_id": "CWE-362" }, { "id": 1591, "func": "int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,\n\t struct inode *new_dir, struct dentry *new_dentry,\n\t struct inode **delegated_inode, unsigned int flags)\n{\n\tint error;\n\tbool is_dir = d_is_dir(old_dentry);\n\tstruct inode *source = old_dentry->d_inode;\n\tstruct inode *target = new_dentry->d_inode;\n\tbool new_is_dir = false;\n\tunsigned max_links = new_dir->i_sb->s_max_links;\n\tstruct name_snapshot old_name;\n\n\tif (source == target)\n\t\treturn 0;\n\n\terror = may_delete(old_dir, old_dentry, is_dir);\n\tif (error)\n\t\treturn error;\n\n\tif (!target) {\n\t\terror = may_create(new_dir, new_dentry);\n\t} else {\n\t\tnew_is_dir = d_is_dir(new_dentry);\n\n\t\tif (!(flags & RENAME_EXCHANGE))\n\t\t\terror = may_delete(new_dir, new_dentry, is_dir);\n\t\telse\n\t\t\terror = may_delete(new_dir, new_dentry, new_is_dir);\n\t}\n\tif (error)\n\t\treturn error;\n\n\tif (!old_dir->i_op->rename)\n\t\treturn -EPERM;\n\n\t/*\n\t * If we are going to change the parent - check write permissions,\n\t * we'll need to flip '..'.\n\t */\n\tif (new_dir != old_dir) {\n\t\tif (is_dir) {\n\t\t\terror = inode_permission(source, MAY_WRITE);\n\t\t\tif (error)\n\t\t\t\treturn error;\n\t\t}\n\t\tif ((flags & RENAME_EXCHANGE) && new_is_dir) {\n\t\t\terror = inode_permission(target, MAY_WRITE);\n\t\t\tif (error)\n\t\t\t\treturn error;\n\t\t}\n\t}\n\n\terror = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry,\n\t\t\t\t flags);\n\tif (error)\n\t\treturn error;\n\n\ttake_dentry_name_snapshot(&old_name, old_dentry);\n\tdget(new_dentry);\n\tif (!is_dir || (flags & RENAME_EXCHANGE))\n\t\tlock_two_nondirectories(source, target);\n\telse if (target)\n\t\tinode_lock(target);\n\n\terror = -EBUSY;\n\tif (is_local_mountpoint(old_dentry) || is_local_mountpoint(new_dentry))\n\t\tgoto out;\n\n\tif (max_links && new_dir != old_dir) {\n\t\terror = -EMLINK;\n\t\tif (is_dir && !new_is_dir && new_dir->i_nlink >= max_links)\n\t\t\tgoto out;\n\t\tif ((flags & RENAME_EXCHANGE) && !is_dir && new_is_dir &&\n\t\t old_dir->i_nlink >= max_links)\n\t\t\tgoto out;\n\t}\n\tif (is_dir && !(flags & RENAME_EXCHANGE) && target)\n\t\tshrink_dcache_parent(new_dentry);\n\tif (!is_dir) {\n\t\terror = try_break_deleg(source, delegated_inode);\n\t\tif (error)\n\t\t\tgoto out;\n\t}\n\tif (target && !new_is_dir) {\n\t\terror = try_break_deleg(target, delegated_inode);\n\t\tif (error)\n\t\t\tgoto out;\n\t}\n\terror = old_dir->i_op->rename(old_dir, old_dentry,\n\t\t\t\t new_dir, new_dentry, flags);\n\tif (error)\n\t\tgoto out;\n\n\tif (!(flags & RENAME_EXCHANGE) && target) {\n\t\tif (is_dir)\n\t\t\ttarget->i_flags |= S_DEAD;\n\t\tdont_mount(new_dentry);\n\t\tdetach_mounts(new_dentry);\n\t}\n\tif (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) {\n\t\tif (!(flags & RENAME_EXCHANGE))\n\t\t\td_move(old_dentry, new_dentry);\n\t\telse\n\t\t\td_exchange(old_dentry, new_dentry);\n\t}\nout:\n\tif (!is_dir || (flags & RENAME_EXCHANGE))\n\t\tunlock_two_nondirectories(source, target);\n\telse if (target)\n\t\tinode_unlock(target);\n\tdput(new_dentry);\n\tif (!error) {\n\t\tfsnotify_move(old_dir, new_dir, old_name.name, is_dir,\n\t\t\t !(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry);\n\t\tif (flags & RENAME_EXCHANGE) {\n\t\t\tfsnotify_move(new_dir, old_dir, old_dentry->d_name.name,\n\t\t\t\t new_is_dir, NULL, new_dentry);\n\t\t}\n\t}\n\trelease_dentry_name_snapshot(&old_name);\n\n\treturn error;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7533", "cwe_id": "CWE-362" }, { "id": 2177, "func": "bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,\n\t\t\t\t struct net_device *dev)\n{\n\tstruct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);\n\tstruct ieee80211_radiotap_iterator iterator;\n\tstruct ieee80211_radiotap_header *rthdr =\n\t\t(struct ieee80211_radiotap_header *) skb->data;\n\tstruct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);\n\tstruct ieee80211_supported_band *sband =\n\t\tlocal->hw.wiphy->bands[info->band];\n\tint ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len,\n\t\t\t\t\t\t NULL);\n\tu16 txflags;\n\tu16 rate = 0;\n\tbool rate_found = false;\n\tu8 rate_retries = 0;\n\tu16 rate_flags = 0;\n\tu8 mcs_known, mcs_flags, mcs_bw;\n\tu16 vht_known;\n\tu8 vht_mcs = 0, vht_nss = 0;\n\tint i;\n\n\t/* check for not even having the fixed radiotap header part */\n\tif (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header)))\n\t\treturn false; /* too short to be possibly valid */\n\n\t/* is it a header version we can trust to find length from? */\n\tif (unlikely(rthdr->it_version))\n\t\treturn false; /* only version 0 is supported */\n\n\t/* does the skb contain enough to deliver on the alleged length? */\n\tif (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data)))\n\t\treturn false; /* skb too short for claimed rt header extent */\n\n\tinfo->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT |\n\t\t IEEE80211_TX_CTL_DONTFRAG;\n\n\t/*\n\t * for every radiotap entry that is present\n\t * (ieee80211_radiotap_iterator_next returns -ENOENT when no more\n\t * entries present, or -EINVAL on error)\n\t */\n\n\twhile (!ret) {\n\t\tret = ieee80211_radiotap_iterator_next(&iterator);\n\n\t\tif (ret)\n\t\t\tcontinue;\n\n\t\t/* see if this argument is something we can use */\n\t\tswitch (iterator.this_arg_index) {\n\t\t/*\n\t\t * You must take care when dereferencing iterator.this_arg\n\t\t * for multibyte types... the pointer is not aligned. Use\n\t\t * get_unaligned((type *)iterator.this_arg) to dereference\n\t\t * iterator.this_arg for type \"type\" safely on all arches.\n\t\t*/\n\t\tcase IEEE80211_RADIOTAP_FLAGS:\n\t\t\tif (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) {\n\t\t\t\t/*\n\t\t\t\t * this indicates that the skb we have been\n\t\t\t\t * handed has the 32-bit FCS CRC at the end...\n\t\t\t\t * we should react to that by snipping it off\n\t\t\t\t * because it will be recomputed and added\n\t\t\t\t * on transmission\n\t\t\t\t */\n\t\t\t\tif (skb->len < (iterator._max_length + FCS_LEN))\n\t\t\t\t\treturn false;\n\n\t\t\t\tskb_trim(skb, skb->len - FCS_LEN);\n\t\t\t}\n\t\t\tif (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP)\n\t\t\t\tinfo->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT;\n\t\t\tif (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG)\n\t\t\t\tinfo->flags &= ~IEEE80211_TX_CTL_DONTFRAG;\n\t\t\tbreak;\n\n\t\tcase IEEE80211_RADIOTAP_TX_FLAGS:\n\t\t\ttxflags = get_unaligned_le16(iterator.this_arg);\n\t\t\tif (txflags & IEEE80211_RADIOTAP_F_TX_NOACK)\n\t\t\t\tinfo->flags |= IEEE80211_TX_CTL_NO_ACK;\n\t\t\tif (txflags & IEEE80211_RADIOTAP_F_TX_NOSEQNO)\n\t\t\t\tinfo->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO;\n\t\t\tif (txflags & IEEE80211_RADIOTAP_F_TX_ORDER)\n\t\t\t\tinfo->control.flags |=\n\t\t\t\t\tIEEE80211_TX_CTRL_DONT_REORDER;\n\t\t\tbreak;\n\n\t\tcase IEEE80211_RADIOTAP_RATE:\n\t\t\trate = *iterator.this_arg;\n\t\t\trate_flags = 0;\n\t\t\trate_found = true;\n\t\t\tbreak;\n\n\t\tcase IEEE80211_RADIOTAP_DATA_RETRIES:\n\t\t\trate_retries = *iterator.this_arg;\n\t\t\tbreak;\n\n\t\tcase IEEE80211_RADIOTAP_MCS:\n\t\t\tmcs_known = iterator.this_arg[0];\n\t\t\tmcs_flags = iterator.this_arg[1];\n\t\t\tif (!(mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_MCS))\n\t\t\t\tbreak;\n\n\t\t\trate_found = true;\n\t\t\trate = iterator.this_arg[2];\n\t\t\trate_flags = IEEE80211_TX_RC_MCS;\n\n\t\t\tif (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_GI &&\n\t\t\t mcs_flags & IEEE80211_RADIOTAP_MCS_SGI)\n\t\t\t\trate_flags |= IEEE80211_TX_RC_SHORT_GI;\n\n\t\t\tmcs_bw = mcs_flags & IEEE80211_RADIOTAP_MCS_BW_MASK;\n\t\t\tif (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_BW &&\n\t\t\t mcs_bw == IEEE80211_RADIOTAP_MCS_BW_40)\n\t\t\t\trate_flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;\n\n\t\t\tif (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_FEC &&\n\t\t\t mcs_flags & IEEE80211_RADIOTAP_MCS_FEC_LDPC)\n\t\t\t\tinfo->flags |= IEEE80211_TX_CTL_LDPC;\n\n\t\t\tif (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_STBC) {\n\t\t\t\tu8 stbc = u8_get_bits(mcs_flags,\n\t\t\t\t\t\t IEEE80211_RADIOTAP_MCS_STBC_MASK);\n\n\t\t\t\tinfo->flags |=\n\t\t\t\t\tu32_encode_bits(stbc,\n\t\t\t\t\t\t\tIEEE80211_TX_CTL_STBC);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase IEEE80211_RADIOTAP_VHT:\n\t\t\tvht_known = get_unaligned_le16(iterator.this_arg);\n\t\t\trate_found = true;\n\n\t\t\trate_flags = IEEE80211_TX_RC_VHT_MCS;\n\t\t\tif ((vht_known & IEEE80211_RADIOTAP_VHT_KNOWN_GI) &&\n\t\t\t (iterator.this_arg[2] &\n\t\t\t IEEE80211_RADIOTAP_VHT_FLAG_SGI))\n\t\t\t\trate_flags |= IEEE80211_TX_RC_SHORT_GI;\n\t\t\tif (vht_known &\n\t\t\t IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH) {\n\t\t\t\tif (iterator.this_arg[3] == 1)\n\t\t\t\t\trate_flags |=\n\t\t\t\t\t\tIEEE80211_TX_RC_40_MHZ_WIDTH;\n\t\t\t\telse if (iterator.this_arg[3] == 4)\n\t\t\t\t\trate_flags |=\n\t\t\t\t\t\tIEEE80211_TX_RC_80_MHZ_WIDTH;\n\t\t\t\telse if (iterator.this_arg[3] == 11)\n\t\t\t\t\trate_flags |=\n\t\t\t\t\t\tIEEE80211_TX_RC_160_MHZ_WIDTH;\n\t\t\t}\n\n\t\t\tvht_mcs = iterator.this_arg[4] >> 4;\n\t\t\tvht_nss = iterator.this_arg[4] & 0xF;\n\t\t\tbreak;\n\n\t\t/*\n\t\t * Please update the file\n\t\t * Documentation/networking/mac80211-injection.rst\n\t\t * when parsing new fields here.\n\t\t */\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (ret != -ENOENT) /* ie, if we didn't simply run out of fields */\n\t\treturn false;\n\n\tif (rate_found) {\n\t\tinfo->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT;\n\n\t\tfor (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {\n\t\t\tinfo->control.rates[i].idx = -1;\n\t\t\tinfo->control.rates[i].flags = 0;\n\t\t\tinfo->control.rates[i].count = 0;\n\t\t}\n\n\t\tif (rate_flags & IEEE80211_TX_RC_MCS) {\n\t\t\tinfo->control.rates[0].idx = rate;\n\t\t} else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) {\n\t\t\tieee80211_rate_set_vht(info->control.rates, vht_mcs,\n\t\t\t\t\t vht_nss);\n\t\t} else {\n\t\t\tfor (i = 0; i < sband->n_bitrates; i++) {\n\t\t\t\tif (rate * 5 != sband->bitrates[i].bitrate)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tinfo->control.rates[0].idx = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (info->control.rates[0].idx < 0)\n\t\t\tinfo->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT;\n\n\t\tinfo->control.rates[0].flags = rate_flags;\n\t\tinfo->control.rates[0].count = min_t(u8, rate_retries + 1,\n\t\t\t\t\t\t local->hw.max_rate_tries);\n\t}\n\n\treturn true;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-38206", "cwe_id": "CWE-476" }, { "id": 2177, "func": "bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,\n\t\t\t\t struct net_device *dev)\n{\n\tstruct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);\n\tstruct ieee80211_radiotap_iterator iterator;\n\tstruct ieee80211_radiotap_header *rthdr =\n\t\t(struct ieee80211_radiotap_header *) skb->data;\n\tstruct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);\n\tint ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len,\n\t\t\t\t\t\t NULL);\n\tu16 txflags;\n\tu16 rate = 0;\n\tbool rate_found = false;\n\tu8 rate_retries = 0;\n\tu16 rate_flags = 0;\n\tu8 mcs_known, mcs_flags, mcs_bw;\n\tu16 vht_known;\n\tu8 vht_mcs = 0, vht_nss = 0;\n\tint i;\n\n\tif (!ieee80211_validate_radiotap_len(skb))\n\t\treturn false;\n\n\tinfo->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT |\n\t\t IEEE80211_TX_CTL_DONTFRAG;\n\n\t/*\n\t * for every radiotap entry that is present\n\t * (ieee80211_radiotap_iterator_next returns -ENOENT when no more\n\t * entries present, or -EINVAL on error)\n\t */\n\n\twhile (!ret) {\n\t\tret = ieee80211_radiotap_iterator_next(&iterator);\n\n\t\tif (ret)\n\t\t\tcontinue;\n\n\t\t/* see if this argument is something we can use */\n\t\tswitch (iterator.this_arg_index) {\n\t\t/*\n\t\t * You must take care when dereferencing iterator.this_arg\n\t\t * for multibyte types... the pointer is not aligned. Use\n\t\t * get_unaligned((type *)iterator.this_arg) to dereference\n\t\t * iterator.this_arg for type \"type\" safely on all arches.\n\t\t*/\n\t\tcase IEEE80211_RADIOTAP_FLAGS:\n\t\t\tif (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) {\n\t\t\t\t/*\n\t\t\t\t * this indicates that the skb we have been\n\t\t\t\t * handed has the 32-bit FCS CRC at the end...\n\t\t\t\t * we should react to that by snipping it off\n\t\t\t\t * because it will be recomputed and added\n\t\t\t\t * on transmission\n\t\t\t\t */\n\t\t\t\tif (skb->len < (iterator._max_length + FCS_LEN))\n\t\t\t\t\treturn false;\n\n\t\t\t\tskb_trim(skb, skb->len - FCS_LEN);\n\t\t\t}\n\t\t\tif (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP)\n\t\t\t\tinfo->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT;\n\t\t\tif (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG)\n\t\t\t\tinfo->flags &= ~IEEE80211_TX_CTL_DONTFRAG;\n\t\t\tbreak;\n\n\t\tcase IEEE80211_RADIOTAP_TX_FLAGS:\n\t\t\ttxflags = get_unaligned_le16(iterator.this_arg);\n\t\t\tif (txflags & IEEE80211_RADIOTAP_F_TX_NOACK)\n\t\t\t\tinfo->flags |= IEEE80211_TX_CTL_NO_ACK;\n\t\t\tif (txflags & IEEE80211_RADIOTAP_F_TX_NOSEQNO)\n\t\t\t\tinfo->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO;\n\t\t\tif (txflags & IEEE80211_RADIOTAP_F_TX_ORDER)\n\t\t\t\tinfo->control.flags |=\n\t\t\t\t\tIEEE80211_TX_CTRL_DONT_REORDER;\n\t\t\tbreak;\n\n\t\tcase IEEE80211_RADIOTAP_RATE:\n\t\t\trate = *iterator.this_arg;\n\t\t\trate_flags = 0;\n\t\t\trate_found = true;\n\t\t\tbreak;\n\n\t\tcase IEEE80211_RADIOTAP_DATA_RETRIES:\n\t\t\trate_retries = *iterator.this_arg;\n\t\t\tbreak;\n\n\t\tcase IEEE80211_RADIOTAP_MCS:\n\t\t\tmcs_known = iterator.this_arg[0];\n\t\t\tmcs_flags = iterator.this_arg[1];\n\t\t\tif (!(mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_MCS))\n\t\t\t\tbreak;\n\n\t\t\trate_found = true;\n\t\t\trate = iterator.this_arg[2];\n\t\t\trate_flags = IEEE80211_TX_RC_MCS;\n\n\t\t\tif (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_GI &&\n\t\t\t mcs_flags & IEEE80211_RADIOTAP_MCS_SGI)\n\t\t\t\trate_flags |= IEEE80211_TX_RC_SHORT_GI;\n\n\t\t\tmcs_bw = mcs_flags & IEEE80211_RADIOTAP_MCS_BW_MASK;\n\t\t\tif (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_BW &&\n\t\t\t mcs_bw == IEEE80211_RADIOTAP_MCS_BW_40)\n\t\t\t\trate_flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;\n\n\t\t\tif (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_FEC &&\n\t\t\t mcs_flags & IEEE80211_RADIOTAP_MCS_FEC_LDPC)\n\t\t\t\tinfo->flags |= IEEE80211_TX_CTL_LDPC;\n\n\t\t\tif (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_STBC) {\n\t\t\t\tu8 stbc = u8_get_bits(mcs_flags,\n\t\t\t\t\t\t IEEE80211_RADIOTAP_MCS_STBC_MASK);\n\n\t\t\t\tinfo->flags |=\n\t\t\t\t\tu32_encode_bits(stbc,\n\t\t\t\t\t\t\tIEEE80211_TX_CTL_STBC);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase IEEE80211_RADIOTAP_VHT:\n\t\t\tvht_known = get_unaligned_le16(iterator.this_arg);\n\t\t\trate_found = true;\n\n\t\t\trate_flags = IEEE80211_TX_RC_VHT_MCS;\n\t\t\tif ((vht_known & IEEE80211_RADIOTAP_VHT_KNOWN_GI) &&\n\t\t\t (iterator.this_arg[2] &\n\t\t\t IEEE80211_RADIOTAP_VHT_FLAG_SGI))\n\t\t\t\trate_flags |= IEEE80211_TX_RC_SHORT_GI;\n\t\t\tif (vht_known &\n\t\t\t IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH) {\n\t\t\t\tif (iterator.this_arg[3] == 1)\n\t\t\t\t\trate_flags |=\n\t\t\t\t\t\tIEEE80211_TX_RC_40_MHZ_WIDTH;\n\t\t\t\telse if (iterator.this_arg[3] == 4)\n\t\t\t\t\trate_flags |=\n\t\t\t\t\t\tIEEE80211_TX_RC_80_MHZ_WIDTH;\n\t\t\t\telse if (iterator.this_arg[3] == 11)\n\t\t\t\t\trate_flags |=\n\t\t\t\t\t\tIEEE80211_TX_RC_160_MHZ_WIDTH;\n\t\t\t}\n\n\t\t\tvht_mcs = iterator.this_arg[4] >> 4;\n\t\t\tvht_nss = iterator.this_arg[4] & 0xF;\n\t\t\tbreak;\n\n\t\t/*\n\t\t * Please update the file\n\t\t * Documentation/networking/mac80211-injection.rst\n\t\t * when parsing new fields here.\n\t\t */\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (ret != -ENOENT) /* ie, if we didn't simply run out of fields */\n\t\treturn false;\n\n\tif (rate_found) {\n\t\tstruct ieee80211_supported_band *sband =\n\t\t\tlocal->hw.wiphy->bands[info->band];\n\n\t\tinfo->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT;\n\n\t\tfor (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {\n\t\t\tinfo->control.rates[i].idx = -1;\n\t\t\tinfo->control.rates[i].flags = 0;\n\t\t\tinfo->control.rates[i].count = 0;\n\t\t}\n\n\t\tif (rate_flags & IEEE80211_TX_RC_MCS) {\n\t\t\tinfo->control.rates[0].idx = rate;\n\t\t} else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) {\n\t\t\tieee80211_rate_set_vht(info->control.rates, vht_mcs,\n\t\t\t\t\t vht_nss);\n\t\t} else if (sband) {\n\t\t\tfor (i = 0; i < sband->n_bitrates; i++) {\n\t\t\t\tif (rate * 5 != sband->bitrates[i].bitrate)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tinfo->control.rates[0].idx = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (info->control.rates[0].idx < 0)\n\t\t\tinfo->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT;\n\n\t\tinfo->control.rates[0].flags = rate_flags;\n\t\tinfo->control.rates[0].count = min_t(u8, rate_retries + 1,\n\t\t\t\t\t\t local->hw.max_rate_tries);\n\t}\n\n\treturn true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-38206", "cwe_id": "CWE-476" }, { "id": 151, "func": "inline TfLiteStatus EvalImpl(TfLiteContext* context, TfLiteNode* node,\n std::function func,\n TfLiteType expected_type) {\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output = GetOutput(context, node, 0);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, expected_type);\n const int64_t num_elements = NumElements(input);\n const T* in_data = GetTensorData(input);\n T* out_data = GetTensorData(output);\n for (int64_t i = 0; i < num_elements; ++i) {\n out_data[i] = func(in_data[i]);\n }\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 151, "func": "inline TfLiteStatus EvalImpl(TfLiteContext* context, TfLiteNode* node,\n std::function func,\n TfLiteType expected_type) {\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, expected_type);\n const int64_t num_elements = NumElements(input);\n const T* in_data = GetTensorData(input);\n T* out_data = GetTensorData(output);\n for (int64_t i = 0; i < num_elements; ++i) {\n out_data[i] = func(in_data[i]);\n }\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 405, "func": " void DoCompute(OpKernelContext* c) {\n core::RefCountPtr v;\n OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v));\n Tensor* params = v->tensor();\n const Tensor& indices = c->input(1);\n const Tensor& updates = c->input(2);\n\n // Check that rank(updates.shape) = rank(indices.shape + params.shape[1:])\n OP_REQUIRES(c,\n updates.dims() == 0 ||\n updates.dims() == indices.dims() + params->dims() - 1,\n errors::InvalidArgument(\n \"Must have updates.shape = indices.shape + \"\n \"params.shape[1:] or updates.shape = [], got \",\n \"updates.shape \", updates.shape().DebugString(),\n \", indices.shape \", indices.shape().DebugString(),\n \", params.shape \", params->shape().DebugString()));\n\n // Check that we have enough index space\n const int64_t N_big = indices.NumElements();\n OP_REQUIRES(\n c, N_big <= std::numeric_limits::max(),\n errors::InvalidArgument(\"indices has too many elements for \",\n DataTypeString(DataTypeToEnum::v()),\n \" indexing: \", N_big, \" > \",\n std::numeric_limits::max()));\n const Index N = static_cast(N_big);\n OP_REQUIRES(\n c, params->dim_size(0) <= std::numeric_limits::max(),\n errors::InvalidArgument(\"params.shape[0] too large for \",\n DataTypeString(DataTypeToEnum::v()),\n \" indexing: \", params->dim_size(0), \" > \",\n std::numeric_limits::max()));\n\n if (N > 0) {\n auto indices_flat = indices.flat();\n auto params_flat = params->flat_outer_dims();\n if (TensorShapeUtils::IsScalar(updates.shape())) {\n const auto update = updates.scalar();\n\n functor::ScatterScalarFunctor functor;\n const Index bad_i = functor(c, c->template eigen_device(),\n params_flat, update, indices_flat);\n OP_REQUIRES(c, bad_i < 0,\n errors::InvalidArgument(\n \"indices\", SliceDebugString(indices.shape(), bad_i),\n \" = \", indices_flat(bad_i), \" is not in [0, \",\n params->dim_size(0), \")\"));\n } else {\n int64_t num_updates = updates.NumElements();\n OP_REQUIRES(c, num_updates % N == 0,\n errors::InvalidArgument(\n \"shape of indices (\", indices.shape().DebugString(),\n \") is not compatible with the shape of updates (\",\n updates.shape().DebugString(), \")\"));\n auto updates_flat = updates.shaped({N, num_updates / N});\n\n functor::ScatterFunctor functor;\n const Index bad_i = functor(c, c->template eigen_device(),\n params_flat, updates_flat, indices_flat);\n OP_REQUIRES(c, bad_i < 0,\n errors::InvalidArgument(\n \"indices\", SliceDebugString(indices.shape(), bad_i),\n \" = \", indices_flat(bad_i), \" is not in [0, \",\n params->dim_size(0), \")\"));\n }\n }\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-37655", "cwe_id": "CWE-125" }, { "id": 405, "func": " void DoCompute(OpKernelContext* c) {\n core::RefCountPtr v;\n OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v));\n Tensor* params = v->tensor();\n const Tensor& indices = c->input(1);\n const Tensor& updates = c->input(2);\n\n // Check that rank(updates.shape) = rank(indices.shape + params.shape[1:])\n OP_REQUIRES(c,\n updates.dims() == 0 ||\n updates.dims() == indices.dims() + params->dims() - 1,\n errors::InvalidArgument(\n \"Must have updates.shape = indices.shape + \"\n \"params.shape[1:] or updates.shape = [], got \",\n \"updates.shape \", updates.shape().DebugString(),\n \", indices.shape \", indices.shape().DebugString(),\n \", params.shape \", params->shape().DebugString()));\n\n // Check that we have enough index space\n const int64_t N_big = indices.NumElements();\n OP_REQUIRES(\n c, N_big <= std::numeric_limits::max(),\n errors::InvalidArgument(\"indices has too many elements for \",\n DataTypeString(DataTypeToEnum::v()),\n \" indexing: \", N_big, \" > \",\n std::numeric_limits::max()));\n const Index N = static_cast(N_big);\n OP_REQUIRES(\n c, params->dim_size(0) <= std::numeric_limits::max(),\n errors::InvalidArgument(\"params.shape[0] too large for \",\n DataTypeString(DataTypeToEnum::v()),\n \" indexing: \", params->dim_size(0), \" > \",\n std::numeric_limits::max()));\n\n if (N > 0) {\n auto indices_flat = indices.flat();\n auto params_flat = params->flat_outer_dims();\n if (TensorShapeUtils::IsScalar(updates.shape())) {\n const auto update = updates.scalar();\n\n functor::ScatterScalarFunctor functor;\n const Index bad_i = functor(c, c->template eigen_device(),\n params_flat, update, indices_flat);\n OP_REQUIRES(c, bad_i < 0,\n errors::InvalidArgument(\n \"indices\", SliceDebugString(indices.shape(), bad_i),\n \" = \", indices_flat(bad_i), \" is not in [0, \",\n params->dim_size(0), \")\"));\n } else {\n int64_t num_updates = updates.NumElements();\n OP_REQUIRES(\n c, TensorShapeUtils::StartsWith(updates.shape(), indices.shape()),\n errors::InvalidArgument(\n \"The shape of indices (\", indices.shape().DebugString(),\n \") must be a prefix of the shape of updates (\",\n updates.shape().DebugString(), \")\"));\n auto updates_flat = updates.shaped({N, num_updates / N});\n\n functor::ScatterFunctor functor;\n const Index bad_i = functor(c, c->template eigen_device(),\n params_flat, updates_flat, indices_flat);\n OP_REQUIRES(c, bad_i < 0,\n errors::InvalidArgument(\n \"indices\", SliceDebugString(indices.shape(), bad_i),\n \" = \", indices_flat(bad_i), \" is not in [0, \",\n params->dim_size(0), \")\"));\n }\n }\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-37655", "cwe_id": "CWE-125" }, { "id": 711, "func": "static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)\n{\n AC3HeaderInfo *hdr = NULL;\n struct eac3_info *info;\n int num_blocks, ret;\n\n if (!track->eac3_priv && !(track->eac3_priv = av_mallocz(sizeof(*info))))\n return AVERROR(ENOMEM);\n info = track->eac3_priv;\n\n if (avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) < 0) {\n /* drop the packets until we see a good one */\n if (!track->entry) {\n av_log(mov, AV_LOG_WARNING, \"Dropping invalid packet from start of the stream\\n\");\n ret = 0;\n } else\n ret = AVERROR_INVALIDDATA;\n goto end;\n }\n\n info->data_rate = FFMAX(info->data_rate, hdr->bit_rate / 1000);\n num_blocks = hdr->num_blocks;\n\n if (!info->ec3_done) {\n /* AC-3 substream must be the first one */\n if (hdr->bitstream_id <= 10 && hdr->substreamid != 0) {\n ret = AVERROR(EINVAL);\n goto end;\n }\n\n /* this should always be the case, given that our AC-3 parser\n * concatenates dependent frames to their independent parent */\n if (hdr->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {\n /* substream ids must be incremental */\n if (hdr->substreamid > info->num_ind_sub + 1) {\n ret = AVERROR(EINVAL);\n goto end;\n }\n\n if (hdr->substreamid == info->num_ind_sub + 1) {\n //info->num_ind_sub++;\n avpriv_request_sample(track->par, \"Multiple independent substreams\");\n ret = AVERROR_PATCHWELCOME;\n goto end;\n } else if (hdr->substreamid < info->num_ind_sub ||\n hdr->substreamid == 0 && info->substream[0].bsid) {\n info->ec3_done = 1;\n goto concatenate;\n }\n } else {\n if (hdr->substreamid != 0) {\n avpriv_request_sample(mov->fc, \"Multiple non EAC3 independent substreams\");\n ret = AVERROR_PATCHWELCOME;\n goto end;\n }\n }\n\n /* fill the info needed for the \"dec3\" atom */\n info->substream[hdr->substreamid].fscod = hdr->sr_code;\n info->substream[hdr->substreamid].bsid = hdr->bitstream_id;\n info->substream[hdr->substreamid].bsmod = hdr->bitstream_mode;\n info->substream[hdr->substreamid].acmod = hdr->channel_mode;\n info->substream[hdr->substreamid].lfeon = hdr->lfe_on;\n\n /* Parse dependent substream(s), if any */\n if (pkt->size != hdr->frame_size) {\n int cumul_size = hdr->frame_size;\n int parent = hdr->substreamid;\n\n while (cumul_size != pkt->size) {\n GetBitContext gbc;\n int i;\n ret = avpriv_ac3_parse_header(&hdr, pkt->data + cumul_size, pkt->size - cumul_size);\n if (ret < 0)\n goto end;\n if (hdr->frame_type != EAC3_FRAME_TYPE_DEPENDENT) {\n ret = AVERROR(EINVAL);\n goto end;\n }\n info->substream[parent].num_dep_sub++;\n ret /= 8;\n\n /* header is parsed up to lfeon, but custom channel map may be needed */\n init_get_bits8(&gbc, pkt->data + cumul_size + ret, pkt->size - cumul_size - ret);\n /* skip bsid */\n skip_bits(&gbc, 5);\n /* skip volume control params */\n for (i = 0; i < (hdr->channel_mode ? 1 : 2); i++) {\n skip_bits(&gbc, 5); // skip dialog normalization\n if (get_bits1(&gbc)) {\n skip_bits(&gbc, 8); // skip compression gain word\n }\n }\n /* get the dependent stream channel map, if exists */\n if (get_bits1(&gbc))\n info->substream[parent].chan_loc |= (get_bits(&gbc, 16) >> 5) & 0x1f;\n else\n info->substream[parent].chan_loc |= hdr->channel_mode;\n cumul_size += hdr->frame_size;\n }\n }\n }\n\nconcatenate:\n if (!info->num_blocks && num_blocks == 6) {\n ret = pkt->size;\n goto end;\n }\n else if (info->num_blocks + num_blocks > 6) {\n ret = AVERROR_INVALIDDATA;\n goto end;\n }\n\n if (!info->num_blocks) {\n ret = av_packet_ref(&info->pkt, pkt);\n if (!ret)\n info->num_blocks = num_blocks;\n goto end;\n } else {\n if ((ret = av_grow_packet(&info->pkt, pkt->size)) < 0)\n goto end;\n memcpy(info->pkt.data + info->pkt.size - pkt->size, pkt->data, pkt->size);\n info->num_blocks += num_blocks;\n info->pkt.duration += pkt->duration;\n if ((ret = av_copy_packet_side_data(&info->pkt, pkt)) < 0)\n goto end;\n if (info->num_blocks != 6)\n goto end;\n av_packet_unref(pkt);\n av_packet_move_ref(pkt, &info->pkt);\n info->num_blocks = 0;\n }\n ret = pkt->size;\n\nend:\n av_free(hdr);\n\n return ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-13300", "cwe_id": "CWE-125" }, { "id": 711, "func": "static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)\n{\n AC3HeaderInfo *hdr = NULL;\n struct eac3_info *info;\n int num_blocks, ret;\n\n if (!track->eac3_priv && !(track->eac3_priv = av_mallocz(sizeof(*info))))\n return AVERROR(ENOMEM);\n info = track->eac3_priv;\n\n if (avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) < 0) {\n /* drop the packets until we see a good one */\n if (!track->entry) {\n av_log(mov, AV_LOG_WARNING, \"Dropping invalid packet from start of the stream\\n\");\n ret = 0;\n } else\n ret = AVERROR_INVALIDDATA;\n goto end;\n }\n\n info->data_rate = FFMAX(info->data_rate, hdr->bit_rate / 1000);\n num_blocks = hdr->num_blocks;\n\n if (!info->ec3_done) {\n /* AC-3 substream must be the first one */\n if (hdr->bitstream_id <= 10 && hdr->substreamid != 0) {\n ret = AVERROR(EINVAL);\n goto end;\n }\n\n /* this should always be the case, given that our AC-3 parser\n * concatenates dependent frames to their independent parent */\n if (hdr->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {\n /* substream ids must be incremental */\n if (hdr->substreamid > info->num_ind_sub + 1) {\n ret = AVERROR(EINVAL);\n goto end;\n }\n\n if (hdr->substreamid == info->num_ind_sub + 1) {\n //info->num_ind_sub++;\n avpriv_request_sample(mov->fc, \"Multiple independent substreams\");\n ret = AVERROR_PATCHWELCOME;\n goto end;\n } else if (hdr->substreamid < info->num_ind_sub ||\n hdr->substreamid == 0 && info->substream[0].bsid) {\n info->ec3_done = 1;\n goto concatenate;\n }\n } else {\n if (hdr->substreamid != 0) {\n avpriv_request_sample(mov->fc, \"Multiple non EAC3 independent substreams\");\n ret = AVERROR_PATCHWELCOME;\n goto end;\n }\n }\n\n /* fill the info needed for the \"dec3\" atom */\n info->substream[hdr->substreamid].fscod = hdr->sr_code;\n info->substream[hdr->substreamid].bsid = hdr->bitstream_id;\n info->substream[hdr->substreamid].bsmod = hdr->bitstream_mode;\n info->substream[hdr->substreamid].acmod = hdr->channel_mode;\n info->substream[hdr->substreamid].lfeon = hdr->lfe_on;\n\n /* Parse dependent substream(s), if any */\n if (pkt->size != hdr->frame_size) {\n int cumul_size = hdr->frame_size;\n int parent = hdr->substreamid;\n\n while (cumul_size != pkt->size) {\n GetBitContext gbc;\n int i;\n ret = avpriv_ac3_parse_header(&hdr, pkt->data + cumul_size, pkt->size - cumul_size);\n if (ret < 0)\n goto end;\n if (hdr->frame_type != EAC3_FRAME_TYPE_DEPENDENT) {\n ret = AVERROR(EINVAL);\n goto end;\n }\n info->substream[parent].num_dep_sub++;\n ret /= 8;\n\n /* header is parsed up to lfeon, but custom channel map may be needed */\n init_get_bits8(&gbc, pkt->data + cumul_size + ret, pkt->size - cumul_size - ret);\n /* skip bsid */\n skip_bits(&gbc, 5);\n /* skip volume control params */\n for (i = 0; i < (hdr->channel_mode ? 1 : 2); i++) {\n skip_bits(&gbc, 5); // skip dialog normalization\n if (get_bits1(&gbc)) {\n skip_bits(&gbc, 8); // skip compression gain word\n }\n }\n /* get the dependent stream channel map, if exists */\n if (get_bits1(&gbc))\n info->substream[parent].chan_loc |= (get_bits(&gbc, 16) >> 5) & 0x1f;\n else\n info->substream[parent].chan_loc |= hdr->channel_mode;\n cumul_size += hdr->frame_size;\n }\n }\n }\n\nconcatenate:\n if (!info->num_blocks && num_blocks == 6) {\n ret = pkt->size;\n goto end;\n }\n else if (info->num_blocks + num_blocks > 6) {\n ret = AVERROR_INVALIDDATA;\n goto end;\n }\n\n if (!info->num_blocks) {\n ret = av_packet_ref(&info->pkt, pkt);\n if (!ret)\n info->num_blocks = num_blocks;\n goto end;\n } else {\n if ((ret = av_grow_packet(&info->pkt, pkt->size)) < 0)\n goto end;\n memcpy(info->pkt.data + info->pkt.size - pkt->size, pkt->data, pkt->size);\n info->num_blocks += num_blocks;\n info->pkt.duration += pkt->duration;\n if ((ret = av_copy_packet_side_data(&info->pkt, pkt)) < 0)\n goto end;\n if (info->num_blocks != 6)\n goto end;\n av_packet_unref(pkt);\n av_packet_move_ref(pkt, &info->pkt);\n info->num_blocks = 0;\n }\n ret = pkt->size;\n\nend:\n av_free(hdr);\n\n return ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-13300", "cwe_id": "CWE-125" }, { "id": 2544, "func": "Status GetMatchingPaths(FileSystem* fs, Env* env, const string& pattern,\n std::vector* results) {\n results->clear();\n if (pattern.empty()) {\n return Status::OK();\n }\n\n string fixed_prefix = pattern.substr(0, pattern.find_first_of(\"*?[\\\\\"));\n string eval_pattern = pattern;\n string dir(io::Dirname(fixed_prefix));\n // If dir is empty then we need to fix up fixed_prefix and eval_pattern to\n // include . as the top level directory.\n if (dir.empty()) {\n dir = \".\";\n fixed_prefix = io::JoinPath(dir, fixed_prefix);\n eval_pattern = io::JoinPath(dir, eval_pattern);\n }\n bool is_directory = pattern[pattern.size() - 1] == '/';\n#ifdef PLATFORM_WINDOWS\n is_directory = is_directory || pattern[pattern.size() - 1] == '\\\\';\n#endif\n std::vector dirs;\n if (!is_directory) {\n dirs.emplace_back(eval_pattern);\n }\n StringPiece tmp_dir(io::Dirname(eval_pattern));\n while (tmp_dir.size() > dir.size()) {\n dirs.emplace_back(string(tmp_dir));\n tmp_dir = io::Dirname(tmp_dir);\n }\n dirs.emplace_back(dir);\n std::reverse(dirs.begin(), dirs.end());\n // Setup a parallel BFS to explore everything under dir.\n std::deque> dir_q;\n std::deque> next_dir_q;\n dir_q.emplace_back(std::make_pair(dirs[0], 0));\n Status ret; // Status to return.\n mutex results_mutex;\n condition_variable results_cond;\n mutex next_que_mutex;\n condition_variable next_que_cond;\n while (!dir_q.empty()) {\n next_dir_q.clear();\n std::vector new_rets(dir_q.size());\n auto handle_level = [fs, &results, &dir_q, &next_dir_q, &new_rets,\n &is_directory, &dirs, &results_mutex, &results_cond,\n &next_que_mutex, &next_que_cond](int i) {\n string current_dir = dir_q.at(i).first;\n int dir_index = dir_q.at(i).second;\n dir_index++;\n std::vector children;\n Status s = fs->GetChildren(current_dir, &children);\n // In case PERMISSION_DENIED is encountered, we bail here.\n if (s.code() == tensorflow::error::PERMISSION_DENIED) {\n return;\n }\n new_rets[i] = s;\n if (children.empty()) return;\n\n // children_dir_status holds is_dir status for children. It can have three\n // possible values: OK for true; FAILED_PRECONDITION for false; CANCELLED\n // if we don't calculate IsDirectory (we might do that because there isn't\n // any point in exploring that child path).\n std::vector children_dir_status;\n\n // This IsDirectory call can be expensive for some FS. Parallelizing it.\n children_dir_status.resize(children.size());\n auto handle_children = [fs, ¤t_dir, &children, &dirs, dir_index,\n is_directory, &children_dir_status](int j) {\n const string child_path = io::JoinPath(current_dir, children[j]);\n if (!fs->Match(child_path, dirs[dir_index])) {\n children_dir_status[j] =\n Status(tensorflow::error::CANCELLED, \"Operation not needed\");\n } else if (dir_index != dirs.size() - 1) {\n children_dir_status[j] = fs->IsDirectory(child_path);\n } else {\n children_dir_status[j] =\n is_directory ? fs->IsDirectory(child_path) : Status::OK();\n }\n };\n ForEach(0, children.size(), handle_children);\n\n for (size_t j = 0; j < children.size(); ++j) {\n const string child_path = io::JoinPath(current_dir, children[j]);\n // If the IsDirectory call was cancelled we bail.\n if (children_dir_status[j].code() == tensorflow::error::CANCELLED) {\n continue;\n }\n if (children_dir_status[j].ok()) {\n if (dir_index != dirs.size() - 1) {\n mutex_lock lk(next_que_mutex);\n next_dir_q.emplace_back(std::make_pair(child_path, dir_index));\n next_que_cond.notify_one();\n } else {\n mutex_lock lk(results_mutex);\n results->emplace_back(child_path);\n results_cond.notify_one();\n }\n }\n }\n };\n ForEach(0, dir_q.size(), handle_level);\n\n ret.Update(new_rets[dir_q.size() - 1]);\n std::swap(dir_q, next_dir_q);\n }\n return ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-26269", "cwe_id": "CWE-125" }, { "id": 2544, "func": "Status GetMatchingPaths(FileSystem* fs, Env* env, const string& pattern,\n std::vector* results) {\n // Check that `fs`, `env` and `results` are non-null.\n if (fs == nullptr || env == nullptr || results == nullptr) {\n return Status(tensorflow::error::INVALID_ARGUMENT,\n \"Filesystem calls GetMatchingPaths with nullptr arguments\");\n }\n\n // By design, we don't match anything on empty pattern\n results->clear();\n if (pattern.empty()) {\n return Status::OK();\n }\n\n // The pattern can contain globbing characters at multiple levels, e.g.:\n //\n // foo/ba?/baz/f*r\n //\n // To match the full pattern, we must match every prefix subpattern and then\n // operate on the children for each match. Thus, we separate all subpatterns\n // in the `dirs` vector below.\n std::vector dirs = AllDirectoryPrefixes(pattern);\n\n // We can have patterns that have several parents where no globbing is being\n // done, for example, `foo/bar/baz/*`. We don't need to expand the directories\n // which don't contain the globbing characters.\n int matching_index = GetFirstGlobbingEntry(dirs);\n\n // If we don't have globbing characters in the pattern then it specifies a\n // path in the filesystem. We add it to the result set if it exists.\n if (matching_index == dirs.size()) {\n if (fs->FileExists(pattern).ok()) {\n results->emplace_back(pattern);\n }\n return Status::OK();\n }\n\n // To expand the globbing, we do a BFS from `dirs[matching_index-1]`.\n // At every step, we work on a pair `{dir, ix}` such that `dir` is a real\n // directory, `ix < dirs.size() - 1` and `dirs[ix+1]` is a globbing pattern.\n // To expand the pattern, we select from all the children of `dir` only those\n // that match against `dirs[ix+1]`.\n // If there are more entries in `dirs` after `dirs[ix+1]` this mean we have\n // more patterns to match. So, we add to the queue only those children that\n // are also directories, paired with `ix+1`.\n // If there are no more entries in `dirs`, we return all children as part of\n // the answer.\n // Since we can get into a combinatorial explosion issue (e.g., pattern\n // `/*/*/*`), we process the queue in parallel. Each parallel processing takes\n // elements from `expand_queue` and adds them to `next_expand_queue`, after\n // which we swap these two queues (similar to double buffering algorithms).\n // PRECONDITION: `IsGlobbingPattern(dirs[0]) == false`\n // PRECONDITION: `matching_index > 0`\n // INVARIANT: If `{d, ix}` is in queue, then `d` and `dirs[ix]` are at the\n // same level in the filesystem tree.\n // INVARIANT: If `{d, _}` is in queue, then `IsGlobbingPattern(d) == false`.\n // INVARIANT: If `{d, _}` is in queue, then `d` is a real directory.\n // INVARIANT: If `{_, ix}` is in queue, then `ix < dirs.size() - 1`.\n // INVARIANT: If `{_, ix}` is in queue, `IsGlobbingPattern(dirs[ix + 1])`.\n std::deque> expand_queue;\n std::deque> next_expand_queue;\n expand_queue.emplace_back(dirs[matching_index - 1], matching_index - 1);\n\n // Adding to `result` or `new_expand_queue` need to be protected by mutexes\n // since there are multiple threads writing to these.\n mutex result_mutex;\n mutex queue_mutex;\n\n while (!expand_queue.empty()) {\n next_expand_queue.clear();\n\n // The work item for every item in `expand_queue`.\n // pattern, we process them in parallel.\n auto handle_level = [&fs, &results, &dirs, &expand_queue,\n &next_expand_queue, &result_mutex,\n &queue_mutex](int i) {\n // See invariants above, all of these are valid accesses.\n const auto& queue_item = expand_queue.at(i);\n const std::string& parent = queue_item.first;\n const int index = queue_item.second + 1;\n const std::string& match_pattern = dirs[index];\n\n // Get all children of `parent`. If this fails, return early.\n std::vector children;\n Status s = fs->GetChildren(parent, &children);\n if (s.code() == tensorflow::error::PERMISSION_DENIED) {\n return;\n }\n\n // Also return early if we don't have any children\n if (children.empty()) {\n return;\n }\n\n // Since we can get extremely many children here and on some filesystems\n // `IsDirectory` is expensive, we process the children in parallel.\n // We also check that children match the pattern in parallel, for speedup.\n // We store the status of the match and `IsDirectory` in\n // `children_status` array, one element for each children.\n std::vector children_status(children.size());\n auto handle_children = [&fs, &match_pattern, &parent, &children,\n &children_status](int j) {\n const std::string path = io::JoinPath(parent, children[j]);\n if (!fs->Match(path, match_pattern)) {\n children_status[j] =\n Status(tensorflow::error::CANCELLED, \"Operation not needed\");\n } else {\n children_status[j] = fs->IsDirectory(path);\n }\n };\n ForEach(0, children.size(), handle_children);\n\n // At this point, pairing `children` with `children_status` will tell us\n // if a children:\n // * does not match the pattern\n // * matches the pattern and is a directory\n // * matches the pattern and is not a directory\n // We fully ignore the first case.\n // If we matched the last pattern (`index == dirs.size() - 1`) then all\n // remaining children get added to the result.\n // Otherwise, only the directories get added to the next queue.\n for (size_t j = 0; j < children.size(); j++) {\n if (children_status[j].code() == tensorflow::error::CANCELLED) {\n continue;\n }\n\n const std::string path = io::JoinPath(parent, children[j]);\n if (index == dirs.size() - 1) {\n mutex_lock l(result_mutex);\n results->emplace_back(path);\n } else if (children_status[j].ok()) {\n mutex_lock l(queue_mutex);\n next_expand_queue.emplace_back(path, index);\n }\n }\n };\n ForEach(0, expand_queue.size(), handle_level);\n\n // After evaluating one level, swap the \"buffers\"\n std::swap(expand_queue, next_expand_queue);\n }\n\n return Status::OK();\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-26269", "cwe_id": "CWE-125" }, { "id": 2351, "func": " void writeBytes(const void* data, int length) {\n const U8* dataPtr = (const U8*)data;\n const U8* dataEnd = dataPtr + length;\n while (dataPtr < dataEnd) {\n int n = check(1, dataEnd - dataPtr);\n memcpy(ptr, dataPtr, n);\n ptr += n;\n dataPtr += n;\n }\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 2351, "func": " void writeBytes(const void* data, size_t length) {\n const U8* dataPtr = (const U8*)data;\n const U8* dataEnd = dataPtr + length;\n while (dataPtr < dataEnd) {\n size_t n = check(1, dataEnd - dataPtr);\n memcpy(ptr, dataPtr, n);\n ptr += n;\n dataPtr += n;\n }\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 2948, "func": "static int read_private_key(RSA *rsa)\n{\n\tint r;\n\tsc_path_t path;\n\tsc_file_t *file;\n\tconst sc_acl_entry_t *e;\n\n\tu8 buf[2048], *p = buf;\n\tsize_t bufsize, keysize;\n\n\tr = select_app_df();\n\tif (r)\n\t\treturn 1;\n\tsc_format_path(\"I0012\", &path);\n\tr = sc_select_file(card, &path, &file);\n\tif (r) {\n\t\tfprintf(stderr, \"Unable to select private key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\te = sc_file_get_acl_entry(file, SC_AC_OP_READ);\n\tif (e == NULL || e->method == SC_AC_NEVER)\n\t\treturn 10;\n\tbufsize = file->size;\n\tsc_file_free(file);\n\tr = sc_read_binary(card, 0, buf, bufsize, 0);\n\tif (r < 0) {\n\t\tfprintf(stderr, \"Unable to read private key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = r;\n\tdo {\n\t\tif (bufsize < 4)\n\t\t\treturn 3;\n\t\tkeysize = (p[0] << 8) | p[1];\n\t\tif (keysize == 0)\n\t\t\tbreak;\n\t\tif (keysize < 3)\n\t\t\treturn 3;\n\t\tif (p[2] == opt_key_num)\n\t\t\tbreak;\n\t\tp += keysize;\n\t\tbufsize -= keysize;\n\t} while (1);\n\tif (keysize == 0) {\n\t\tprintf(\"Key number %d not found.\\n\", opt_key_num);\n\t\treturn 2;\n\t}\n\treturn parse_private_key(p, keysize, rsa);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-16391", "cwe_id": "CWE-119" }, { "id": 2948, "func": "static int read_private_key(RSA *rsa)\n{\n\tint r;\n\tsc_path_t path;\n\tsc_file_t *file;\n\tconst sc_acl_entry_t *e;\n\n\tu8 buf[2048], *p = buf;\n\tsize_t bufsize, keysize;\n\n\tr = select_app_df();\n\tif (r)\n\t\treturn 1;\n\tsc_format_path(\"I0012\", &path);\n\tr = sc_select_file(card, &path, &file);\n\tif (r) {\n\t\tfprintf(stderr, \"Unable to select private key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\te = sc_file_get_acl_entry(file, SC_AC_OP_READ);\n\tif (e == NULL || e->method == SC_AC_NEVER)\n\t\treturn 10;\n\tbufsize = MIN(file->size, sizeof buf);\n\tsc_file_free(file);\n\tr = sc_read_binary(card, 0, buf, bufsize, 0);\n\tif (r < 0) {\n\t\tfprintf(stderr, \"Unable to read private key file: %s\\n\", sc_strerror(r));\n\t\treturn 2;\n\t}\n\tbufsize = r;\n\tdo {\n\t\tif (bufsize < 4)\n\t\t\treturn 3;\n\t\tkeysize = (p[0] << 8) | p[1];\n\t\tif (keysize == 0)\n\t\t\tbreak;\n\t\tif (keysize < 3)\n\t\t\treturn 3;\n\t\tif (p[2] == opt_key_num)\n\t\t\tbreak;\n\t\tp += keysize;\n\t\tbufsize -= keysize;\n\t} while (1);\n\tif (keysize == 0) {\n\t\tprintf(\"Key number %d not found.\\n\", opt_key_num);\n\t\treturn 2;\n\t}\n\treturn parse_private_key(p, keysize, rsa);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-16391", "cwe_id": "CWE-119" }, { "id": 775, "func": "Jsi_RC Jsi_ValueInsertArray(Jsi_Interp *interp, Jsi_Value *target, int key, Jsi_Value *val, int flags)\n{\n if (target->vt != JSI_VT_OBJECT) {\n if (interp->strict)\n Jsi_LogWarn(\"Target is not object\");\n return JSI_ERROR;\n }\n Jsi_Obj *obj = target->d.obj;\n \n if (obj->isarrlist) {\n if (key >= 0 && key < interp->maxArrayList) {\n Jsi_ObjArraySet(interp, obj, val, key);\n return JSI_OK;\n }\n return JSI_ERROR;\n }\n char unibuf[JSI_MAX_NUMBER_STRING];\n Jsi_NumberItoA10(key, unibuf, sizeof(unibuf));\n Jsi_ObjInsert(interp, obj, unibuf, val, flags);\n return JSI_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-22874", "cwe_id": "CWE-190" }, { "id": 775, "func": "Jsi_RC Jsi_ValueInsertArray(Jsi_Interp *interp, Jsi_Value *target, int key, Jsi_Value *val, int flags)\n{\n if (target->vt != JSI_VT_OBJECT) {\n if (interp->strict)\n Jsi_LogWarn(\"Target is not object\");\n return JSI_ERROR;\n }\n Jsi_Obj *obj = target->d.obj;\n \n if (obj->isarrlist) {\n if (key >= 0 && (uint)key < interp->maxArrayList) {\n Jsi_ObjArraySet(interp, obj, val, key);\n return JSI_OK;\n }\n return JSI_ERROR;\n }\n char unibuf[JSI_MAX_NUMBER_STRING];\n Jsi_NumberItoA10(key, unibuf, sizeof(unibuf));\n Jsi_ObjInsert(interp, obj, unibuf, val, flags);\n return JSI_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-22874", "cwe_id": "CWE-190" }, { "id": 3077, "func": "static int logi_dj_ll_raw_request(struct hid_device *hid,\n\t\t\t\t unsigned char reportnum, __u8 *buf,\n\t\t\t\t size_t count, unsigned char report_type,\n\t\t\t\t int reqtype)\n{\n\tstruct dj_device *djdev = hid->driver_data;\n\tstruct dj_receiver_dev *djrcv_dev = djdev->dj_receiver_dev;\n\tu8 *out_buf;\n\tint ret;\n\n\tif (buf[0] != REPORT_TYPE_LEDS)\n\t\treturn -EINVAL;\n\n\tout_buf = kzalloc(DJREPORT_SHORT_LENGTH, GFP_ATOMIC);\n\tif (!out_buf)\n\t\treturn -ENOMEM;\n\n\tif (count < DJREPORT_SHORT_LENGTH - 2)\n\t\tcount = DJREPORT_SHORT_LENGTH - 2;\n\n\tout_buf[0] = REPORT_ID_DJ_SHORT;\n\tout_buf[1] = djdev->device_index;\n\tmemcpy(out_buf + 2, buf, count);\n\n\tret = hid_hw_raw_request(djrcv_dev->hdev, out_buf[0], out_buf,\n\t\tDJREPORT_SHORT_LENGTH, report_type, reqtype);\n\n\tkfree(out_buf);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-3183", "cwe_id": "CWE-119" }, { "id": 3077, "func": "static int logi_dj_ll_raw_request(struct hid_device *hid,\n\t\t\t\t unsigned char reportnum, __u8 *buf,\n\t\t\t\t size_t count, unsigned char report_type,\n\t\t\t\t int reqtype)\n{\n\tstruct dj_device *djdev = hid->driver_data;\n\tstruct dj_receiver_dev *djrcv_dev = djdev->dj_receiver_dev;\n\tu8 *out_buf;\n\tint ret;\n\n\tif (buf[0] != REPORT_TYPE_LEDS)\n\t\treturn -EINVAL;\n\n\tout_buf = kzalloc(DJREPORT_SHORT_LENGTH, GFP_ATOMIC);\n\tif (!out_buf)\n\t\treturn -ENOMEM;\n\n\tif (count > DJREPORT_SHORT_LENGTH - 2)\n\t\tcount = DJREPORT_SHORT_LENGTH - 2;\n\n\tout_buf[0] = REPORT_ID_DJ_SHORT;\n\tout_buf[1] = djdev->device_index;\n\tmemcpy(out_buf + 2, buf, count);\n\n\tret = hid_hw_raw_request(djrcv_dev->hdev, out_buf[0], out_buf,\n\t\tDJREPORT_SHORT_LENGTH, report_type, reqtype);\n\n\tkfree(out_buf);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-3183", "cwe_id": "CWE-119" }, { "id": 1461, "func": "ast2obj_arguments(void* _o)\n{\n arguments_ty o = (arguments_ty)_o;\n PyObject *result = NULL, *value = NULL;\n if (!o) {\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n result = PyType_GenericNew(arguments_type, NULL, NULL);\n if (!result) return NULL;\n value = ast2obj_list(o->args, ast2obj_arg);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_arg(o->vararg);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_vararg, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_list(o->kwonlyargs, ast2obj_arg);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_kwonlyargs, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_list(o->kw_defaults, ast2obj_expr);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_arg(o->kwarg);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_kwarg, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_list(o->defaults, ast2obj_expr);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_defaults, value) == -1)\n goto failed;\n Py_DECREF(value);\n return result;\nfailed:\n Py_XDECREF(value);\n Py_XDECREF(result);\n return NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1461, "func": "ast2obj_arguments(void* _o)\n{\n arguments_ty o = (arguments_ty)_o;\n PyObject *result = NULL, *value = NULL;\n if (!o) {\n Py_RETURN_NONE;\n }\n\n result = PyType_GenericNew(arguments_type, NULL, NULL);\n if (!result) return NULL;\n value = ast2obj_list(o->args, ast2obj_arg);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_arg(o->vararg);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_vararg, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_list(o->kwonlyargs, ast2obj_arg);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_kwonlyargs, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_list(o->kw_defaults, ast2obj_expr);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_arg(o->kwarg);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_kwarg, value) == -1)\n goto failed;\n Py_DECREF(value);\n value = ast2obj_list(o->defaults, ast2obj_expr);\n if (!value) goto failed;\n if (_PyObject_SetAttrId(result, &PyId_defaults, value) == -1)\n goto failed;\n Py_DECREF(value);\n return result;\nfailed:\n Py_XDECREF(value);\n Py_XDECREF(result);\n return NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 91, "func": "static int udf_symlink_filler(struct file *file, struct page *page)\n{\n\tstruct inode *inode = page->mapping->host;\n\tstruct buffer_head *bh = NULL;\n\tunsigned char *symlink;\n\tint err = -EIO;\n\tunsigned char *p = kmap(page);\n\tstruct udf_inode_info *iinfo;\n\tuint32_t pos;\n\n\tiinfo = UDF_I(inode);\n\tpos = udf_block_map(inode, 0);\n\n\tdown_read(&iinfo->i_data_sem);\n\tif (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {\n\t\tsymlink = iinfo->i_ext.i_data + iinfo->i_lenEAttr;\n\t} else {\n\t\tbh = sb_bread(inode->i_sb, pos);\n\n\t\tif (!bh)\n\t\t\tgoto out;\n\n\t\tsymlink = bh->b_data;\n\t}\n\n\tudf_pc_to_char(inode->i_sb, symlink, inode->i_size, p);\n\tbrelse(bh);\n\n\tup_read(&iinfo->i_data_sem);\n\tSetPageUptodate(page);\n\tkunmap(page);\n\tunlock_page(page);\n\treturn 0;\n\nout:\n\tup_read(&iinfo->i_data_sem);\n\tSetPageError(page);\n\tkunmap(page);\n\tunlock_page(page);\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-9728", "cwe_id": "CWE-119" }, { "id": 91, "func": "static int udf_symlink_filler(struct file *file, struct page *page)\n{\n\tstruct inode *inode = page->mapping->host;\n\tstruct buffer_head *bh = NULL;\n\tunsigned char *symlink;\n\tint err;\n\tunsigned char *p = kmap(page);\n\tstruct udf_inode_info *iinfo;\n\tuint32_t pos;\n\n\t/* We don't support symlinks longer than one block */\n\tif (inode->i_size > inode->i_sb->s_blocksize) {\n\t\terr = -ENAMETOOLONG;\n\t\tgoto out_unmap;\n\t}\n\n\tiinfo = UDF_I(inode);\n\tpos = udf_block_map(inode, 0);\n\n\tdown_read(&iinfo->i_data_sem);\n\tif (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {\n\t\tsymlink = iinfo->i_ext.i_data + iinfo->i_lenEAttr;\n\t} else {\n\t\tbh = sb_bread(inode->i_sb, pos);\n\n\t\tif (!bh) {\n\t\t\terr = -EIO;\n\t\t\tgoto out_unlock_inode;\n\t\t}\n\n\t\tsymlink = bh->b_data;\n\t}\n\n\tudf_pc_to_char(inode->i_sb, symlink, inode->i_size, p);\n\tbrelse(bh);\n\n\tup_read(&iinfo->i_data_sem);\n\tSetPageUptodate(page);\n\tkunmap(page);\n\tunlock_page(page);\n\treturn 0;\n\nout_unlock_inode:\n\tup_read(&iinfo->i_data_sem);\n\tSetPageError(page);\nout_unmap:\n\tkunmap(page);\n\tunlock_page(page);\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-9728", "cwe_id": "CWE-119" }, { "id": 26, "func": "qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,\n\t const char *fmt, ...)\n{\n\tva_list va;\n\tstruct va_format vaf;\n\tchar nfunc[32];\n\n\tmemset(nfunc, 0, sizeof(nfunc));\n\tmemcpy(nfunc, func, sizeof(nfunc) - 1);\n\n\tva_start(va, fmt);\n\n\tvaf.fmt = fmt;\n\tvaf.va = &va;\n\n\tif (likely(qedi) && likely(qedi->pdev))\n\t\tpr_err(\"[%s]:[%s:%d]:%d: %pV\", dev_name(&qedi->pdev->dev),\n\t\t nfunc, line, qedi->host_no, &vaf);\n\telse\n\t\tpr_err(\"[0000:00:00.0]:[%s:%d]: %pV\", nfunc, line, &vaf);\n\n\tva_end(va);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15090", "cwe_id": "CWE-125" }, { "id": 26, "func": "qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,\n\t const char *fmt, ...)\n{\n\tva_list va;\n\tstruct va_format vaf;\n\n\tva_start(va, fmt);\n\n\tvaf.fmt = fmt;\n\tvaf.va = &va;\n\n\tif (likely(qedi) && likely(qedi->pdev))\n\t\tpr_err(\"[%s]:[%s:%d]:%d: %pV\", dev_name(&qedi->pdev->dev),\n\t\t func, line, qedi->host_no, &vaf);\n\telse\n\t\tpr_err(\"[0000:00:00.0]:[%s:%d]: %pV\", func, line, &vaf);\n\n\tva_end(va);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15090", "cwe_id": "CWE-125" }, { "id": 1753, "func": "webSocketsHasDataInBuffer(rfbClientPtr cl)\n{\n ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;\n\n if (wsctx && wsctx->readbuflen)\n return TRUE;\n\n return (cl->sslctx && rfbssl_pending(cl) > 0);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-18922", "cwe_id": "CWE-787" }, { "id": 1753, "func": "webSocketsHasDataInBuffer(rfbClientPtr cl)\n{\n ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;\n\n if (wsctx && wsctx->readlen)\n return TRUE;\n\n return (cl->sslctx && rfbssl_pending(cl) > 0);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-18922", "cwe_id": "CWE-787" }, { "id": 1379, "func": "static MagickBooleanType EncodeImage(const ImageInfo *image_info,Image *image,\n const size_t data_size)\n{\n#define MaxCode(number_bits) ((one << (number_bits))-1)\n#define MaxHashTable 5003\n#define MaxGIFBits 12UL\n#define MaxGIFTable (1UL << MaxGIFBits)\n#define GIFOutputCode(code) \\\n{ \\\n /* \\\n Emit a code. \\\n */ \\\n if (bits > 0) \\\n datum|=(size_t) (code) << bits; \\\n else \\\n datum=(size_t) (code); \\\n bits+=number_bits; \\\n while (bits >= 8) \\\n { \\\n /* \\\n Add a character to current packet. \\\n */ \\\n packet[length++]=(unsigned char) (datum & 0xff); \\\n if (length >= 254) \\\n { \\\n (void) WriteBlobByte(image,(unsigned char) length); \\\n (void) WriteBlob(image,length,packet); \\\n length=0; \\\n } \\\n datum>>=8; \\\n bits-=8; \\\n } \\\n if (free_code > max_code) \\\n { \\\n number_bits++; \\\n if (number_bits == MaxGIFBits) \\\n max_code=MaxGIFTable; \\\n else \\\n max_code=MaxCode(number_bits); \\\n } \\\n}\n\n IndexPacket\n index;\n\n short\n *hash_code,\n *hash_prefix,\n waiting_code;\n\n size_t\n bits,\n clear_code,\n datum,\n end_of_information_code,\n free_code,\n length,\n max_code,\n next_pixel,\n number_bits,\n one,\n pass;\n\n ssize_t\n displacement,\n offset,\n k,\n y;\n\n unsigned char\n *packet,\n *hash_suffix;\n\n /*\n Allocate encoder tables.\n */\n assert(image != (Image *) NULL);\n one=1;\n packet=(unsigned char *) AcquireQuantumMemory(256,sizeof(*packet));\n hash_code=(short *) AcquireQuantumMemory(MaxHashTable,sizeof(*hash_code));\n hash_prefix=(short *) AcquireQuantumMemory(MaxHashTable,sizeof(*hash_prefix));\n hash_suffix=(unsigned char *) AcquireQuantumMemory(MaxHashTable,\n sizeof(*hash_suffix));\n if ((packet == (unsigned char *) NULL) || (hash_code == (short *) NULL) ||\n (hash_prefix == (short *) NULL) ||\n (hash_suffix == (unsigned char *) NULL))\n {\n if (packet != (unsigned char *) NULL)\n packet=(unsigned char *) RelinquishMagickMemory(packet);\n if (hash_code != (short *) NULL)\n hash_code=(short *) RelinquishMagickMemory(hash_code);\n if (hash_prefix != (short *) NULL)\n hash_prefix=(short *) RelinquishMagickMemory(hash_prefix);\n if (hash_suffix != (unsigned char *) NULL)\n hash_suffix=(unsigned char *) RelinquishMagickMemory(hash_suffix);\n return(MagickFalse);\n }\n /*\n Initialize GIF encoder.\n */\n (void) memset(packet,0,256*sizeof(*packet));\n (void) memset(hash_code,0,MaxHashTable*sizeof(*hash_code));\n (void) memset(hash_prefix,0,MaxHashTable*sizeof(*hash_prefix));\n (void) memset(hash_suffix,0,MaxHashTable*sizeof(*hash_suffix));\n number_bits=data_size;\n max_code=MaxCode(number_bits);\n clear_code=((short) one << (data_size-1));\n end_of_information_code=clear_code+1;\n free_code=clear_code+2;\n length=0;\n datum=0;\n bits=0;\n GIFOutputCode(clear_code);\n /*\n Encode pixels.\n */\n offset=0;\n pass=0;\n waiting_code=0;\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n register const IndexPacket\n *magick_restrict indexes;\n\n register const PixelPacket\n *magick_restrict p;\n\n register ssize_t\n x;\n\n p=GetVirtualPixels(image,0,offset,image->columns,1,&image->exception);\n if (p == (const PixelPacket *) NULL)\n break;\n indexes=GetVirtualIndexQueue(image);\n if (y == 0)\n {\n waiting_code=(short) (*indexes);\n p++;\n }\n for (x=(ssize_t) (y == 0 ? 1 : 0); x < (ssize_t) image->columns; x++)\n {\n /*\n Probe hash table.\n */\n index=(IndexPacket) ((size_t) GetPixelIndex(indexes+x) & 0xff);\n p++;\n k=(ssize_t) (((size_t) index << (MaxGIFBits-8))+waiting_code);\n if (k >= MaxHashTable)\n k-=MaxHashTable;\n next_pixel=MagickFalse;\n displacement=1;\n if (hash_code[k] > 0)\n {\n if ((hash_prefix[k] == waiting_code) &&\n (hash_suffix[k] == (unsigned char) index))\n {\n waiting_code=hash_code[k];\n continue;\n }\n if (k != 0)\n displacement=MaxHashTable-k;\n for ( ; ; )\n {\n k-=displacement;\n if (k < 0)\n k+=MaxHashTable;\n if (hash_code[k] == 0)\n break;\n if ((hash_prefix[k] == waiting_code) &&\n (hash_suffix[k] == (unsigned char) index))\n {\n waiting_code=hash_code[k];\n next_pixel=MagickTrue;\n break;\n }\n }\n if (next_pixel != MagickFalse)\n continue;\n }\n GIFOutputCode(waiting_code);\n if (free_code < MaxGIFTable)\n {\n hash_code[k]=(short) free_code++;\n hash_prefix[k]=waiting_code;\n hash_suffix[k]=(unsigned char) index;\n }\n else\n {\n /*\n Fill the hash table with empty entries.\n */\n for (k=0; k < MaxHashTable; k++)\n hash_code[k]=0;\n /*\n Reset compressor and issue a clear code.\n */\n free_code=clear_code+2;\n GIFOutputCode(clear_code);\n number_bits=data_size;\n max_code=MaxCode(number_bits);\n }\n waiting_code=(short) index;\n }\n if (image_info->interlace == NoInterlace)\n offset++;\n else\n switch (pass)\n {\n case 0:\n default:\n {\n offset+=8;\n if (offset >= (ssize_t) image->rows)\n {\n pass++;\n offset=4;\n }\n break;\n }\n case 1:\n {\n offset+=8;\n if (offset >= (ssize_t) image->rows)\n {\n pass++;\n offset=2;\n }\n break;\n }\n case 2:\n {\n offset+=4;\n if (offset >= (ssize_t) image->rows)\n {\n pass++;\n offset=1;\n }\n break;\n }\n case 3:\n {\n offset+=2;\n break;\n }\n }\n }\n /*\n Flush out the buffered code.\n */\n GIFOutputCode(waiting_code);\n GIFOutputCode(end_of_information_code);\n if (bits > 0)\n {\n /*\n Add a character to current packet.\n */\n packet[length++]=(unsigned char) (datum & 0xff);\n if (length >= 254)\n {\n (void) WriteBlobByte(image,(unsigned char) length);\n (void) WriteBlob(image,length,packet);\n length=0;\n }\n }\n /*\n Flush accumulated data.\n */\n if (length > 0)\n {\n (void) WriteBlobByte(image,(unsigned char) length);\n (void) WriteBlob(image,length,packet);\n }\n /*\n Free encoder memory.\n */\n hash_suffix=(unsigned char *) RelinquishMagickMemory(hash_suffix);\n hash_prefix=(short *) RelinquishMagickMemory(hash_prefix);\n hash_code=(short *) RelinquishMagickMemory(hash_code);\n packet=(unsigned char *) RelinquishMagickMemory(packet);\n return(MagickTrue);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-13308", "cwe_id": "CWE-787" }, { "id": 1379, "func": "static MagickBooleanType EncodeImage(const ImageInfo *image_info,Image *image,\n const size_t data_size)\n{\n#define MaxCode(number_bits) ((one << (number_bits))-1)\n#define MaxHashTable 5003\n#define MaxGIFBits 12UL\n#define MaxGIFTable (1UL << MaxGIFBits)\n#define GIFOutputCode(code) \\\n{ \\\n /* \\\n Emit a code. \\\n */ \\\n if (bits > 0) \\\n datum|=(size_t) (code) << bits; \\\n else \\\n datum=(size_t) (code); \\\n bits+=number_bits; \\\n while (bits >= 8) \\\n { \\\n /* \\\n Add a character to current packet. \\\n */ \\\n packet[length++]=(unsigned char) (datum & 0xff); \\\n if (length >= 254) \\\n { \\\n (void) WriteBlobByte(image,(unsigned char) length); \\\n (void) WriteBlob(image,length,packet); \\\n length=0; \\\n } \\\n datum>>=8; \\\n bits-=8; \\\n } \\\n if (free_code > max_code) \\\n { \\\n number_bits++; \\\n if (number_bits == MaxGIFBits) \\\n max_code=MaxGIFTable; \\\n else \\\n max_code=MaxCode(number_bits); \\\n } \\\n}\n\n IndexPacket\n index;\n\n short\n *hash_code,\n *hash_prefix,\n waiting_code;\n\n size_t\n bits,\n clear_code,\n datum,\n end_of_information_code,\n free_code,\n length,\n max_code,\n next_pixel,\n number_bits,\n one,\n pass;\n\n ssize_t\n displacement,\n offset,\n k,\n y;\n\n unsigned char\n *packet,\n *hash_suffix;\n\n /*\n Allocate encoder tables.\n */\n assert(image != (Image *) NULL);\n one=1;\n packet=(unsigned char *) AcquireQuantumMemory(256,sizeof(*packet));\n hash_code=(short *) AcquireQuantumMemory(MaxHashTable,sizeof(*hash_code));\n hash_prefix=(short *) AcquireQuantumMemory(MaxHashTable,sizeof(*hash_prefix));\n hash_suffix=(unsigned char *) AcquireQuantumMemory(MaxHashTable,\n sizeof(*hash_suffix));\n if ((packet == (unsigned char *) NULL) || (hash_code == (short *) NULL) ||\n (hash_prefix == (short *) NULL) ||\n (hash_suffix == (unsigned char *) NULL))\n {\n if (packet != (unsigned char *) NULL)\n packet=(unsigned char *) RelinquishMagickMemory(packet);\n if (hash_code != (short *) NULL)\n hash_code=(short *) RelinquishMagickMemory(hash_code);\n if (hash_prefix != (short *) NULL)\n hash_prefix=(short *) RelinquishMagickMemory(hash_prefix);\n if (hash_suffix != (unsigned char *) NULL)\n hash_suffix=(unsigned char *) RelinquishMagickMemory(hash_suffix);\n return(MagickFalse);\n }\n /*\n Initialize GIF encoder.\n */\n (void) memset(packet,0,256*sizeof(*packet));\n (void) memset(hash_code,0,MaxHashTable*sizeof(*hash_code));\n (void) memset(hash_prefix,0,MaxHashTable*sizeof(*hash_prefix));\n (void) memset(hash_suffix,0,MaxHashTable*sizeof(*hash_suffix));\n number_bits=data_size;\n max_code=MaxCode(number_bits);\n clear_code=((short) one << (data_size-1));\n end_of_information_code=clear_code+1;\n free_code=clear_code+2;\n length=0;\n datum=0;\n bits=0;\n GIFOutputCode(clear_code);\n /*\n Encode pixels.\n */\n offset=0;\n pass=0;\n waiting_code=0;\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n register const IndexPacket\n *magick_restrict indexes;\n\n register const PixelPacket\n *magick_restrict p;\n\n register ssize_t\n x;\n\n p=GetVirtualPixels(image,0,offset,image->columns,1,&image->exception);\n if (p == (const PixelPacket *) NULL)\n break;\n indexes=GetVirtualIndexQueue(image);\n if (y == 0)\n {\n waiting_code=(short) (*indexes);\n p++;\n }\n for (x=(ssize_t) (y == 0 ? 1 : 0); x < (ssize_t) image->columns; x++)\n {\n /*\n Probe hash table.\n */\n next_pixel=MagickFalse;\n displacement=1;\n index=(IndexPacket) ((size_t) GetPixelIndex(indexes+x) & 0xff);\n p++;\n k=(ssize_t) (((size_t) index << (MaxGIFBits-8))+waiting_code);\n if (k >= MaxHashTable)\n k-=MaxHashTable;\n if (k < 0)\n continue;\n if (hash_code[k] > 0)\n {\n if ((hash_prefix[k] == waiting_code) &&\n (hash_suffix[k] == (unsigned char) index))\n {\n waiting_code=hash_code[k];\n continue;\n }\n if (k != 0)\n displacement=MaxHashTable-k;\n for ( ; ; )\n {\n k-=displacement;\n if (k < 0)\n k+=MaxHashTable;\n if (hash_code[k] == 0)\n break;\n if ((hash_prefix[k] == waiting_code) &&\n (hash_suffix[k] == (unsigned char) index))\n {\n waiting_code=hash_code[k];\n next_pixel=MagickTrue;\n break;\n }\n }\n if (next_pixel != MagickFalse)\n continue;\n }\n GIFOutputCode(waiting_code);\n if (free_code < MaxGIFTable)\n {\n hash_code[k]=(short) free_code++;\n hash_prefix[k]=waiting_code;\n hash_suffix[k]=(unsigned char) index;\n }\n else\n {\n /*\n Fill the hash table with empty entries.\n */\n for (k=0; k < MaxHashTable; k++)\n hash_code[k]=0;\n /*\n Reset compressor and issue a clear code.\n */\n free_code=clear_code+2;\n GIFOutputCode(clear_code);\n number_bits=data_size;\n max_code=MaxCode(number_bits);\n }\n waiting_code=(short) index;\n }\n if (image_info->interlace == NoInterlace)\n offset++;\n else\n switch (pass)\n {\n case 0:\n default:\n {\n offset+=8;\n if (offset >= (ssize_t) image->rows)\n {\n pass++;\n offset=4;\n }\n break;\n }\n case 1:\n {\n offset+=8;\n if (offset >= (ssize_t) image->rows)\n {\n pass++;\n offset=2;\n }\n break;\n }\n case 2:\n {\n offset+=4;\n if (offset >= (ssize_t) image->rows)\n {\n pass++;\n offset=1;\n }\n break;\n }\n case 3:\n {\n offset+=2;\n break;\n }\n }\n }\n /*\n Flush out the buffered code.\n */\n GIFOutputCode(waiting_code);\n GIFOutputCode(end_of_information_code);\n if (bits > 0)\n {\n /*\n Add a character to current packet.\n */\n packet[length++]=(unsigned char) (datum & 0xff);\n if (length >= 254)\n {\n (void) WriteBlobByte(image,(unsigned char) length);\n (void) WriteBlob(image,length,packet);\n length=0;\n }\n }\n /*\n Flush accumulated data.\n */\n if (length > 0)\n {\n (void) WriteBlobByte(image,(unsigned char) length);\n (void) WriteBlob(image,length,packet);\n }\n /*\n Free encoder memory.\n */\n hash_suffix=(unsigned char *) RelinquishMagickMemory(hash_suffix);\n hash_prefix=(short *) RelinquishMagickMemory(hash_prefix);\n hash_code=(short *) RelinquishMagickMemory(hash_code);\n packet=(unsigned char *) RelinquishMagickMemory(packet);\n return(MagickTrue);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-13308", "cwe_id": "CWE-787" }, { "id": 1296, "func": "SPL_METHOD(Array, unserialize)\n{\n\tspl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\n\tchar *buf;\n\tint buf_len;\n\tconst unsigned char *p, *s;\n\tphp_unserialize_data_t var_hash;\n\tzval *pmembers, *pflags = NULL;\n\tHashTable *aht;\n\tlong flags;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &buf, &buf_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (buf_len == 0) {\n\t\treturn;\n\t}\n\n\taht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);\n\tif (aht->nApplyCount > 0) {\n\t\tzend_error(E_WARNING, \"Modification of ArrayObject during sorting is prohibited\");\n\t\treturn;\n\t}\n\n\t/* storage */\n\ts = p = (const unsigned char*)buf;\n\tPHP_VAR_UNSERIALIZE_INIT(var_hash);\n\n\tif (*p!= 'x' || *++p != ':') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\tALLOC_INIT_ZVAL(pflags);\n\tif (!php_var_unserialize(&pflags, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pflags) != IS_LONG) {\n\t\tgoto outexcept;\n\t}\n\n\tvar_push_dtor(&var_hash, &pflags);\n\t--p; /* for ';' */\n\tflags = Z_LVAL_P(pflags);\n\t/* flags needs to be verified and we also need to verify whether the next\n\t * thing we get is ';'. After that we require an 'm' or somethign else\n\t * where 'm' stands for members and anything else should be an array. If\n\t * neither 'a' or 'm' follows we have an error. */\n\n\tif (*p != ';') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\tif (*p!='m') {\n\t\tif (*p!='a' && *p!='O' && *p!='C' && *p!='r') {\n\t\t\tgoto outexcept;\n\t\t}\n\t\tintern->ar_flags &= ~SPL_ARRAY_CLONE_MASK;\n\t\tintern->ar_flags |= flags & SPL_ARRAY_CLONE_MASK;\n\t\tzval_ptr_dtor(&intern->array);\n\t\tALLOC_INIT_ZVAL(intern->array);\n\t\tif (!php_var_unserialize(&intern->array, &p, s + buf_len, &var_hash TSRMLS_CC)) {\n\t\t\tgoto outexcept;\n\t\t}\n\t\tvar_push_dtor(&var_hash, &intern->array);\n\t}\n\tif (*p != ';') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\t/* members */\n\tif (*p!= 'm' || *++p != ':') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\tALLOC_INIT_ZVAL(pmembers);\n\tif (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {\n\t\tzval_ptr_dtor(&pmembers);\n\t\tgoto outexcept;\n\t}\n\n\tvar_push_dtor(&var_hash, &pmembers);\n\t/* copy members */\n\tif (!intern->std.properties) {\n\t\trebuild_object_properties(&intern->std);\n\t}\n\tzend_hash_copy(intern->std.properties, Z_ARRVAL_P(pmembers), (copy_ctor_func_t) zval_add_ref, (void *) NULL, sizeof(zval *));\n\tzval_ptr_dtor(&pmembers);\n\n\t/* done reading $serialized */\n\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\tif (pflags) {\n\t\tzval_ptr_dtor(&pflags);\n\t}\n\treturn;\n\noutexcept:\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\tif (pflags) {\n\t\tzval_ptr_dtor(&pflags);\n\t}\n\tzend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, \"Error at offset %ld of %d bytes\", (long)((char*)p - buf), buf_len);\n\treturn;\n\n} /* }}} */", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-7417", "cwe_id": "CWE-20" }, { "id": 1296, "func": "SPL_METHOD(Array, unserialize)\n{\n\tspl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC);\n\n\tchar *buf;\n\tint buf_len;\n\tconst unsigned char *p, *s;\n\tphp_unserialize_data_t var_hash;\n\tzval *pmembers, *pflags = NULL;\n\tHashTable *aht;\n\tlong flags;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &buf, &buf_len) == FAILURE) {\n\t\treturn;\n\t}\n\n\tif (buf_len == 0) {\n\t\treturn;\n\t}\n\n\taht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);\n\tif (aht->nApplyCount > 0) {\n\t\tzend_error(E_WARNING, \"Modification of ArrayObject during sorting is prohibited\");\n\t\treturn;\n\t}\n\n\t/* storage */\n\ts = p = (const unsigned char*)buf;\n\tPHP_VAR_UNSERIALIZE_INIT(var_hash);\n\n\tif (*p!= 'x' || *++p != ':') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\tALLOC_INIT_ZVAL(pflags);\n\tif (!php_var_unserialize(&pflags, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pflags) != IS_LONG) {\n\t\tgoto outexcept;\n\t}\n\n\tvar_push_dtor(&var_hash, &pflags);\n\t--p; /* for ';' */\n\tflags = Z_LVAL_P(pflags);\n\t/* flags needs to be verified and we also need to verify whether the next\n\t * thing we get is ';'. After that we require an 'm' or somethign else\n\t * where 'm' stands for members and anything else should be an array. If\n\t * neither 'a' or 'm' follows we have an error. */\n\n\tif (*p != ';') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\tif (*p!='m') {\n\t\tif (*p!='a' && *p!='O' && *p!='C' && *p!='r') {\n\t\t\tgoto outexcept;\n\t\t}\n\t\tintern->ar_flags &= ~SPL_ARRAY_CLONE_MASK;\n\t\tintern->ar_flags |= flags & SPL_ARRAY_CLONE_MASK;\n\t\tzval_ptr_dtor(&intern->array);\n\t\tALLOC_INIT_ZVAL(intern->array);\n\t\tif (!php_var_unserialize(&intern->array, &p, s + buf_len, &var_hash TSRMLS_CC)\n\t\t\t\t|| (Z_TYPE_P(intern->array) != IS_ARRAY && Z_TYPE_P(intern->array) != IS_OBJECT)) {\n\t\t\tzval_ptr_dtor(&intern->array);\n\t\t\tgoto outexcept;\n\t\t}\n\t\tvar_push_dtor(&var_hash, &intern->array);\n\t}\n\tif (*p != ';') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\t/* members */\n\tif (*p!= 'm' || *++p != ':') {\n\t\tgoto outexcept;\n\t}\n\t++p;\n\n\tALLOC_INIT_ZVAL(pmembers);\n\tif (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {\n\t\tzval_ptr_dtor(&pmembers);\n\t\tgoto outexcept;\n\t}\n\n\tvar_push_dtor(&var_hash, &pmembers);\n\t/* copy members */\n\tif (!intern->std.properties) {\n\t\trebuild_object_properties(&intern->std);\n\t}\n\tzend_hash_copy(intern->std.properties, Z_ARRVAL_P(pmembers), (copy_ctor_func_t) zval_add_ref, (void *) NULL, sizeof(zval *));\n\tzval_ptr_dtor(&pmembers);\n\n\t/* done reading $serialized */\n\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\tif (pflags) {\n\t\tzval_ptr_dtor(&pflags);\n\t}\n\treturn;\n\noutexcept:\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\tif (pflags) {\n\t\tzval_ptr_dtor(&pflags);\n\t}\n\tzend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, \"Error at offset %ld of %d bytes\", (long)((char*)p - buf), buf_len);\n\treturn;\n\n} /* }}} */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-7417", "cwe_id": "CWE-20" }, { "id": 3013, "func": "ExprAppendMultiKeysymList(ExprDef *expr, ExprDef *append)\n{\n unsigned nSyms = darray_size(expr->keysym_list.syms);\n unsigned numEntries = darray_size(append->keysym_list.syms);\n\n darray_append(expr->keysym_list.symsMapIndex, nSyms);\n darray_append(expr->keysym_list.symsNumEntries, numEntries);\n darray_concat(expr->keysym_list.syms, append->keysym_list.syms);\n\n FreeStmt((ParseCommon *) &append);\n\n return expr;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-15857", "cwe_id": "CWE-416" }, { "id": 3013, "func": "ExprAppendMultiKeysymList(ExprDef *expr, ExprDef *append)\n{\n unsigned nSyms = darray_size(expr->keysym_list.syms);\n unsigned numEntries = darray_size(append->keysym_list.syms);\n\n darray_append(expr->keysym_list.symsMapIndex, nSyms);\n darray_append(expr->keysym_list.symsNumEntries, numEntries);\n darray_concat(expr->keysym_list.syms, append->keysym_list.syms);\n\n FreeStmt((ParseCommon *) append);\n\n return expr;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-15857", "cwe_id": "CWE-416" }, { "id": 758, "func": "mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)\n{\n\tconst u_char *p;\n\tuint32_t label_entry;\n\tuint16_t label_stack_depth = 0;\n\tenum mpls_packet_type pt = PT_UNKNOWN;\n\n\tp = bp;\n\tND_PRINT((ndo, \"MPLS\"));\n\tdo {\n\t\tND_TCHECK2(*p, sizeof(label_entry));\n\t\tif (length < sizeof(label_entry)) {\n\t\t\tND_PRINT((ndo, \"[|MPLS], length %u\", length));\n\t\t\treturn;\n\t\t}\n\t\tlabel_entry = EXTRACT_32BITS(p);\n\t\tND_PRINT((ndo, \"%s(label %u\",\n\t\t (label_stack_depth && ndo->ndo_vflag) ? \"\\n\\t\" : \" \",\n \t\t MPLS_LABEL(label_entry)));\n\t\tlabel_stack_depth++;\n\t\tif (ndo->ndo_vflag &&\n\t\t MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))\n\t\t\tND_PRINT((ndo, \" (%s)\", mpls_labelname[MPLS_LABEL(label_entry)]));\n\t\tND_PRINT((ndo, \", exp %u\", MPLS_EXP(label_entry)));\n\t\tif (MPLS_STACK(label_entry))\n\t\t\tND_PRINT((ndo, \", [S]\"));\n\t\tND_PRINT((ndo, \", ttl %u)\", MPLS_TTL(label_entry)));\n\n\t\tp += sizeof(label_entry);\n\t\tlength -= sizeof(label_entry);\n\t} while (!MPLS_STACK(label_entry));\n\n\t/*\n\t * Try to figure out the packet type.\n\t */\n\tswitch (MPLS_LABEL(label_entry)) {\n\n\tcase 0:\t/* IPv4 explicit NULL label */\n\tcase 3:\t/* IPv4 implicit NULL label */\n\t\tpt = PT_IPV4;\n\t\tbreak;\n\n\tcase 2:\t/* IPv6 explicit NULL label */\n\t\tpt = PT_IPV6;\n\t\tbreak;\n\n\tdefault:\n\t\t/*\n\t\t * Generally there's no indication of protocol in MPLS label\n\t\t * encoding.\n\t\t *\n\t\t * However, draft-hsmit-isis-aal5mux-00.txt describes a\n\t\t * technique for encapsulating IS-IS and IP traffic on the\n\t\t * same ATM virtual circuit; you look at the first payload\n\t\t * byte to determine the network layer protocol, based on\n\t\t * the fact that\n\t\t *\n\t\t *\t1) the first byte of an IP header is 0x45-0x4f\n\t\t *\t for IPv4 and 0x60-0x6f for IPv6;\n\t\t *\n\t\t *\t2) the first byte of an OSI CLNP packet is 0x81,\n\t\t *\t the first byte of an OSI ES-IS packet is 0x82,\n\t\t *\t and the first byte of an OSI IS-IS packet is\n\t\t *\t 0x83;\n\t\t *\n\t\t * so the network layer protocol can be inferred from the\n\t\t * first byte of the packet, if the protocol is one of the\n\t\t * ones listed above.\n\t\t *\n\t\t * Cisco sends control-plane traffic MPLS-encapsulated in\n\t\t * this fashion.\n\t\t */\n\t\tND_TCHECK(*p);\n\t\tif (length < 1) {\n\t\t\t/* nothing to print */\n\t\t\treturn;\n\t\t}\n\t\tswitch(*p) {\n\n\t\tcase 0x45:\n\t\tcase 0x46:\n\t\tcase 0x47:\n\t\tcase 0x48:\n\t\tcase 0x49:\n\t\tcase 0x4a:\n\t\tcase 0x4b:\n\t\tcase 0x4c:\n\t\tcase 0x4d:\n\t\tcase 0x4e:\n\t\tcase 0x4f:\n\t\t\tpt = PT_IPV4;\n\t\t\tbreak;\n\n\t\tcase 0x60:\n\t\tcase 0x61:\n\t\tcase 0x62:\n\t\tcase 0x63:\n\t\tcase 0x64:\n\t\tcase 0x65:\n\t\tcase 0x66:\n\t\tcase 0x67:\n\t\tcase 0x68:\n\t\tcase 0x69:\n\t\tcase 0x6a:\n\t\tcase 0x6b:\n\t\tcase 0x6c:\n\t\tcase 0x6d:\n\t\tcase 0x6e:\n\t\tcase 0x6f:\n\t\t\tpt = PT_IPV6;\n\t\t\tbreak;\n\n\t\tcase 0x81:\n\t\tcase 0x82:\n\t\tcase 0x83:\n\t\t\tpt = PT_OSI;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\t/* ok bail out - we did not figure out what it is*/\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/*\n\t * Print the payload.\n\t */\n\tif (pt == PT_UNKNOWN) {\n\t\tif (!ndo->ndo_suppress_default_print)\n\t\t\tND_DEFAULTPRINT(p, length);\n\t\treturn;\n\t}\n\tND_PRINT((ndo, ndo->ndo_vflag ? \"\\n\\t\" : \" \"));\n\tswitch (pt) {\n\n\tcase PT_IPV4:\n\t\tip_print(ndo, p, length);\n\t\tbreak;\n\n\tcase PT_IPV6:\n\t\tip6_print(ndo, p, length);\n\t\tbreak;\n\n\tcase PT_OSI:\n\t\tisoclns_print(ndo, p, length, length);\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n\t}\n\treturn;\n\ntrunc:\n\tND_PRINT((ndo, \"[|MPLS]\"));\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-12897", "cwe_id": "CWE-125" }, { "id": 758, "func": "mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)\n{\n\tconst u_char *p;\n\tuint32_t label_entry;\n\tuint16_t label_stack_depth = 0;\n\tenum mpls_packet_type pt = PT_UNKNOWN;\n\n\tp = bp;\n\tND_PRINT((ndo, \"MPLS\"));\n\tdo {\n\t\tND_TCHECK2(*p, sizeof(label_entry));\n\t\tif (length < sizeof(label_entry)) {\n\t\t\tND_PRINT((ndo, \"[|MPLS], length %u\", length));\n\t\t\treturn;\n\t\t}\n\t\tlabel_entry = EXTRACT_32BITS(p);\n\t\tND_PRINT((ndo, \"%s(label %u\",\n\t\t (label_stack_depth && ndo->ndo_vflag) ? \"\\n\\t\" : \" \",\n \t\t MPLS_LABEL(label_entry)));\n\t\tlabel_stack_depth++;\n\t\tif (ndo->ndo_vflag &&\n\t\t MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))\n\t\t\tND_PRINT((ndo, \" (%s)\", mpls_labelname[MPLS_LABEL(label_entry)]));\n\t\tND_PRINT((ndo, \", exp %u\", MPLS_EXP(label_entry)));\n\t\tif (MPLS_STACK(label_entry))\n\t\t\tND_PRINT((ndo, \", [S]\"));\n\t\tND_PRINT((ndo, \", ttl %u)\", MPLS_TTL(label_entry)));\n\n\t\tp += sizeof(label_entry);\n\t\tlength -= sizeof(label_entry);\n\t} while (!MPLS_STACK(label_entry));\n\n\t/*\n\t * Try to figure out the packet type.\n\t */\n\tswitch (MPLS_LABEL(label_entry)) {\n\n\tcase 0:\t/* IPv4 explicit NULL label */\n\tcase 3:\t/* IPv4 implicit NULL label */\n\t\tpt = PT_IPV4;\n\t\tbreak;\n\n\tcase 2:\t/* IPv6 explicit NULL label */\n\t\tpt = PT_IPV6;\n\t\tbreak;\n\n\tdefault:\n\t\t/*\n\t\t * Generally there's no indication of protocol in MPLS label\n\t\t * encoding.\n\t\t *\n\t\t * However, draft-hsmit-isis-aal5mux-00.txt describes a\n\t\t * technique for encapsulating IS-IS and IP traffic on the\n\t\t * same ATM virtual circuit; you look at the first payload\n\t\t * byte to determine the network layer protocol, based on\n\t\t * the fact that\n\t\t *\n\t\t *\t1) the first byte of an IP header is 0x45-0x4f\n\t\t *\t for IPv4 and 0x60-0x6f for IPv6;\n\t\t *\n\t\t *\t2) the first byte of an OSI CLNP packet is 0x81,\n\t\t *\t the first byte of an OSI ES-IS packet is 0x82,\n\t\t *\t and the first byte of an OSI IS-IS packet is\n\t\t *\t 0x83;\n\t\t *\n\t\t * so the network layer protocol can be inferred from the\n\t\t * first byte of the packet, if the protocol is one of the\n\t\t * ones listed above.\n\t\t *\n\t\t * Cisco sends control-plane traffic MPLS-encapsulated in\n\t\t * this fashion.\n\t\t */\n\t\tND_TCHECK(*p);\n\t\tif (length < 1) {\n\t\t\t/* nothing to print */\n\t\t\treturn;\n\t\t}\n\t\tswitch(*p) {\n\n\t\tcase 0x45:\n\t\tcase 0x46:\n\t\tcase 0x47:\n\t\tcase 0x48:\n\t\tcase 0x49:\n\t\tcase 0x4a:\n\t\tcase 0x4b:\n\t\tcase 0x4c:\n\t\tcase 0x4d:\n\t\tcase 0x4e:\n\t\tcase 0x4f:\n\t\t\tpt = PT_IPV4;\n\t\t\tbreak;\n\n\t\tcase 0x60:\n\t\tcase 0x61:\n\t\tcase 0x62:\n\t\tcase 0x63:\n\t\tcase 0x64:\n\t\tcase 0x65:\n\t\tcase 0x66:\n\t\tcase 0x67:\n\t\tcase 0x68:\n\t\tcase 0x69:\n\t\tcase 0x6a:\n\t\tcase 0x6b:\n\t\tcase 0x6c:\n\t\tcase 0x6d:\n\t\tcase 0x6e:\n\t\tcase 0x6f:\n\t\t\tpt = PT_IPV6;\n\t\t\tbreak;\n\n\t\tcase 0x81:\n\t\tcase 0x82:\n\t\tcase 0x83:\n\t\t\tpt = PT_OSI;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\t/* ok bail out - we did not figure out what it is*/\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/*\n\t * Print the payload.\n\t */\n\tif (pt == PT_UNKNOWN) {\n\t\tif (!ndo->ndo_suppress_default_print)\n\t\t\tND_DEFAULTPRINT(p, length);\n\t\treturn;\n\t}\n\tND_PRINT((ndo, ndo->ndo_vflag ? \"\\n\\t\" : \" \"));\n\tswitch (pt) {\n\n\tcase PT_IPV4:\n\t\tip_print(ndo, p, length);\n\t\tbreak;\n\n\tcase PT_IPV6:\n\t\tip6_print(ndo, p, length);\n\t\tbreak;\n\n\tcase PT_OSI:\n\t\tisoclns_print(ndo, p, length);\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n\t}\n\treturn;\n\ntrunc:\n\tND_PRINT((ndo, \"[|MPLS]\"));\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-12897", "cwe_id": "CWE-125" }, { "id": 3228, "func": "static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,\n\t\t\t\tu64 *cookie_ret, struct rds_mr **mr_ret)\n{\n\tstruct rds_mr *mr = NULL, *found;\n\tunsigned int nr_pages;\n\tstruct page **pages = NULL;\n\tstruct scatterlist *sg;\n\tvoid *trans_private;\n\tunsigned long flags;\n\trds_rdma_cookie_t cookie;\n\tunsigned int nents;\n\tlong i;\n\tint ret;\n\n\tif (rs->rs_bound_addr == 0) {\n\t\tret = -ENOTCONN; /* XXX not a great errno */\n\t\tgoto out;\n\t}\n\n\tif (!rs->rs_transport->get_mr) {\n\t\tret = -EOPNOTSUPP;\n\t\tgoto out;\n\t}\n\n\tnr_pages = rds_pages_in_vec(&args->vec);\n\tif (nr_pages == 0) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\t/* Restrict the size of mr irrespective of underlying transport\n\t * To account for unaligned mr regions, subtract one from nr_pages\n\t */\n\tif ((nr_pages - 1) > (RDS_MAX_MSG_SIZE >> PAGE_SHIFT)) {\n\t\tret = -EMSGSIZE;\n\t\tgoto out;\n\t}\n\n\trdsdebug(\"RDS: get_mr addr %llx len %llu nr_pages %u\\n\",\n\t\targs->vec.addr, args->vec.bytes, nr_pages);\n\n\t/* XXX clamp nr_pages to limit the size of this alloc? */\n\tpages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);\n\tif (!pages) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tmr = kzalloc(sizeof(struct rds_mr), GFP_KERNEL);\n\tif (!mr) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\trefcount_set(&mr->r_refcount, 1);\n\tRB_CLEAR_NODE(&mr->r_rb_node);\n\tmr->r_trans = rs->rs_transport;\n\tmr->r_sock = rs;\n\n\tif (args->flags & RDS_RDMA_USE_ONCE)\n\t\tmr->r_use_once = 1;\n\tif (args->flags & RDS_RDMA_INVALIDATE)\n\t\tmr->r_invalidate = 1;\n\tif (args->flags & RDS_RDMA_READWRITE)\n\t\tmr->r_write = 1;\n\n\t/*\n\t * Pin the pages that make up the user buffer and transfer the page\n\t * pointers to the mr's sg array. We check to see if we've mapped\n\t * the whole region after transferring the partial page references\n\t * to the sg array so that we can have one page ref cleanup path.\n\t *\n\t * For now we have no flag that tells us whether the mapping is\n\t * r/o or r/w. We need to assume r/w, or we'll do a lot of RDMA to\n\t * the zero page.\n\t */\n\tret = rds_pin_pages(args->vec.addr, nr_pages, pages, 1);\n\tif (ret < 0)\n\t\tgoto out;\n\n\tnents = ret;\n\tsg = kcalloc(nents, sizeof(*sg), GFP_KERNEL);\n\tif (!sg) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\tWARN_ON(!nents);\n\tsg_init_table(sg, nents);\n\n\t/* Stick all pages into the scatterlist */\n\tfor (i = 0 ; i < nents; i++)\n\t\tsg_set_page(&sg[i], pages[i], PAGE_SIZE, 0);\n\n\trdsdebug(\"RDS: trans_private nents is %u\\n\", nents);\n\n\t/* Obtain a transport specific MR. If this succeeds, the\n\t * s/g list is now owned by the MR.\n\t * Note that dma_map() implies that pending writes are\n\t * flushed to RAM, so no dma_sync is needed here. */\n\ttrans_private = rs->rs_transport->get_mr(sg, nents, rs,\n\t\t\t\t\t\t &mr->r_key);\n\n\tif (IS_ERR(trans_private)) {\n\t\tfor (i = 0 ; i < nents; i++)\n\t\t\tput_page(sg_page(&sg[i]));\n\t\tkfree(sg);\n\t\tret = PTR_ERR(trans_private);\n\t\tgoto out;\n\t}\n\n\tmr->r_trans_private = trans_private;\n\n\trdsdebug(\"RDS: get_mr put_user key is %x cookie_addr %p\\n\",\n\t mr->r_key, (void *)(unsigned long) args->cookie_addr);\n\n\t/* The user may pass us an unaligned address, but we can only\n\t * map page aligned regions. So we keep the offset, and build\n\t * a 64bit cookie containing and pass that\n\t * around. */\n\tcookie = rds_rdma_make_cookie(mr->r_key, args->vec.addr & ~PAGE_MASK);\n\tif (cookie_ret)\n\t\t*cookie_ret = cookie;\n\n\tif (args->cookie_addr && put_user(cookie, (u64 __user *)(unsigned long) args->cookie_addr)) {\n\t\tret = -EFAULT;\n\t\tgoto out;\n\t}\n\n\t/* Inserting the new MR into the rbtree bumps its\n\t * reference count. */\n\tspin_lock_irqsave(&rs->rs_rdma_lock, flags);\n\tfound = rds_mr_tree_walk(&rs->rs_rdma_keys, mr->r_key, mr);\n\tspin_unlock_irqrestore(&rs->rs_rdma_lock, flags);\n\n\tBUG_ON(found && found != mr);\n\n\trdsdebug(\"RDS: get_mr key is %x\\n\", mr->r_key);\n\tif (mr_ret) {\n\t\trefcount_inc(&mr->r_refcount);\n\t\t*mr_ret = mr;\n\t}\n\n\tret = 0;\nout:\n\tkfree(pages);\n\tif (mr)\n\t\trds_mr_put(mr);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-7492", "cwe_id": "CWE-476" }, { "id": 3228, "func": "static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,\n\t\t\t\tu64 *cookie_ret, struct rds_mr **mr_ret)\n{\n\tstruct rds_mr *mr = NULL, *found;\n\tunsigned int nr_pages;\n\tstruct page **pages = NULL;\n\tstruct scatterlist *sg;\n\tvoid *trans_private;\n\tunsigned long flags;\n\trds_rdma_cookie_t cookie;\n\tunsigned int nents;\n\tlong i;\n\tint ret;\n\n\tif (rs->rs_bound_addr == 0 || !rs->rs_transport) {\n\t\tret = -ENOTCONN; /* XXX not a great errno */\n\t\tgoto out;\n\t}\n\n\tif (!rs->rs_transport->get_mr) {\n\t\tret = -EOPNOTSUPP;\n\t\tgoto out;\n\t}\n\n\tnr_pages = rds_pages_in_vec(&args->vec);\n\tif (nr_pages == 0) {\n\t\tret = -EINVAL;\n\t\tgoto out;\n\t}\n\n\t/* Restrict the size of mr irrespective of underlying transport\n\t * To account for unaligned mr regions, subtract one from nr_pages\n\t */\n\tif ((nr_pages - 1) > (RDS_MAX_MSG_SIZE >> PAGE_SHIFT)) {\n\t\tret = -EMSGSIZE;\n\t\tgoto out;\n\t}\n\n\trdsdebug(\"RDS: get_mr addr %llx len %llu nr_pages %u\\n\",\n\t\targs->vec.addr, args->vec.bytes, nr_pages);\n\n\t/* XXX clamp nr_pages to limit the size of this alloc? */\n\tpages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);\n\tif (!pages) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\tmr = kzalloc(sizeof(struct rds_mr), GFP_KERNEL);\n\tif (!mr) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\n\trefcount_set(&mr->r_refcount, 1);\n\tRB_CLEAR_NODE(&mr->r_rb_node);\n\tmr->r_trans = rs->rs_transport;\n\tmr->r_sock = rs;\n\n\tif (args->flags & RDS_RDMA_USE_ONCE)\n\t\tmr->r_use_once = 1;\n\tif (args->flags & RDS_RDMA_INVALIDATE)\n\t\tmr->r_invalidate = 1;\n\tif (args->flags & RDS_RDMA_READWRITE)\n\t\tmr->r_write = 1;\n\n\t/*\n\t * Pin the pages that make up the user buffer and transfer the page\n\t * pointers to the mr's sg array. We check to see if we've mapped\n\t * the whole region after transferring the partial page references\n\t * to the sg array so that we can have one page ref cleanup path.\n\t *\n\t * For now we have no flag that tells us whether the mapping is\n\t * r/o or r/w. We need to assume r/w, or we'll do a lot of RDMA to\n\t * the zero page.\n\t */\n\tret = rds_pin_pages(args->vec.addr, nr_pages, pages, 1);\n\tif (ret < 0)\n\t\tgoto out;\n\n\tnents = ret;\n\tsg = kcalloc(nents, sizeof(*sg), GFP_KERNEL);\n\tif (!sg) {\n\t\tret = -ENOMEM;\n\t\tgoto out;\n\t}\n\tWARN_ON(!nents);\n\tsg_init_table(sg, nents);\n\n\t/* Stick all pages into the scatterlist */\n\tfor (i = 0 ; i < nents; i++)\n\t\tsg_set_page(&sg[i], pages[i], PAGE_SIZE, 0);\n\n\trdsdebug(\"RDS: trans_private nents is %u\\n\", nents);\n\n\t/* Obtain a transport specific MR. If this succeeds, the\n\t * s/g list is now owned by the MR.\n\t * Note that dma_map() implies that pending writes are\n\t * flushed to RAM, so no dma_sync is needed here. */\n\ttrans_private = rs->rs_transport->get_mr(sg, nents, rs,\n\t\t\t\t\t\t &mr->r_key);\n\n\tif (IS_ERR(trans_private)) {\n\t\tfor (i = 0 ; i < nents; i++)\n\t\t\tput_page(sg_page(&sg[i]));\n\t\tkfree(sg);\n\t\tret = PTR_ERR(trans_private);\n\t\tgoto out;\n\t}\n\n\tmr->r_trans_private = trans_private;\n\n\trdsdebug(\"RDS: get_mr put_user key is %x cookie_addr %p\\n\",\n\t mr->r_key, (void *)(unsigned long) args->cookie_addr);\n\n\t/* The user may pass us an unaligned address, but we can only\n\t * map page aligned regions. So we keep the offset, and build\n\t * a 64bit cookie containing and pass that\n\t * around. */\n\tcookie = rds_rdma_make_cookie(mr->r_key, args->vec.addr & ~PAGE_MASK);\n\tif (cookie_ret)\n\t\t*cookie_ret = cookie;\n\n\tif (args->cookie_addr && put_user(cookie, (u64 __user *)(unsigned long) args->cookie_addr)) {\n\t\tret = -EFAULT;\n\t\tgoto out;\n\t}\n\n\t/* Inserting the new MR into the rbtree bumps its\n\t * reference count. */\n\tspin_lock_irqsave(&rs->rs_rdma_lock, flags);\n\tfound = rds_mr_tree_walk(&rs->rs_rdma_keys, mr->r_key, mr);\n\tspin_unlock_irqrestore(&rs->rs_rdma_lock, flags);\n\n\tBUG_ON(found && found != mr);\n\n\trdsdebug(\"RDS: get_mr key is %x\\n\", mr->r_key);\n\tif (mr_ret) {\n\t\trefcount_inc(&mr->r_refcount);\n\t\t*mr_ret = mr;\n\t}\n\n\tret = 0;\nout:\n\tkfree(pages);\n\tif (mr)\n\t\trds_mr_put(mr);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-7492", "cwe_id": "CWE-476" }, { "id": 423, "func": "static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s)\n{\n\tstruct jbg_dec_state decoder;\n\tint decodeStatus = 0;\n\tunsigned char* pImage = NULL;\n\t(void) size, (void) s;\n\n\tif (isFillOrder(tif, tif->tif_dir.td_fillorder))\n\t{\n\t\tTIFFReverseBits(tif->tif_rawdata, tif->tif_rawdatasize);\n\t}\n\n\tjbg_dec_init(&decoder);\n\n#if defined(HAVE_JBG_NEWLEN)\n\tjbg_newlen(tif->tif_rawdata, (size_t)tif->tif_rawdatasize);\n\t/*\n\t * I do not check the return status of jbg_newlen because even if this\n\t * function fails it does not necessarily mean that decoding the image\n\t * will fail. It is generally only needed for received fax images\n\t * that do not contain the actual length of the image in the BIE\n\t * header. I do not log when an error occurs because that will cause\n\t * problems when converting JBIG encoded TIFF's to\n\t * PostScript. As long as the actual image length is contained in the\n\t * BIE header jbg_dec_in should succeed.\n\t */\n#endif /* HAVE_JBG_NEWLEN */\n\n\tdecodeStatus = jbg_dec_in(&decoder, (unsigned char*)tif->tif_rawdata,\n\t\t\t\t (size_t)tif->tif_rawdatasize, NULL);\n\tif (JBG_EOK != decodeStatus)\n\t{\n\t\t/*\n\t\t * XXX: JBG_EN constant was defined in pre-2.0 releases of the\n\t\t * JBIG-KIT. Since the 2.0 the error reporting functions were\n\t\t * changed. We will handle both cases here.\n\t\t */\n\t\tTIFFErrorExt(tif->tif_clientdata,\n\t\t\t \"JBIG\", \"Error (%d) decoding: %s\",\n\t\t\t decodeStatus,\n#if defined(JBG_EN)\n\t\t\t jbg_strerror(decodeStatus, JBG_EN)\n#else\n\t\t\t jbg_strerror(decodeStatus)\n#endif\n\t\t\t );\n\t\tjbg_dec_free(&decoder);\n\t\treturn 0;\n\t}\n\n\tpImage = jbg_dec_getimage(&decoder, 0);\n\t_TIFFmemcpy(buffer, pImage, jbg_dec_getsize(&decoder));\n\tjbg_dec_free(&decoder);\n\treturn 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-18557", "cwe_id": "CWE-787" }, { "id": 423, "func": "static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s)\n{\n\tstruct jbg_dec_state decoder;\n\tint decodeStatus = 0;\n\tunsigned char* pImage = NULL;\n\tunsigned long decodedSize;\n\t(void) s;\n\n\tif (isFillOrder(tif, tif->tif_dir.td_fillorder))\n\t{\n\t\tTIFFReverseBits(tif->tif_rawcp, tif->tif_rawcc);\n\t}\n\n\tjbg_dec_init(&decoder);\n\n#if defined(HAVE_JBG_NEWLEN)\n\tjbg_newlen(tif->tif_rawcp, (size_t)tif->tif_rawcc);\n\t/*\n\t * I do not check the return status of jbg_newlen because even if this\n\t * function fails it does not necessarily mean that decoding the image\n\t * will fail. It is generally only needed for received fax images\n\t * that do not contain the actual length of the image in the BIE\n\t * header. I do not log when an error occurs because that will cause\n\t * problems when converting JBIG encoded TIFF's to\n\t * PostScript. As long as the actual image length is contained in the\n\t * BIE header jbg_dec_in should succeed.\n\t */\n#endif /* HAVE_JBG_NEWLEN */\n\n\tdecodeStatus = jbg_dec_in(&decoder, (unsigned char*)tif->tif_rawcp,\n\t\t\t\t (size_t)tif->tif_rawcc, NULL);\n\tif (JBG_EOK != decodeStatus)\n\t{\n\t\t/*\n\t\t * XXX: JBG_EN constant was defined in pre-2.0 releases of the\n\t\t * JBIG-KIT. Since the 2.0 the error reporting functions were\n\t\t * changed. We will handle both cases here.\n\t\t */\n\t\tTIFFErrorExt(tif->tif_clientdata,\n\t\t\t \"JBIG\", \"Error (%d) decoding: %s\",\n\t\t\t decodeStatus,\n#if defined(JBG_EN)\n\t\t\t jbg_strerror(decodeStatus, JBG_EN)\n#else\n\t\t\t jbg_strerror(decodeStatus)\n#endif\n\t\t\t );\n\t\tjbg_dec_free(&decoder);\n\t\treturn 0;\n\t}\n\n\tdecodedSize = jbg_dec_getsize(&decoder);\n\tif( (tmsize_t)decodedSize < size )\n\t{\n\t TIFFWarningExt(tif->tif_clientdata, \"JBIG\",\n\t \"Only decoded %lu bytes, whereas %lu requested\",\n\t decodedSize, (unsigned long)size);\n\t}\n\telse if( (tmsize_t)decodedSize > size )\n\t{\n\t TIFFErrorExt(tif->tif_clientdata, \"JBIG\",\n\t \"Decoded %lu bytes, whereas %lu were requested\",\n\t decodedSize, (unsigned long)size);\n\t jbg_dec_free(&decoder);\n\t return 0;\n\t}\n\tpImage = jbg_dec_getimage(&decoder, 0);\n\t_TIFFmemcpy(buffer, pImage, decodedSize);\n\tjbg_dec_free(&decoder);\n\n tif->tif_rawcp += tif->tif_rawcc;\n tif->tif_rawcc = 0;\n\n\treturn 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-18557", "cwe_id": "CWE-787" }, { "id": 364, "func": "int AES_encrypt(char *message, uint8_t *encr_message, uint64_t encrLen) {\n\n if (!message) {\n LOG_ERROR(\"Null message in AES_encrypt\");\n return -1;\n }\n\n if (!encr_message) {\n LOG_ERROR(\"Null encr message in AES_encrypt\");\n return -2;\n }\n\n uint64_t len = strlen(message) + 1;\n\n if (len + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE > encrLen ) {\n LOG_ERROR(\"Output buffer too small\");\n return -3;\n }\n\n sgx_read_rand(encr_message + SGX_AESGCM_MAC_SIZE, SGX_AESGCM_IV_SIZE);\n\n sgx_status_t status = sgx_rijndael128GCM_encrypt(&AES_key, (uint8_t*)message, strlen(message),\n encr_message + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE,\n encr_message + SGX_AESGCM_MAC_SIZE, SGX_AESGCM_IV_SIZE,\n NULL, 0,\n (sgx_aes_gcm_128bit_tag_t *) encr_message);\n\n return status;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-36218", "cwe_id": "CWE-787" }, { "id": 364, "func": "int AES_encrypt(char *message, uint8_t *encr_message, uint64_t encrBufLen, unsigned char type,\n unsigned char decryptable, uint64_t* resultLen) {\n\n\n\n if (!type) {\n LOG_ERROR(\"Null type in AES_encrypt\");\n return -1;\n }\n\n if (!message) {\n LOG_ERROR(\"Null message in AES_encrypt\");\n return -1;\n }\n\n if (!encr_message) {\n LOG_ERROR(\"Null encr message in AES_encrypt\");\n return -2;\n }\n\n uint64_t len = strlen(message) + 1;\n\n if (2 + len + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE > encrBufLen ) {\n LOG_ERROR(\"Output buffer too small\");\n return -3;\n }\n\n SAFE_CHAR_BUF(fullMessage, len + 2);\n\n fullMessage[0] = type;\n fullMessage[1] = decryptable;\n\n strncpy(fullMessage + 2, message, len );\n\n len = len + 2;\n message = fullMessage;\n\n sgx_read_rand(encr_message + SGX_AESGCM_MAC_SIZE, SGX_AESGCM_IV_SIZE);\n\n sgx_status_t status = sgx_rijndael128GCM_encrypt(&AES_key, (uint8_t*)message, len,\n encr_message + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE,\n encr_message + SGX_AESGCM_MAC_SIZE, SGX_AESGCM_IV_SIZE,\n NULL, 0,\n (sgx_aes_gcm_128bit_tag_t *) encr_message);\n\n *resultLen = len + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE;\n\n return status;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-36218", "cwe_id": "CWE-787" }, { "id": 2840, "func": "static int read_fragment_table(long long *directory_table_end)\n{\n\tint res, i;\n\tint bytes = SQUASHFS_FRAGMENT_BYTES(sBlk.s.fragments);\n\tint indexes = SQUASHFS_FRAGMENT_INDEXES(sBlk.s.fragments);\n\tlong long fragment_table_index[indexes];\n\n\tTRACE(\"read_fragment_table: %d fragments, reading %d fragment indexes \"\n\t\t\"from 0x%llx\\n\", sBlk.s.fragments, indexes,\n\t\tsBlk.s.fragment_table_start);\n\n\tif(sBlk.s.fragments == 0) {\n\t\t*directory_table_end = sBlk.s.fragment_table_start;\n\t\treturn TRUE;\n\t}\n\n\tfragment_table = malloc(bytes);\n\tif(fragment_table == NULL)\n\t\tEXIT_UNSQUASH(\"read_fragment_table: failed to allocate \"\n\t\t\t\"fragment table\\n\");\n\n\tres = read_fs_bytes(fd, sBlk.s.fragment_table_start,\n\t\tSQUASHFS_FRAGMENT_INDEX_BYTES(sBlk.s.fragments),\n\t\tfragment_table_index);\n\tif(res == FALSE) {\n\t\tERROR(\"read_fragment_table: failed to read fragment table \"\n\t\t\t\"index\\n\");\n\t\treturn FALSE;\n\t}\n\tSQUASHFS_INSWAP_FRAGMENT_INDEXES(fragment_table_index, indexes);\n\n\tfor(i = 0; i < indexes; i++) {\n\t\tint expected = (i + 1) != indexes ? SQUASHFS_METADATA_SIZE :\n\t\t\t\t\tbytes & (SQUASHFS_METADATA_SIZE - 1);\n\t\tint length = read_block(fd, fragment_table_index[i], NULL,\n\t\t\texpected, ((char *) fragment_table) + (i *\n\t\t\tSQUASHFS_METADATA_SIZE));\n\t\tTRACE(\"Read fragment table block %d, from 0x%llx, length %d\\n\",\n\t\t\ti, fragment_table_index[i], length);\n\t\tif(length == FALSE) {\n\t\t\tERROR(\"read_fragment_table: failed to read fragment \"\n\t\t\t\t\"table index\\n\");\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\n\tfor(i = 0; i < sBlk.s.fragments; i++) \n\t\tSQUASHFS_INSWAP_FRAGMENT_ENTRY(&fragment_table[i]);\n\n\t*directory_table_end = fragment_table_index[0];\n\treturn TRUE;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-4645", "cwe_id": "CWE-190" }, { "id": 2840, "func": "static int read_fragment_table(long long *table_start)\n{\n\t/*\n\t * Note on overflow limits:\n\t * Size of SBlk.s.fragments is 2^32 (unsigned int)\n\t * Max size of bytes is 2^32*16 or 2^36\n\t * Max indexes is (2^32*16)/8K or 2^23\n\t * Max length is ((2^32*16)/8K)*8 or 2^26 or 64M\n\t */\n\tint res, i;\n\tlong long bytes = SQUASHFS_FRAGMENT_BYTES((long long) sBlk.s.fragments);\n\tint indexes = SQUASHFS_FRAGMENT_INDEXES((long long) sBlk.s.fragments);\n\tint length = SQUASHFS_FRAGMENT_INDEX_BYTES((long long) sBlk.s.fragments);\n\tlong long *fragment_table_index;\n\n\t/*\n\t * The size of the index table (length bytes) should match the\n\t * table start and end points\n\t */\n\tif(length != (*table_start - sBlk.s.fragment_table_start)) {\n\t\tERROR(\"read_fragment_table: Bad fragment count in super block\\n\");\n\t\treturn FALSE;\n\t}\n\n\tTRACE(\"read_fragment_table: %d fragments, reading %d fragment indexes \"\n\t\t\"from 0x%llx\\n\", sBlk.s.fragments, indexes,\n\t\tsBlk.s.fragment_table_start);\n\n\tfragment_table_index = alloc_index_table(indexes);\n\tfragment_table = malloc(bytes);\n\tif(fragment_table == NULL)\n\t\tEXIT_UNSQUASH(\"read_fragment_table: failed to allocate \"\n\t\t\t\"fragment table\\n\");\n\n\tres = read_fs_bytes(fd, sBlk.s.fragment_table_start, length,\n\t\t\t\t\t\t\tfragment_table_index);\n\tif(res == FALSE) {\n\t\tERROR(\"read_fragment_table: failed to read fragment table \"\n\t\t\t\"index\\n\");\n\t\treturn FALSE;\n\t}\n\tSQUASHFS_INSWAP_FRAGMENT_INDEXES(fragment_table_index, indexes);\n\n\tfor(i = 0; i < indexes; i++) {\n\t\tint expected = (i + 1) != indexes ? SQUASHFS_METADATA_SIZE :\n\t\t\t\t\tbytes & (SQUASHFS_METADATA_SIZE - 1);\n\t\tint length = read_block(fd, fragment_table_index[i], NULL,\n\t\t\texpected, ((char *) fragment_table) + (i *\n\t\t\tSQUASHFS_METADATA_SIZE));\n\t\tTRACE(\"Read fragment table block %d, from 0x%llx, length %d\\n\",\n\t\t\ti, fragment_table_index[i], length);\n\t\tif(length == FALSE) {\n\t\t\tERROR(\"read_fragment_table: failed to read fragment \"\n\t\t\t\t\"table index\\n\");\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\n\tfor(i = 0; i < sBlk.s.fragments; i++) \n\t\tSQUASHFS_INSWAP_FRAGMENT_ENTRY(&fragment_table[i]);\n\n\t*table_start = fragment_table_index[0];\n\treturn TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-4645", "cwe_id": "CWE-190" }, { "id": 2523, "func": "Status CompressElement(const std::vector& element,\n CompressedElement* out) {\n // Step 1: Determine the total uncompressed size. This requires serializing\n // non-memcopyable tensors, which we save to use again later.\n std::vector non_memcpy_components;\n int64 total_size = 0;\n for (auto& component : element) {\n if (DataTypeCanUseMemcpy(component.dtype())) {\n // Some datatypes can be memcopied, allowing us to save two copies\n // (AsProtoTensorContent and SerializeToArray).\n total_size += DMAHelper::buffer(&component)->size();\n } else {\n non_memcpy_components.emplace_back();\n component.AsProtoTensorContent(&non_memcpy_components.back());\n total_size += non_memcpy_components.back().ByteSizeLong();\n }\n }\n\n // Step 2: Write the tensor data to a buffer, and compress that buffer.\n // We use tstring for access to resize_uninitialized.\n tstring uncompressed;\n uncompressed.resize_uninitialized(total_size);\n // Position in `uncompressed` to write the next component.\n char* position = uncompressed.mdata();\n int non_memcpy_component_index = 0;\n for (auto& component : element) {\n CompressedComponentMetadata* metadata =\n out->mutable_component_metadata()->Add();\n metadata->set_dtype(component.dtype());\n component.shape().AsProto(metadata->mutable_tensor_shape());\n if (DataTypeCanUseMemcpy(component.dtype())) {\n const TensorBuffer* buffer = DMAHelper::buffer(&component);\n memcpy(position, buffer->data(), buffer->size());\n metadata->set_tensor_size_bytes(buffer->size());\n } else {\n TensorProto& proto = non_memcpy_components[non_memcpy_component_index++];\n proto.SerializeToArray(position, proto.ByteSizeLong());\n metadata->set_tensor_size_bytes(proto.ByteSizeLong());\n }\n position += metadata->tensor_size_bytes();\n }\n DCHECK_EQ(position, uncompressed.mdata() + total_size);\n\n if (!port::Snappy_Compress(uncompressed.mdata(), total_size,\n out->mutable_data())) {\n return errors::Internal(\"Failed to compress using snappy.\");\n }\n VLOG(3) << \"Compressed element from \" << total_size << \" bytes to \"\n << out->data().size() << \" bytes\";\n return Status::OK();\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-37637", "cwe_id": "CWE-476" }, { "id": 2523, "func": "Status CompressElement(const std::vector& element,\n CompressedElement* out) {\n // Step 1: Determine the total uncompressed size. This requires serializing\n // non-memcopyable tensors, which we save to use again later.\n std::vector non_memcpy_components;\n int64 total_size = 0;\n for (auto& component : element) {\n if (DataTypeCanUseMemcpy(component.dtype())) {\n const TensorBuffer* buffer = DMAHelper::buffer(&component);\n if (buffer) {\n total_size += buffer->size();\n }\n } else {\n non_memcpy_components.emplace_back();\n component.AsProtoTensorContent(&non_memcpy_components.back());\n total_size += non_memcpy_components.back().ByteSizeLong();\n }\n }\n\n // Step 2: Write the tensor data to a buffer, and compress that buffer.\n // We use tstring for access to resize_uninitialized.\n tstring uncompressed;\n uncompressed.resize_uninitialized(total_size);\n // Position in `uncompressed` to write the next component.\n char* position = uncompressed.mdata();\n int non_memcpy_component_index = 0;\n for (auto& component : element) {\n CompressedComponentMetadata* metadata =\n out->mutable_component_metadata()->Add();\n metadata->set_dtype(component.dtype());\n component.shape().AsProto(metadata->mutable_tensor_shape());\n if (DataTypeCanUseMemcpy(component.dtype())) {\n const TensorBuffer* buffer = DMAHelper::buffer(&component);\n if (buffer) {\n memcpy(position, buffer->data(), buffer->size());\n metadata->set_tensor_size_bytes(buffer->size());\n }\n } else {\n TensorProto& proto = non_memcpy_components[non_memcpy_component_index++];\n proto.SerializeToArray(position, proto.ByteSizeLong());\n metadata->set_tensor_size_bytes(proto.ByteSizeLong());\n }\n position += metadata->tensor_size_bytes();\n }\n DCHECK_EQ(position, uncompressed.mdata() + total_size);\n\n if (!port::Snappy_Compress(uncompressed.mdata(), total_size,\n out->mutable_data())) {\n return errors::Internal(\"Failed to compress using snappy.\");\n }\n VLOG(3) << \"Compressed element from \" << total_size << \" bytes to \"\n << out->data().size() << \" bytes\";\n return Status::OK();\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-37637", "cwe_id": "CWE-476" }, { "id": 2789, "func": "static Jsi_RC jsi_ArrayUnshiftCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,Jsi_Value **ret, Jsi_Func *funcPtr) {\n if (_this->vt != JSI_VT_OBJECT || !Jsi_ObjIsArray(interp, _this->d.obj))\n return Jsi_LogError(\"expected array object\");\n\n Jsi_Obj *obj = _this->d.obj;\n int argc = Jsi_ValueGetLength(interp, args);\n int curlen = Jsi_ObjGetLength(interp, obj);\n if (curlen < 0) {\n Jsi_ObjSetLength(interp, obj, 0);\n }\n if (argc <= 0) {\n Jsi_ValueMakeNumber(interp, ret, 0);\n return JSI_OK;\n }\n Jsi_ObjListifyArray(interp, obj);\n if (Jsi_ObjArraySizer(interp, obj, curlen+argc)<=0) \n return Jsi_LogError(\"too long\");\n memmove(obj->arr+argc, obj->arr, (curlen)*sizeof(Jsi_Value*));\n obj->arrCnt += argc;\n int i;\n for (i = 0; i < argc; ++i) {\n Jsi_Value *ov = Jsi_ValueArrayIndex(interp, args, i);\n obj->arr[i] = NULL;\n if (!ov) { Jsi_LogBug(\"Arguments Error\"); continue; }\n obj->arr[i] = ov;\n Jsi_IncrRefCount(interp, ov);\n }\n Jsi_ObjSetLength(interp, obj, curlen+argc);\n \n Jsi_ValueMakeNumber(interp, ret, Jsi_ObjGetLength(interp, obj));\n return JSI_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-22875", "cwe_id": "CWE-190" }, { "id": 2789, "func": "static Jsi_RC jsi_ArrayUnshiftCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,Jsi_Value **ret, Jsi_Func *funcPtr) {\n if (_this->vt != JSI_VT_OBJECT || !Jsi_ObjIsArray(interp, _this->d.obj))\n return Jsi_LogError(\"expected array object\");\n\n Jsi_Obj *obj = _this->d.obj;\n int argc = Jsi_ValueGetLength(interp, args);\n int curlen = jsi_SizeOfArray(interp, obj);\n if (argc <= 0) {\n Jsi_ValueMakeNumber(interp, ret, 0);\n return JSI_OK;\n }\n Jsi_ObjListifyArray(interp, obj);\n if (Jsi_ObjArraySizer(interp, obj, curlen+argc)<=0) \n return Jsi_LogError(\"too long\");\n memmove(obj->arr+argc, obj->arr, (curlen)*sizeof(Jsi_Value*));\n obj->arrCnt += argc;\n int i;\n for (i = 0; i < argc; ++i) {\n Jsi_Value *ov = Jsi_ValueArrayIndex(interp, args, i);\n obj->arr[i] = NULL;\n if (!ov) { Jsi_LogBug(\"Arguments Error\"); continue; }\n obj->arr[i] = ov;\n Jsi_IncrRefCount(interp, ov);\n }\n Jsi_ObjSetLength(interp, obj, curlen+argc);\n \n Jsi_ValueMakeNumber(interp, ret, jsi_SizeOfArray(interp, obj));\n return JSI_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-22875", "cwe_id": "CWE-190" }, { "id": 528, "func": "static int dnxhd_find_frame_end(DNXHDParserContext *dctx,\n const uint8_t *buf, int buf_size)\n{\n ParseContext *pc = &dctx->pc;\n uint64_t state = pc->state64;\n int pic_found = pc->frame_start_found;\n int i = 0;\n\n if (!pic_found) {\n for (i = 0; i < buf_size; i++) {\n state = (state << 8) | buf[i];\n if (ff_dnxhd_check_header_prefix(state & 0xffffffffff00LL) != 0) {\n i++;\n pic_found = 1;\n dctx->cur_byte = 0;\n dctx->remaining = 0;\n break;\n }\n }\n }\n\n if (pic_found && !dctx->remaining) {\n if (!buf_size) /* EOF considered as end of frame */\n return 0;\n for (; i < buf_size; i++) {\n dctx->cur_byte++;\n state = (state << 8) | buf[i];\n\n if (dctx->cur_byte == 24) {\n dctx->h = (state >> 32) & 0xFFFF;\n } else if (dctx->cur_byte == 26) {\n dctx->w = (state >> 32) & 0xFFFF;\n } else if (dctx->cur_byte == 42) {\n int cid = (state >> 32) & 0xFFFFFFFF;\n\n if (cid <= 0)\n continue;\n\n dctx->remaining = avpriv_dnxhd_get_frame_size(cid);\n if (dctx->remaining <= 0) {\n dctx->remaining = ff_dnxhd_get_hr_frame_size(cid, dctx->w, dctx->h);\n if (dctx->remaining <= 0)\n return dctx->remaining;\n }\n if (buf_size - i + 47 >= dctx->remaining) {\n int remaining = dctx->remaining;\n\n pc->frame_start_found = 0;\n pc->state64 = -1;\n dctx->cur_byte = 0;\n dctx->remaining = 0;\n return remaining;\n } else {\n dctx->remaining -= buf_size;\n }\n }\n }\n } else if (pic_found) {\n if (dctx->remaining > buf_size) {\n dctx->remaining -= buf_size;\n } else {\n int remaining = dctx->remaining;\n\n pc->frame_start_found = 0;\n pc->state64 = -1;\n dctx->cur_byte = 0;\n dctx->remaining = 0;\n return remaining;\n }\n }\n pc->frame_start_found = pic_found;\n pc->state64 = state;\n return END_NOT_FOUND;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-9608", "cwe_id": "CWE-476" }, { "id": 528, "func": "static int dnxhd_find_frame_end(DNXHDParserContext *dctx,\n const uint8_t *buf, int buf_size)\n{\n ParseContext *pc = &dctx->pc;\n uint64_t state = pc->state64;\n int pic_found = pc->frame_start_found;\n int i = 0;\n\n if (!pic_found) {\n for (i = 0; i < buf_size; i++) {\n state = (state << 8) | buf[i];\n if (ff_dnxhd_check_header_prefix(state & 0xffffffffff00LL) != 0) {\n i++;\n pic_found = 1;\n dctx->cur_byte = 0;\n dctx->remaining = 0;\n break;\n }\n }\n }\n\n if (pic_found && !dctx->remaining) {\n if (!buf_size) /* EOF considered as end of frame */\n return 0;\n for (; i < buf_size; i++) {\n dctx->cur_byte++;\n state = (state << 8) | buf[i];\n\n if (dctx->cur_byte == 24) {\n dctx->h = (state >> 32) & 0xFFFF;\n } else if (dctx->cur_byte == 26) {\n dctx->w = (state >> 32) & 0xFFFF;\n } else if (dctx->cur_byte == 42) {\n int cid = (state >> 32) & 0xFFFFFFFF;\n int remaining;\n\n if (cid <= 0)\n continue;\n\n remaining = avpriv_dnxhd_get_frame_size(cid);\n if (remaining <= 0) {\n remaining = ff_dnxhd_get_hr_frame_size(cid, dctx->w, dctx->h);\n if (remaining <= 0)\n continue;\n }\n dctx->remaining = remaining;\n if (buf_size - i + 47 >= dctx->remaining) {\n int remaining = dctx->remaining;\n\n pc->frame_start_found = 0;\n pc->state64 = -1;\n dctx->cur_byte = 0;\n dctx->remaining = 0;\n return remaining;\n } else {\n dctx->remaining -= buf_size;\n }\n }\n }\n } else if (pic_found) {\n if (dctx->remaining > buf_size) {\n dctx->remaining -= buf_size;\n } else {\n int remaining = dctx->remaining;\n\n pc->frame_start_found = 0;\n pc->state64 = -1;\n dctx->cur_byte = 0;\n dctx->remaining = 0;\n return remaining;\n }\n }\n pc->frame_start_found = pic_found;\n pc->state64 = state;\n return END_NOT_FOUND;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-9608", "cwe_id": "CWE-476" }, { "id": 2503, "func": "int insn_get_code_seg_params(struct pt_regs *regs)\n{\n\tstruct desc_struct *desc;\n\tshort sel;\n\n\tif (v8086_mode(regs))\n\t\t/* Address and operand size are both 16-bit. */\n\t\treturn INSN_CODE_SEG_PARAMS(2, 2);\n\n\tsel = get_segment_selector(regs, INAT_SEG_REG_CS);\n\tif (sel < 0)\n\t\treturn sel;\n\n\tdesc = get_desc(sel);\n\tif (!desc)\n\t\treturn -EINVAL;\n\n\t/*\n\t * The most significant byte of the Type field of the segment descriptor\n\t * determines whether a segment contains data or code. If this is a data\n\t * segment, return error.\n\t */\n\tif (!(desc->type & BIT(3)))\n\t\treturn -EINVAL;\n\n\tswitch ((desc->l << 1) | desc->d) {\n\tcase 0: /*\n\t\t * Legacy mode. CS.L=0, CS.D=0. Address and operand size are\n\t\t * both 16-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(2, 2);\n\tcase 1: /*\n\t\t * Legacy mode. CS.L=0, CS.D=1. Address and operand size are\n\t\t * both 32-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(4, 4);\n\tcase 2: /*\n\t\t * IA-32e 64-bit mode. CS.L=1, CS.D=0. Address size is 64-bit;\n\t\t * operand size is 32-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(4, 8);\n\tcase 3: /* Invalid setting. CS.L=1, CS.D=1 */\n\t\t/* fall through */\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-13233", "cwe_id": "CWE-362" }, { "id": 2503, "func": "int insn_get_code_seg_params(struct pt_regs *regs)\n{\n\tstruct desc_struct desc;\n\tshort sel;\n\n\tif (v8086_mode(regs))\n\t\t/* Address and operand size are both 16-bit. */\n\t\treturn INSN_CODE_SEG_PARAMS(2, 2);\n\n\tsel = get_segment_selector(regs, INAT_SEG_REG_CS);\n\tif (sel < 0)\n\t\treturn sel;\n\n\tif (!get_desc(&desc, sel))\n\t\treturn -EINVAL;\n\n\t/*\n\t * The most significant byte of the Type field of the segment descriptor\n\t * determines whether a segment contains data or code. If this is a data\n\t * segment, return error.\n\t */\n\tif (!(desc.type & BIT(3)))\n\t\treturn -EINVAL;\n\n\tswitch ((desc.l << 1) | desc.d) {\n\tcase 0: /*\n\t\t * Legacy mode. CS.L=0, CS.D=0. Address and operand size are\n\t\t * both 16-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(2, 2);\n\tcase 1: /*\n\t\t * Legacy mode. CS.L=0, CS.D=1. Address and operand size are\n\t\t * both 32-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(4, 4);\n\tcase 2: /*\n\t\t * IA-32e 64-bit mode. CS.L=1, CS.D=0. Address size is 64-bit;\n\t\t * operand size is 32-bit.\n\t\t */\n\t\treturn INSN_CODE_SEG_PARAMS(4, 8);\n\tcase 3: /* Invalid setting. CS.L=1, CS.D=1 */\n\t\t/* fall through */\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-13233", "cwe_id": "CWE-362" }, { "id": 2437, "func": "TfLiteStatus TanhEval(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = reinterpret_cast(node->user_data);\n const TfLiteTensor* input = GetInput(context, node, 0);\n TfLiteTensor* output = GetOutput(context, node, 0);\n switch (input->type) {\n case kTfLiteFloat32: {\n if (kernel_type == kReference) {\n reference_ops::Tanh(GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output),\n GetTensorData(output));\n } else {\n optimized_ops::Tanh(GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output),\n GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n case kTfLiteInt16: {\n TanhParams params;\n params.input_left_shift = data->input_left_shift;\n if (kernel_type == kReference || (data->input_multiplier > 0)) {\n reference_integer_ops::Tanh(\n data->input_multiplier, data->input_left_shift,\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n optimized_ops::Tanh(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n case kTfLiteUInt8: {\n if (kernel_type == kFixedPointOptimized) {\n TanhParams params;\n params.input_zero_point = input->params.zero_point;\n params.input_range_radius = data->input_range_radius;\n params.input_multiplier = data->input_multiplier;\n params.input_left_shift = data->input_left_shift;\n optimized_ops::Tanh16bitPrecision(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n EvalUsingLookupTable(data, input, output);\n }\n return kTfLiteOk;\n } break;\n case kTfLiteInt8: {\n if (kernel_type == kFixedPointOptimized) {\n TanhParams params;\n params.input_zero_point = input->params.zero_point;\n params.input_range_radius = data->input_range_radius;\n params.input_multiplier = data->input_multiplier;\n params.input_left_shift = data->input_left_shift;\n optimized_ops::Tanh16bitPrecision(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n EvalUsingLookupTable(data, input, output);\n }\n return kTfLiteOk;\n } break;\n default:\n TF_LITE_KERNEL_LOG(context,\n \"Only float32, uint8, int16 and int8 are supported \"\n \"currently, got %s.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2437, "func": "TfLiteStatus TanhEval(TfLiteContext* context, TfLiteNode* node) {\n OpData* data = reinterpret_cast(node->user_data);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n switch (input->type) {\n case kTfLiteFloat32: {\n if (kernel_type == kReference) {\n reference_ops::Tanh(GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output),\n GetTensorData(output));\n } else {\n optimized_ops::Tanh(GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output),\n GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n case kTfLiteInt16: {\n TanhParams params;\n params.input_left_shift = data->input_left_shift;\n if (kernel_type == kReference || (data->input_multiplier > 0)) {\n reference_integer_ops::Tanh(\n data->input_multiplier, data->input_left_shift,\n GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n optimized_ops::Tanh(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n }\n return kTfLiteOk;\n } break;\n case kTfLiteUInt8: {\n if (kernel_type == kFixedPointOptimized) {\n TanhParams params;\n params.input_zero_point = input->params.zero_point;\n params.input_range_radius = data->input_range_radius;\n params.input_multiplier = data->input_multiplier;\n params.input_left_shift = data->input_left_shift;\n optimized_ops::Tanh16bitPrecision(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n EvalUsingLookupTable(data, input, output);\n }\n return kTfLiteOk;\n } break;\n case kTfLiteInt8: {\n if (kernel_type == kFixedPointOptimized) {\n TanhParams params;\n params.input_zero_point = input->params.zero_point;\n params.input_range_radius = data->input_range_radius;\n params.input_multiplier = data->input_multiplier;\n params.input_left_shift = data->input_left_shift;\n optimized_ops::Tanh16bitPrecision(\n params, GetTensorShape(input), GetTensorData(input),\n GetTensorShape(output), GetTensorData(output));\n } else {\n EvalUsingLookupTable(data, input, output);\n }\n return kTfLiteOk;\n } break;\n default:\n TF_LITE_KERNEL_LOG(context,\n \"Only float32, uint8, int16 and int8 are supported \"\n \"currently, got %s.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1225, "func": "RawTile KakaduImage::getRegion( int seq, int ang, unsigned int res, int layers, int x, int y, unsigned int w, unsigned int h )\n{\n // Scale up our output bit depth to the nearest factor of 8\n unsigned int obpc = bpc;\n if( bpc <= 16 && bpc > 8 ) obpc = 16;\n else if( bpc <= 8 ) obpc = 8;\n\n#ifdef DEBUG\n Timer timer;\n timer.start();\n#endif\n\n RawTile rawtile( 0, res, seq, ang, w, h, channels, obpc );\n\n if( obpc == 16 ) rawtile.data = new unsigned short[w*h*channels];\n else if( obpc == 8 ) rawtile.data = new unsigned char[w*h*channels];\n else throw file_error( \"Kakadu :: Unsupported number of bits\" );\n\n rawtile.dataLength = w*h*channels*(obpc/8);\n rawtile.filename = getImagePath();\n rawtile.timestamp = timestamp;\n\n process( res, layers, x, y, w, h, rawtile.data );\n\n#ifdef DEBUG\n logfile << \"Kakadu :: getRegion() :: \" << timer.getTime() << \" microseconds\" << endl;\n#endif\n\n return rawtile;\n\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-46389", "cwe_id": "CWE-190" }, { "id": 1225, "func": "RawTile KakaduImage::getRegion( int seq, int ang, unsigned int res, int layers, int x, int y, unsigned int w, unsigned int h )\n{\n // Scale up our output bit depth to the nearest factor of 8\n unsigned int obpc = bpc;\n if( bpc <= 16 && bpc > 8 ) obpc = 16;\n else if( bpc <= 8 ) obpc = 8;\n\n#ifdef DEBUG\n Timer timer;\n timer.start();\n#endif\n\n RawTile rawtile( 0, res, seq, ang, w, h, channels, obpc );\n\n size_t np = (size_t) w * (size_t) h * (size_t) channels;\n if( obpc == 16 ) rawtile.data = new unsigned short[np];\n else if( obpc == 8 ) rawtile.data = new unsigned char[np];\n else throw file_error( \"Kakadu :: Unsupported number of bits\" );\n\n rawtile.dataLength = np*(obpc/8);\n rawtile.filename = getImagePath();\n rawtile.timestamp = timestamp;\n\n process( res, layers, x, y, w, h, rawtile.data );\n\n#ifdef DEBUG\n logfile << \"Kakadu :: getRegion() :: \" << timer.getTime() << \" microseconds\" << endl;\n#endif\n\n return rawtile;\n\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-46389", "cwe_id": "CWE-190" }, { "id": 1528, "func": "void rose_start_idletimer(struct sock *sk)\n{\n\tstruct rose_sock *rose = rose_sk(sk);\n\n\tdel_timer(&rose->idletimer);\n\n\tif (rose->idle > 0) {\n\t\trose->idletimer.function = rose_idletimer_expiry;\n\t\trose->idletimer.expires = jiffies + rose->idle;\n\n\t\tadd_timer(&rose->idletimer);\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-2318", "cwe_id": "CWE-416" }, { "id": 1528, "func": "void rose_start_idletimer(struct sock *sk)\n{\n\tstruct rose_sock *rose = rose_sk(sk);\n\n\tsk_stop_timer(sk, &rose->idletimer);\n\n\tif (rose->idle > 0) {\n\t\trose->idletimer.function = rose_idletimer_expiry;\n\t\trose->idletimer.expires = jiffies + rose->idle;\n\n\t\tsk_reset_timer(sk, &rose->idletimer, rose->idletimer.expires);\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-2318", "cwe_id": "CWE-416" }, { "id": 2299, "func": " static bool TryParse(const char* inp, int length,\n TypedValue* buf, Variant& out,\n JSONContainerType container_type, bool is_tsimplejson) {\n SimpleParser parser(inp, length, buf, container_type, is_tsimplejson);\n bool ok = parser.parseValue();\n parser.skipSpace();\n if (!ok || parser.p != inp + length) {\n // Unsupported, malformed, or trailing garbage. Release entire stack.\n tvDecRefRange(buf, parser.top);\n return false;\n }\n out = Variant::attach(*--parser.top);\n return true;\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-1893", "cwe_id": "CWE-125" }, { "id": 2299, "func": " static bool TryParse(const char* inp, int length,\n TypedValue* buf, Variant& out,\n JSONContainerType container_type, bool is_tsimplejson) {\n SimpleParser parser(inp, length, buf, container_type, is_tsimplejson);\n bool ok = parser.parseValue();\n if (!ok ||\n (parser.skipSpace(), parser.p != inp + length)) {\n // Unsupported, malformed, or trailing garbage. Release entire stack.\n tvDecRefRange(buf, parser.top);\n return false;\n }\n out = Variant::attach(*--parser.top);\n return true;\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-1893", "cwe_id": "CWE-125" }, { "id": 3254, "func": "file_check_mem(struct magic_set *ms, unsigned int level)\n{\n\tsize_t len;\n\n\tif (level >= ms->c.len) {\n\t\tlen = (ms->c.len += 20) * sizeof(*ms->c.li);\n\t\tms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ?\n\t\t malloc(len) :\n\t\t realloc(ms->c.li, len));\n\t\tif (ms->c.li == NULL) {\n\t\t\tfile_oomem(ms, len);\n\t\t\treturn -1;\n\t\t}\n\t}\n\tms->c.li[level].got_match = 0;\n#ifdef ENABLE_CONDITIONALS\n\tms->c.li[level].last_match = 0;\n\tms->c.li[level].last_cond = COND_NONE;\n#endif /* ENABLE_CONDITIONALS */\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-8865", "cwe_id": "CWE-119" }, { "id": 3254, "func": "file_check_mem(struct magic_set *ms, unsigned int level)\n{\n\tsize_t len;\n\n\tif (level >= ms->c.len) {\n\t\tlen = (ms->c.len = 20 + level) * sizeof(*ms->c.li);\n\t\tms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ?\n\t\t malloc(len) :\n\t\t realloc(ms->c.li, len));\n\t\tif (ms->c.li == NULL) {\n\t\t\tfile_oomem(ms, len);\n\t\t\treturn -1;\n\t\t}\n\t}\n\tms->c.li[level].got_match = 0;\n#ifdef ENABLE_CONDITIONALS\n\tms->c.li[level].last_match = 0;\n\tms->c.li[level].last_cond = COND_NONE;\n#endif /* ENABLE_CONDITIONALS */\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-8865", "cwe_id": "CWE-119" }, { "id": 3057, "func": "TfLiteStatus LessEqualEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n bool requires_broadcast = !HaveSameShapes(input1, input2);\n switch (input1->type) {\n case kTfLiteFloat32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt64:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteUInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n default:\n context->ReportError(context,\n \"Does not support type %d, requires float|int|uint8\",\n input1->type);\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3057, "func": "TfLiteStatus LessEqualEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n bool requires_broadcast = !HaveSameShapes(input1, input2);\n switch (input1->type) {\n case kTfLiteFloat32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt64:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteUInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n default:\n context->ReportError(context,\n \"Does not support type %d, requires float|int|uint8\",\n input1->type);\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2340, "func": "int git_pkt_parse_line(\n\tgit_pkt **head, const char *line, const char **out, size_t bufflen)\n{\n\tint ret;\n\tint32_t len;\n\n\t/* Not even enough for the length */\n\tif (bufflen > 0 && bufflen < PKT_LEN_SIZE)\n\t\treturn GIT_EBUFS;\n\n\tlen = parse_len(line);\n\tif (len < 0) {\n\t\t/*\n\t\t * If we fail to parse the length, it might be because the\n\t\t * server is trying to send us the packfile already.\n\t\t */\n\t\tif (bufflen >= 4 && !git__prefixcmp(line, \"PACK\")) {\n\t\t\tgiterr_clear();\n\t\t\t*out = line;\n\t\t\treturn pack_pkt(head);\n\t\t}\n\n\t\treturn (int)len;\n\t}\n\n\t/*\n\t * If we were given a buffer length, then make sure there is\n\t * enough in the buffer to satisfy this line\n\t */\n\tif (bufflen > 0 && bufflen < (size_t)len)\n\t\treturn GIT_EBUFS;\n\n\t/*\n\t * The length has to be exactly 0 in case of a flush\n\t * packet or greater than PKT_LEN_SIZE, as the decoded\n\t * length includes its own encoded length of four bytes.\n\t */\n\tif (len != 0 && len < PKT_LEN_SIZE)\n\t\treturn GIT_ERROR;\n\n\tline += PKT_LEN_SIZE;\n\t/*\n\t * TODO: How do we deal with empty lines? Try again? with the next\n\t * line?\n\t */\n\tif (len == PKT_LEN_SIZE) {\n\t\t*head = NULL;\n\t\t*out = line;\n\t\treturn 0;\n\t}\n\n\tif (len == 0) { /* Flush pkt */\n\t\t*out = line;\n\t\treturn flush_pkt(head);\n\t}\n\n\tlen -= PKT_LEN_SIZE; /* the encoded length includes its own size */\n\n\tif (*line == GIT_SIDE_BAND_DATA)\n\t\tret = data_pkt(head, line, len);\n\telse if (*line == GIT_SIDE_BAND_PROGRESS)\n\t\tret = sideband_progress_pkt(head, line, len);\n\telse if (*line == GIT_SIDE_BAND_ERROR)\n\t\tret = sideband_error_pkt(head, line, len);\n\telse if (!git__prefixcmp(line, \"ACK\"))\n\t\tret = ack_pkt(head, line, len);\n\telse if (!git__prefixcmp(line, \"NAK\"))\n\t\tret = nak_pkt(head);\n\telse if (!git__prefixcmp(line, \"ERR \"))\n\t\tret = err_pkt(head, line, len);\n\telse if (*line == '#')\n\t\tret = comment_pkt(head, line, len);\n\telse if (!git__prefixcmp(line, \"ok\"))\n\t\tret = ok_pkt(head, line, len);\n\telse if (!git__prefixcmp(line, \"ng\"))\n\t\tret = ng_pkt(head, line, len);\n\telse if (!git__prefixcmp(line, \"unpack\"))\n\t\tret = unpack_pkt(head, line, len);\n\telse\n\t\tret = ref_pkt(head, line, len);\n\n\t*out = line + len;\n\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10129", "cwe_id": "CWE-476" }, { "id": 2340, "func": "int git_pkt_parse_line(\n\tgit_pkt **head, const char *line, const char **out, size_t bufflen)\n{\n\tint ret;\n\tint32_t len;\n\n\t/* Not even enough for the length */\n\tif (bufflen > 0 && bufflen < PKT_LEN_SIZE)\n\t\treturn GIT_EBUFS;\n\n\tlen = parse_len(line);\n\tif (len < 0) {\n\t\t/*\n\t\t * If we fail to parse the length, it might be because the\n\t\t * server is trying to send us the packfile already.\n\t\t */\n\t\tif (bufflen >= 4 && !git__prefixcmp(line, \"PACK\")) {\n\t\t\tgiterr_clear();\n\t\t\t*out = line;\n\t\t\treturn pack_pkt(head);\n\t\t}\n\n\t\treturn (int)len;\n\t}\n\n\t/*\n\t * If we were given a buffer length, then make sure there is\n\t * enough in the buffer to satisfy this line\n\t */\n\tif (bufflen > 0 && bufflen < (size_t)len)\n\t\treturn GIT_EBUFS;\n\n\t/*\n\t * The length has to be exactly 0 in case of a flush\n\t * packet or greater than PKT_LEN_SIZE, as the decoded\n\t * length includes its own encoded length of four bytes.\n\t */\n\tif (len != 0 && len < PKT_LEN_SIZE)\n\t\treturn GIT_ERROR;\n\n\tline += PKT_LEN_SIZE;\n\t/*\n\t * The Git protocol does not specify empty lines as part\n\t * of the protocol. Not knowing what to do with an empty\n\t * line, we should return an error upon hitting one.\n\t */\n\tif (len == PKT_LEN_SIZE) {\n\t\tgiterr_set_str(GITERR_NET, \"Invalid empty packet\");\n\t\treturn GIT_ERROR;\n\t}\n\n\tif (len == 0) { /* Flush pkt */\n\t\t*out = line;\n\t\treturn flush_pkt(head);\n\t}\n\n\tlen -= PKT_LEN_SIZE; /* the encoded length includes its own size */\n\n\tif (*line == GIT_SIDE_BAND_DATA)\n\t\tret = data_pkt(head, line, len);\n\telse if (*line == GIT_SIDE_BAND_PROGRESS)\n\t\tret = sideband_progress_pkt(head, line, len);\n\telse if (*line == GIT_SIDE_BAND_ERROR)\n\t\tret = sideband_error_pkt(head, line, len);\n\telse if (!git__prefixcmp(line, \"ACK\"))\n\t\tret = ack_pkt(head, line, len);\n\telse if (!git__prefixcmp(line, \"NAK\"))\n\t\tret = nak_pkt(head);\n\telse if (!git__prefixcmp(line, \"ERR \"))\n\t\tret = err_pkt(head, line, len);\n\telse if (*line == '#')\n\t\tret = comment_pkt(head, line, len);\n\telse if (!git__prefixcmp(line, \"ok\"))\n\t\tret = ok_pkt(head, line, len);\n\telse if (!git__prefixcmp(line, \"ng\"))\n\t\tret = ng_pkt(head, line, len);\n\telse if (!git__prefixcmp(line, \"unpack\"))\n\t\tret = unpack_pkt(head, line, len);\n\telse\n\t\tret = ref_pkt(head, line, len);\n\n\t*out = line + len;\n\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10129", "cwe_id": "CWE-476" }, { "id": 3154, "func": "static inline int xsave_state_booting(struct xsave_struct *fx, u64 mask)\n{\n\tu32 lmask = mask;\n\tu32 hmask = mask >> 32;\n\tint err = 0;\n\n\tWARN_ON(system_state != SYSTEM_BOOTING);\n\n\tif (boot_cpu_has(X86_FEATURE_XSAVES))\n\t\tasm volatile(\"1:\"XSAVES\"\\n\\t\"\n\t\t\t\"2:\\n\\t\"\n\t\t\t: : \"D\" (fx), \"m\" (*fx), \"a\" (lmask), \"d\" (hmask)\n\t\t\t: \"memory\");\n\telse\n\t\tasm volatile(\"1:\"XSAVE\"\\n\\t\"\n\t\t\t\"2:\\n\\t\"\n\t\t\t: : \"D\" (fx), \"m\" (*fx), \"a\" (lmask), \"d\" (hmask)\n\t\t\t: \"memory\");\n\n\tasm volatile(xstate_fault\n\t\t : \"0\" (0)\n\t\t : \"memory\");\n\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-2672", "cwe_id": "CWE-20" }, { "id": 3154, "func": "static inline int xsave_state_booting(struct xsave_struct *fx, u64 mask)\n{\n\tu32 lmask = mask;\n\tu32 hmask = mask >> 32;\n\tint err = 0;\n\n\tWARN_ON(system_state != SYSTEM_BOOTING);\n\n\tif (boot_cpu_has(X86_FEATURE_XSAVES))\n\t\tasm volatile(\"1:\"XSAVES\"\\n\\t\"\n\t\t\t\"2:\\n\\t\"\n\t\t\t xstate_fault\n\t\t\t: \"D\" (fx), \"m\" (*fx), \"a\" (lmask), \"d\" (hmask)\n\t\t\t: \"memory\");\n\telse\n\t\tasm volatile(\"1:\"XSAVE\"\\n\\t\"\n\t\t\t\"2:\\n\\t\"\n\t\t\t xstate_fault\n\t\t\t: \"D\" (fx), \"m\" (*fx), \"a\" (lmask), \"d\" (hmask)\n\t\t\t: \"memory\");\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-2672", "cwe_id": "CWE-20" }, { "id": 1330, "func": "static int verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)\n{\n pj_ssl_sock_t *ssock;\n SSL *ossl_ssl;\n int err;\n\n /* Get SSL instance */\n ossl_ssl = X509_STORE_CTX_get_ex_data(x509_ctx, \n\t\t\t\t SSL_get_ex_data_X509_STORE_CTX_idx());\n pj_assert(ossl_ssl);\n\n /* Get SSL socket instance */\n ssock = SSL_get_ex_data(ossl_ssl, sslsock_idx);\n pj_assert(ssock);\n\n /* Store verification status */\n err = X509_STORE_CTX_get_error(x509_ctx);\n switch (err) {\n case X509_V_OK:\n\tbreak;\n\n case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:\n\tssock->verify_status |= PJ_SSL_CERT_EISSUER_NOT_FOUND;\n\tbreak;\n\n case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:\n case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:\n case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:\n case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:\n\tssock->verify_status |= PJ_SSL_CERT_EINVALID_FORMAT;\n\tbreak;\n\n case X509_V_ERR_CERT_NOT_YET_VALID:\n case X509_V_ERR_CERT_HAS_EXPIRED:\n\tssock->verify_status |= PJ_SSL_CERT_EVALIDITY_PERIOD;\n\tbreak;\n\n case X509_V_ERR_UNABLE_TO_GET_CRL:\n case X509_V_ERR_CRL_NOT_YET_VALID:\n case X509_V_ERR_CRL_HAS_EXPIRED:\n case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE:\n case X509_V_ERR_CRL_SIGNATURE_FAILURE:\n case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:\n case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:\n\tssock->verify_status |= PJ_SSL_CERT_ECRL_FAILURE;\n\tbreak;\t\n\n case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:\n case X509_V_ERR_CERT_UNTRUSTED:\n case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:\n case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:\n\tssock->verify_status |= PJ_SSL_CERT_EUNTRUSTED;\n\tbreak;\t\n\n case X509_V_ERR_CERT_SIGNATURE_FAILURE:\n case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:\n case X509_V_ERR_SUBJECT_ISSUER_MISMATCH:\n case X509_V_ERR_AKID_SKID_MISMATCH:\n case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH:\n case X509_V_ERR_KEYUSAGE_NO_CERTSIGN:\n\tssock->verify_status |= PJ_SSL_CERT_EISSUER_MISMATCH;\n\tbreak;\n\n case X509_V_ERR_CERT_REVOKED:\n\tssock->verify_status |= PJ_SSL_CERT_EREVOKED;\n\tbreak;\t\n\n case X509_V_ERR_INVALID_PURPOSE:\n case X509_V_ERR_CERT_REJECTED:\n case X509_V_ERR_INVALID_CA:\n\tssock->verify_status |= PJ_SSL_CERT_EINVALID_PURPOSE;\n\tbreak;\n\n case X509_V_ERR_CERT_CHAIN_TOO_LONG: /* not really used */\n case X509_V_ERR_PATH_LENGTH_EXCEEDED:\n\tssock->verify_status |= PJ_SSL_CERT_ECHAIN_TOO_LONG;\n\tbreak;\n\n /* Unknown errors */\n case X509_V_ERR_OUT_OF_MEM:\n default:\n\tssock->verify_status |= PJ_SSL_CERT_EUNKNOWN;\n\tbreak;\n }\n\n /* When verification is not requested just return ok here, however\n * application can still get the verification status.\n */\n if (PJ_FALSE == ssock->param.verify_peer)\n\tpreverify_ok = 1;\n\n return preverify_ok;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-32686", "cwe_id": "CWE-362" }, { "id": 1330, "func": "static int verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)\n{\n pj_ssl_sock_t *ssock = NULL;\n SSL *ossl_ssl = NULL;\n int err;\n\n /* Get SSL instance */\n ossl_ssl = X509_STORE_CTX_get_ex_data(x509_ctx, \n\t\t\t\t SSL_get_ex_data_X509_STORE_CTX_idx());\n if (!ossl_ssl) {\n\tPJ_LOG(1,(THIS_FILE,\n\t\t \"SSL verification callback failed to get SSL instance\"));\n\tgoto on_return;\n }\n\n /* Get SSL socket instance */\n ssock = SSL_get_ex_data(ossl_ssl, sslsock_idx);\n if (!ssock) {\n\t/* SSL socket may have been destroyed */\n\tPJ_LOG(1,(THIS_FILE,\n\t\t \"SSL verification callback failed to get SSL socket \"\n\t\t \"instance (sslsock_idx=%d).\", sslsock_idx));\n\tgoto on_return;\n }\n\n /* Store verification status */\n err = X509_STORE_CTX_get_error(x509_ctx);\n switch (err) {\n case X509_V_OK:\n\tbreak;\n\n case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:\n\tssock->verify_status |= PJ_SSL_CERT_EISSUER_NOT_FOUND;\n\tbreak;\n\n case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:\n case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:\n case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:\n case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:\n\tssock->verify_status |= PJ_SSL_CERT_EINVALID_FORMAT;\n\tbreak;\n\n case X509_V_ERR_CERT_NOT_YET_VALID:\n case X509_V_ERR_CERT_HAS_EXPIRED:\n\tssock->verify_status |= PJ_SSL_CERT_EVALIDITY_PERIOD;\n\tbreak;\n\n case X509_V_ERR_UNABLE_TO_GET_CRL:\n case X509_V_ERR_CRL_NOT_YET_VALID:\n case X509_V_ERR_CRL_HAS_EXPIRED:\n case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE:\n case X509_V_ERR_CRL_SIGNATURE_FAILURE:\n case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:\n case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:\n\tssock->verify_status |= PJ_SSL_CERT_ECRL_FAILURE;\n\tbreak;\t\n\n case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:\n case X509_V_ERR_CERT_UNTRUSTED:\n case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:\n case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:\n\tssock->verify_status |= PJ_SSL_CERT_EUNTRUSTED;\n\tbreak;\t\n\n case X509_V_ERR_CERT_SIGNATURE_FAILURE:\n case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:\n case X509_V_ERR_SUBJECT_ISSUER_MISMATCH:\n case X509_V_ERR_AKID_SKID_MISMATCH:\n case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH:\n case X509_V_ERR_KEYUSAGE_NO_CERTSIGN:\n\tssock->verify_status |= PJ_SSL_CERT_EISSUER_MISMATCH;\n\tbreak;\n\n case X509_V_ERR_CERT_REVOKED:\n\tssock->verify_status |= PJ_SSL_CERT_EREVOKED;\n\tbreak;\t\n\n case X509_V_ERR_INVALID_PURPOSE:\n case X509_V_ERR_CERT_REJECTED:\n case X509_V_ERR_INVALID_CA:\n\tssock->verify_status |= PJ_SSL_CERT_EINVALID_PURPOSE;\n\tbreak;\n\n case X509_V_ERR_CERT_CHAIN_TOO_LONG: /* not really used */\n case X509_V_ERR_PATH_LENGTH_EXCEEDED:\n\tssock->verify_status |= PJ_SSL_CERT_ECHAIN_TOO_LONG;\n\tbreak;\n\n /* Unknown errors */\n case X509_V_ERR_OUT_OF_MEM:\n default:\n\tssock->verify_status |= PJ_SSL_CERT_EUNKNOWN;\n\tbreak;\n }\n\n /* When verification is not requested just return ok here, however\n * application can still get the verification status.\n */\n if (PJ_FALSE == ssock->param.verify_peer)\n\tpreverify_ok = 1;\n\non_return:\n return preverify_ok;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-32686", "cwe_id": "CWE-362" }, { "id": 1210, "func": "static int inet_sk_reselect_saddr(struct sock *sk)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\t__be32 old_saddr = inet->inet_saddr;\n\t__be32 daddr = inet->inet_daddr;\n\tstruct flowi4 fl4;\n\tstruct rtable *rt;\n\t__be32 new_saddr;\n\n\tif (inet->opt && inet->opt->srr)\n\t\tdaddr = inet->opt->faddr;\n\n\t/* Query new route. */\n\trt = ip_route_connect(&fl4, daddr, 0, RT_CONN_FLAGS(sk),\n\t\t\t sk->sk_bound_dev_if, sk->sk_protocol,\n\t\t\t inet->inet_sport, inet->inet_dport, sk, false);\n\tif (IS_ERR(rt))\n\t\treturn PTR_ERR(rt);\n\n\tsk_setup_caps(sk, &rt->dst);\n\n\tnew_saddr = rt->rt_src;\n\n\tif (new_saddr == old_saddr)\n\t\treturn 0;\n\n\tif (sysctl_ip_dynaddr > 1) {\n\t\tprintk(KERN_INFO \"%s(): shifting inet->saddr from %pI4 to %pI4\\n\",\n\t\t __func__, &old_saddr, &new_saddr);\n\t}\n\n\tinet->inet_saddr = inet->inet_rcv_saddr = new_saddr;\n\n\t/*\n\t * XXX The only one ugly spot where we need to\n\t * XXX really change the sockets identity after\n\t * XXX it has entered the hashes. -DaveM\n\t *\n\t * Besides that, it does not check for connection\n\t * uniqueness. Wait for troubles.\n\t */\n\t__sk_prot_rehash(sk);\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 1210, "func": "static int inet_sk_reselect_saddr(struct sock *sk)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\t__be32 old_saddr = inet->inet_saddr;\n\t__be32 daddr = inet->inet_daddr;\n\tstruct flowi4 fl4;\n\tstruct rtable *rt;\n\t__be32 new_saddr;\n\tstruct ip_options_rcu *inet_opt;\n\n\tinet_opt = rcu_dereference_protected(inet->inet_opt,\n\t\t\t\t\t sock_owned_by_user(sk));\n\tif (inet_opt && inet_opt->opt.srr)\n\t\tdaddr = inet_opt->opt.faddr;\n\n\t/* Query new route. */\n\trt = ip_route_connect(&fl4, daddr, 0, RT_CONN_FLAGS(sk),\n\t\t\t sk->sk_bound_dev_if, sk->sk_protocol,\n\t\t\t inet->inet_sport, inet->inet_dport, sk, false);\n\tif (IS_ERR(rt))\n\t\treturn PTR_ERR(rt);\n\n\tsk_setup_caps(sk, &rt->dst);\n\n\tnew_saddr = rt->rt_src;\n\n\tif (new_saddr == old_saddr)\n\t\treturn 0;\n\n\tif (sysctl_ip_dynaddr > 1) {\n\t\tprintk(KERN_INFO \"%s(): shifting inet->saddr from %pI4 to %pI4\\n\",\n\t\t __func__, &old_saddr, &new_saddr);\n\t}\n\n\tinet->inet_saddr = inet->inet_rcv_saddr = new_saddr;\n\n\t/*\n\t * XXX The only one ugly spot where we need to\n\t * XXX really change the sockets identity after\n\t * XXX it has entered the hashes. -DaveM\n\t *\n\t * Besides that, it does not check for connection\n\t * uniqueness. Wait for troubles.\n\t */\n\t__sk_prot_rehash(sk);\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 654, "func": "static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)\n{\n unsigned long len;\n GET_STATE(self);\n Check_Type(object_nl, T_STRING);\n len = RSTRING_LEN(object_nl);\n if (len == 0) {\n if (state->object_nl) {\n ruby_xfree(state->object_nl);\n state->object_nl = NULL;\n }\n } else {\n if (state->object_nl) ruby_xfree(state->object_nl);\n state->object_nl = strdup(RSTRING_PTR(object_nl));\n state->object_nl_len = len;\n }\n return Qnil;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-14064", "cwe_id": "CWE-119" }, { "id": 654, "func": "static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)\n{\n unsigned long len;\n GET_STATE(self);\n Check_Type(object_nl, T_STRING);\n len = RSTRING_LEN(object_nl);\n if (len == 0) {\n if (state->object_nl) {\n ruby_xfree(state->object_nl);\n state->object_nl = NULL;\n }\n } else {\n if (state->object_nl) ruby_xfree(state->object_nl);\n state->object_nl = fstrndup(RSTRING_PTR(object_nl), len);\n state->object_nl_len = len;\n }\n return Qnil;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-14064", "cwe_id": "CWE-119" }, { "id": 294, "func": "static MOBI_RET mobi_decompress_huffman_internal(MOBIBuffer *buf_out, MOBIBuffer *buf_in, const MOBIHuffCdic *huffcdic, size_t depth) {\n if (depth > MOBI_HUFFMAN_MAXDEPTH) {\n debug_print(\"Too many levels of recursion: %zu\\n\", depth);\n return MOBI_DATA_CORRUPT;\n }\n MOBI_RET ret = MOBI_SUCCESS;\n int8_t bitcount = 32;\n /* this cast should be safe: max record size is 4096 */\n int bitsleft = (int) (buf_in->maxlen * 8);\n uint8_t code_length = 0;\n uint64_t buffer = mobi_buffer_fill64(buf_in);\n while (ret == MOBI_SUCCESS) {\n if (bitcount <= 0) {\n bitcount += 32;\n buffer = mobi_buffer_fill64(buf_in);\n }\n uint32_t code = (buffer >> bitcount) & 0xffffffffU;\n /* lookup code in table1 */\n uint32_t t1 = huffcdic->table1[code >> 24];\n /* get maxcode and codelen from t1 */\n code_length = t1 & 0x1f;\n uint32_t maxcode = (((t1 >> 8) + 1) << (32 - code_length)) - 1;\n /* check termination bit */\n if (!(t1 & 0x80)) {\n /* get offset from mincode, maxcode tables */\n while (code < huffcdic->mincode_table[code_length]) {\n code_length++;\n }\n maxcode = huffcdic->maxcode_table[code_length];\n }\n bitcount -= code_length;\n bitsleft -= code_length;\n if (bitsleft < 0) {\n break;\n }\n /* get index for symbol offset */\n uint32_t index = (uint32_t) (maxcode - code) >> (32 - code_length);\n /* check which part of cdic to use */\n uint16_t cdic_index = (uint16_t) ((uint32_t)index >> huffcdic->code_length);\n if (index >= huffcdic->index_count) {\n debug_print(\"Wrong symbol offsets index: %u\\n\", index);\n return MOBI_DATA_CORRUPT;\n }\n /* get offset */\n uint32_t offset = huffcdic->symbol_offsets[index];\n uint32_t symbol_length = (uint32_t) huffcdic->symbols[cdic_index][offset] << 8 | (uint32_t) huffcdic->symbols[cdic_index][offset + 1];\n /* 1st bit is is_decompressed flag */\n int is_decompressed = symbol_length >> 15;\n /* get rid of flag */\n symbol_length &= 0x7fff;\n if (is_decompressed) {\n /* symbol is at (offset + 2), 2 bytes used earlier for symbol length */\n mobi_buffer_addraw(buf_out, (huffcdic->symbols[cdic_index] + offset + 2), symbol_length);\n ret = buf_out->error;\n } else {\n /* symbol is compressed */\n /* TODO cache uncompressed symbols? */\n MOBIBuffer buf_sym;\n buf_sym.data = huffcdic->symbols[cdic_index] + offset + 2;\n buf_sym.offset = 0;\n buf_sym.maxlen = symbol_length;\n buf_sym.error = MOBI_SUCCESS;\n ret = mobi_decompress_huffman_internal(buf_out, &buf_sym, huffcdic, depth + 1);\n }\n }\n return ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-3881", "cwe_id": "CWE-125" }, { "id": 294, "func": "static MOBI_RET mobi_decompress_huffman_internal(MOBIBuffer *buf_out, MOBIBuffer *buf_in, const MOBIHuffCdic *huffcdic, size_t depth) {\n if (depth > MOBI_HUFFMAN_MAXDEPTH) {\n debug_print(\"Too many levels of recursion: %zu\\n\", depth);\n return MOBI_DATA_CORRUPT;\n }\n MOBI_RET ret = MOBI_SUCCESS;\n int8_t bitcount = 32;\n /* this cast should be safe: max record size is 4096 */\n int bitsleft = (int) (buf_in->maxlen * 8);\n uint8_t code_length = 0;\n uint64_t buffer = mobi_buffer_fill64(buf_in);\n while (ret == MOBI_SUCCESS) {\n if (bitcount <= 0) {\n bitcount += 32;\n buffer = mobi_buffer_fill64(buf_in);\n }\n uint32_t code = (buffer >> bitcount) & 0xffffffffU;\n /* lookup code in table1 */\n uint32_t t1 = huffcdic->table1[code >> 24];\n /* get maxcode and codelen from t1 */\n code_length = t1 & 0x1f;\n uint32_t maxcode = (((t1 >> 8) + 1) << (32 - code_length)) - 1;\n /* check termination bit */\n if (!(t1 & 0x80)) {\n /* get offset from mincode, maxcode tables */\n while (code < huffcdic->mincode_table[code_length]) {\n if (++code_length >= HUFF_CODETABLE_SIZE) {\n debug_print(\"Wrong offset to mincode table: %hhu\\n\", code_length);\n return MOBI_DATA_CORRUPT;\n }\n }\n maxcode = huffcdic->maxcode_table[code_length];\n }\n bitcount -= code_length;\n bitsleft -= code_length;\n if (bitsleft < 0) {\n break;\n }\n /* get index for symbol offset */\n uint32_t index = (uint32_t) (maxcode - code) >> (32 - code_length);\n /* check which part of cdic to use */\n uint16_t cdic_index = (uint16_t) ((uint32_t)index >> huffcdic->code_length);\n if (index >= huffcdic->index_count) {\n debug_print(\"Wrong symbol offsets index: %u\\n\", index);\n return MOBI_DATA_CORRUPT;\n }\n /* get offset */\n uint32_t offset = huffcdic->symbol_offsets[index];\n uint32_t symbol_length = (uint32_t) huffcdic->symbols[cdic_index][offset] << 8 | (uint32_t) huffcdic->symbols[cdic_index][offset + 1];\n /* 1st bit is is_decompressed flag */\n int is_decompressed = symbol_length >> 15;\n /* get rid of flag */\n symbol_length &= 0x7fff;\n if (is_decompressed) {\n /* symbol is at (offset + 2), 2 bytes used earlier for symbol length */\n mobi_buffer_addraw(buf_out, (huffcdic->symbols[cdic_index] + offset + 2), symbol_length);\n ret = buf_out->error;\n } else {\n /* symbol is compressed */\n /* TODO cache uncompressed symbols? */\n MOBIBuffer buf_sym;\n buf_sym.data = huffcdic->symbols[cdic_index] + offset + 2;\n buf_sym.offset = 0;\n buf_sym.maxlen = symbol_length;\n buf_sym.error = MOBI_SUCCESS;\n ret = mobi_decompress_huffman_internal(buf_out, &buf_sym, huffcdic, depth + 1);\n }\n }\n return ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-3881", "cwe_id": "CWE-125" }, { "id": 665, "func": "GIOChannel *net_connect_ip_ssl(IPADDR *ip, int port, IPADDR *my_ip, const char *cert, const char *pkey, const char *cafile, const char *capath, gboolean verify)\n{\n\tGIOChannel *handle, *ssl_handle;\n\n\thandle = net_connect_ip(ip, port, my_ip);\n\tif (handle == NULL)\n\t\treturn NULL;\n\tssl_handle = irssi_ssl_get_iochannel(handle, cert, pkey, cafile, capath, verify);\n\tif (ssl_handle == NULL)\n\t\tg_io_channel_unref(handle);\n\treturn ssl_handle;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2010-1155", "cwe_id": "CWE-20" }, { "id": 665, "func": "GIOChannel *net_connect_ip_ssl(IPADDR *ip, int port, const char* hostname, IPADDR *my_ip, const char *cert, const char *pkey, const char *cafile, const char *capath, gboolean verify)\n{\n\tGIOChannel *handle, *ssl_handle;\n\n\thandle = net_connect_ip(ip, port, my_ip);\n\tif (handle == NULL)\n\t\treturn NULL;\n\tssl_handle = irssi_ssl_get_iochannel(handle, hostname, cert, pkey, cafile, capath, verify);\n\tif (ssl_handle == NULL)\n\t\tg_io_channel_unref(handle);\n\treturn ssl_handle;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2010-1155", "cwe_id": "CWE-20" }, { "id": 1749, "func": "Java_org_tensorflow_lite_InterpreterTest_getNativeHandleForDelegate(\n JNIEnv* env, jclass clazz) {\n // A simple op which outputs a tensor with values of 7.\n static TfLiteRegistration registration = {\n .init = nullptr,\n .free = nullptr,\n .prepare =\n [](TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input = tflite::GetInput(context, node, 0);\n TfLiteTensor* output = tflite::GetOutput(context, node, 0);\n TfLiteIntArray* output_dims = TfLiteIntArrayCopy(input->dims);\n output->type = kTfLiteFloat32;\n return context->ResizeTensor(context, output, output_dims);\n },\n .invoke =\n [](TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output = tflite::GetOutput(context, node, 0);\n std::fill(output->data.f,\n output->data.f + tflite::NumElements(output), 7.0f);\n return kTfLiteOk;\n },\n .profiling_string = nullptr,\n .builtin_code = 0,\n .custom_name = \"\",\n .version = 1,\n };\n static TfLiteDelegate delegate = {\n .data_ = nullptr,\n .Prepare = [](TfLiteContext* context,\n TfLiteDelegate* delegate) -> TfLiteStatus {\n TfLiteIntArray* execution_plan;\n TF_LITE_ENSURE_STATUS(\n context->GetExecutionPlan(context, &execution_plan));\n context->ReplaceNodeSubsetsWithDelegateKernels(\n context, registration, execution_plan, delegate);\n // Now bind delegate buffer handles for all tensors.\n for (size_t i = 0; i < context->tensors_size; ++i) {\n context->tensors[i].delegate = delegate;\n context->tensors[i].buffer_handle = static_cast(i);\n }\n return kTfLiteOk;\n },\n .CopyFromBufferHandle = nullptr,\n .CopyToBufferHandle = nullptr,\n .FreeBufferHandle = nullptr,\n .flags = kTfLiteDelegateFlagsAllowDynamicTensors,\n };\n return reinterpret_cast(&delegate);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1749, "func": "Java_org_tensorflow_lite_InterpreterTest_getNativeHandleForDelegate(\n JNIEnv* env, jclass clazz) {\n // A simple op which outputs a tensor with values of 7.\n static TfLiteRegistration registration = {\n .init = nullptr,\n .free = nullptr,\n .prepare =\n [](TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context,\n tflite::GetInputSafe(context, node, 0, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n tflite::GetOutputSafe(context, node, 0, &output));\n TfLiteIntArray* output_dims = TfLiteIntArrayCopy(input->dims);\n output->type = kTfLiteFloat32;\n return context->ResizeTensor(context, output, output_dims);\n },\n .invoke =\n [](TfLiteContext* context, TfLiteNode* node) {\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n tflite::GetOutputSafe(context, node, 0, &output));\n std::fill(output->data.f,\n output->data.f + tflite::NumElements(output), 7.0f);\n return kTfLiteOk;\n },\n .profiling_string = nullptr,\n .builtin_code = 0,\n .custom_name = \"\",\n .version = 1,\n };\n static TfLiteDelegate delegate = {\n .data_ = nullptr,\n .Prepare = [](TfLiteContext* context,\n TfLiteDelegate* delegate) -> TfLiteStatus {\n TfLiteIntArray* execution_plan;\n TF_LITE_ENSURE_STATUS(\n context->GetExecutionPlan(context, &execution_plan));\n context->ReplaceNodeSubsetsWithDelegateKernels(\n context, registration, execution_plan, delegate);\n // Now bind delegate buffer handles for all tensors.\n for (size_t i = 0; i < context->tensors_size; ++i) {\n context->tensors[i].delegate = delegate;\n context->tensors[i].buffer_handle = static_cast(i);\n }\n return kTfLiteOk;\n },\n .CopyFromBufferHandle = nullptr,\n .CopyToBufferHandle = nullptr,\n .FreeBufferHandle = nullptr,\n .flags = kTfLiteDelegateFlagsAllowDynamicTensors,\n };\n return reinterpret_cast(&delegate);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2549, "func": "static int atusb_get_and_show_build(struct atusb *atusb)\n{\n\tstruct usb_device *usb_dev = atusb->usb_dev;\n\tchar build[ATUSB_BUILD_SIZE + 1];\n\tint ret;\n\n\tret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),\n\t\t\t\tATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0,\n\t\t\t\tbuild, ATUSB_BUILD_SIZE, 1000);\n\tif (ret >= 0) {\n\t\tbuild[ret] = 0;\n\t\tdev_info(&usb_dev->dev, \"Firmware: build %s\\n\", build);\n\t}\n\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-5548", "cwe_id": "CWE-119" }, { "id": 2549, "func": "static int atusb_get_and_show_build(struct atusb *atusb)\n{\n\tstruct usb_device *usb_dev = atusb->usb_dev;\n\tchar *build;\n\tint ret;\n\n\tbuild = kmalloc(ATUSB_BUILD_SIZE + 1, GFP_KERNEL);\n\tif (!build)\n\t\treturn -ENOMEM;\n\n\tret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),\n\t\t\t\tATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0,\n\t\t\t\tbuild, ATUSB_BUILD_SIZE, 1000);\n\tif (ret >= 0) {\n\t\tbuild[ret] = 0;\n\t\tdev_info(&usb_dev->dev, \"Firmware: build %s\\n\", build);\n\t}\n\n\tkfree(build);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-5548", "cwe_id": "CWE-119" }, { "id": 1513, "func": "int jp2_box_put(jp2_box_t *box, jas_stream_t *out)\n{\n\tjas_stream_t *tmpstream;\n\tbool extlen;\n\tbool dataflag;\n\n\ttmpstream = 0;\n\n\tdataflag = !(box->info->flags & (JP2_BOX_SUPER | JP2_BOX_NODATA));\n\n\tif (dataflag) {\n\t\tif (!(tmpstream = jas_stream_memopen(0, 0))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (box->ops->putdata) {\n\t\t\tif ((*box->ops->putdata)(box, tmpstream)) {\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t}\n\t\tbox->len = jas_stream_tell(tmpstream) + JP2_BOX_HDRLEN(false);\n\t\tjas_stream_rewind(tmpstream);\n\t}\n\textlen = (box->len >= (((uint_fast64_t)1) << 32)) != 0;\n\tif (jp2_putuint32(out, extlen ? 1 : box->len)) {\n\t\tgoto error;\n\t}\n\tif (jp2_putuint32(out, box->type)) {\n\t\tgoto error;\n\t}\n\tif (extlen) {\n\t\tif (jp2_putuint64(out, box->len)) {\n\t\t\tgoto error;\n\t\t}\n\t}\n\n\tif (dataflag) {\n\t\tif (jas_stream_copy(out, tmpstream, box->len - JP2_BOX_HDRLEN(false))) {\n\t\t\tgoto error;\n\t\t}\n\t\tjas_stream_close(tmpstream);\n\t}\n\n\treturn 0;\n\nerror:\n\n\tif (tmpstream) {\n\t\tjas_stream_close(tmpstream);\n\t}\n\treturn -1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-6850", "cwe_id": "CWE-476" }, { "id": 1513, "func": "int jp2_box_put(jp2_box_t *box, jas_stream_t *out)\n{\n\tjas_stream_t *tmpstream;\n\tbool extlen;\n\tbool dataflag;\n\n\ttmpstream = 0;\n\n\tdataflag = !(box->info->flags & (JP2_BOX_SUPER | JP2_BOX_NODATA));\n\n\tif (dataflag) {\n\t\tif (!(tmpstream = jas_stream_memopen(0, 0))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (box->ops->putdata) {\n\t\t\tif ((*box->ops->putdata)(box, tmpstream)) {\n\t\t\t\tgoto error;\n\t\t\t}\n\t\t}\n\t\tbox->len = jas_stream_tell(tmpstream) + JP2_BOX_HDRLEN(false);\n\t\tjas_stream_rewind(tmpstream);\n\t}\n\textlen = (box->len >= (((uint_fast64_t)1) << 32)) != 0;\n\tif (jp2_putuint32(out, extlen ? 1 : box->len)) {\n\t\tgoto error;\n\t}\n\tif (jp2_putuint32(out, box->type)) {\n\t\tgoto error;\n\t}\n\tif (extlen) {\n\t\tif (jp2_putuint64(out, box->len)) {\n\t\t\tgoto error;\n\t\t}\n\t}\n\n\tif (dataflag) {\n\t\tif (jas_stream_copy(out, tmpstream, box->len -\n\t\t JP2_BOX_HDRLEN(false))) {\n\t\t\tjas_eprintf(\"cannot copy box data\\n\");\n\t\t\tgoto error;\n\t\t}\n\t\tjas_stream_close(tmpstream);\n\t}\n\n\treturn 0;\n\nerror:\n\n\tif (tmpstream) {\n\t\tjas_stream_close(tmpstream);\n\t}\n\treturn -1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-6850", "cwe_id": "CWE-476" }, { "id": 3030, "func": "int mif_validate(jas_stream_t *in)\n{\n\tuchar buf[MIF_MAGICLEN];\n\tuint_fast32_t magic;\n\tint i;\n\tint n;\n\n\tassert(JAS_STREAM_MAXPUTBACK >= MIF_MAGICLEN);\n\n\t/* Read the validation data (i.e., the data used for detecting\n\t the format). */\n\tif ((n = jas_stream_read(in, buf, MIF_MAGICLEN)) < 0) {\n\t\treturn -1;\n\t}\n\n\t/* Put the validation data back onto the stream, so that the\n\t stream position will not be changed. */\n\tfor (i = n - 1; i >= 0; --i) {\n\t\tif (jas_stream_ungetc(in, buf[i]) == EOF) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t/* Was enough data read? */\n\tif (n < MIF_MAGICLEN) {\n\t\treturn -1;\n\t}\n\n\t/* Compute the signature value. */\n\tmagic = (JAS_CAST(uint_fast32_t, buf[0]) << 24) |\n\t (JAS_CAST(uint_fast32_t, buf[1]) << 16) |\n\t (JAS_CAST(uint_fast32_t, buf[2]) << 8) |\n\t buf[3];\n\n\t/* Ensure that the signature is correct for this format. */\n\tif (magic != MIF_MAGIC) {\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 3030, "func": "int mif_validate(jas_stream_t *in)\n{\n\tjas_uchar buf[MIF_MAGICLEN];\n\tuint_fast32_t magic;\n\tint i;\n\tint n;\n\n\tassert(JAS_STREAM_MAXPUTBACK >= MIF_MAGICLEN);\n\n\t/* Read the validation data (i.e., the data used for detecting\n\t the format). */\n\tif ((n = jas_stream_read(in, buf, MIF_MAGICLEN)) < 0) {\n\t\treturn -1;\n\t}\n\n\t/* Put the validation data back onto the stream, so that the\n\t stream position will not be changed. */\n\tfor (i = n - 1; i >= 0; --i) {\n\t\tif (jas_stream_ungetc(in, buf[i]) == EOF) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t/* Was enough data read? */\n\tif (n < MIF_MAGICLEN) {\n\t\treturn -1;\n\t}\n\n\t/* Compute the signature value. */\n\tmagic = (JAS_CAST(uint_fast32_t, buf[0]) << 24) |\n\t (JAS_CAST(uint_fast32_t, buf[1]) << 16) |\n\t (JAS_CAST(uint_fast32_t, buf[2]) << 8) |\n\t buf[3];\n\n\t/* Ensure that the signature is correct for this format. */\n\tif (magic != MIF_MAGIC) {\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 1335, "func": "static int nr_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t struct msghdr *msg, size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;\n\tsize_t copied;\n\tstruct sk_buff *skb;\n\tint er;\n\n\t/*\n\t * This works for seqpacket too. The receiver has ordered the queue for\n\t * us! We do one quick check first though\n\t */\n\n\tlock_sock(sk);\n\tif (sk->sk_state != TCP_ESTABLISHED) {\n\t\trelease_sock(sk);\n\t\treturn -ENOTCONN;\n\t}\n\n\t/* Now we can treat all alike */\n\tif ((skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &er)) == NULL) {\n\t\trelease_sock(sk);\n\t\treturn er;\n\t}\n\n\tskb_reset_transport_header(skb);\n\tcopied = skb->len;\n\n\tif (copied > size) {\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\ter = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (er < 0) {\n\t\tskb_free_datagram(sk, skb);\n\t\trelease_sock(sk);\n\t\treturn er;\n\t}\n\n\tif (sax != NULL) {\n\t\tmemset(sax, 0, sizeof(*sax));\n\t\tsax->sax25_family = AF_NETROM;\n\t\tskb_copy_from_linear_data_offset(skb, 7, sax->sax25_call.ax25_call,\n\t\t\t AX25_ADDR_LEN);\n\t}\n\n\tmsg->msg_namelen = sizeof(*sax);\n\n\tskb_free_datagram(sk, skb);\n\n\trelease_sock(sk);\n\treturn copied;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-7266", "cwe_id": "CWE-20" }, { "id": 1335, "func": "static int nr_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t struct msghdr *msg, size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;\n\tsize_t copied;\n\tstruct sk_buff *skb;\n\tint er;\n\n\t/*\n\t * This works for seqpacket too. The receiver has ordered the queue for\n\t * us! We do one quick check first though\n\t */\n\n\tlock_sock(sk);\n\tif (sk->sk_state != TCP_ESTABLISHED) {\n\t\trelease_sock(sk);\n\t\treturn -ENOTCONN;\n\t}\n\n\t/* Now we can treat all alike */\n\tif ((skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &er)) == NULL) {\n\t\trelease_sock(sk);\n\t\treturn er;\n\t}\n\n\tskb_reset_transport_header(skb);\n\tcopied = skb->len;\n\n\tif (copied > size) {\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\ter = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (er < 0) {\n\t\tskb_free_datagram(sk, skb);\n\t\trelease_sock(sk);\n\t\treturn er;\n\t}\n\n\tif (sax != NULL) {\n\t\tmemset(sax, 0, sizeof(*sax));\n\t\tsax->sax25_family = AF_NETROM;\n\t\tskb_copy_from_linear_data_offset(skb, 7, sax->sax25_call.ax25_call,\n\t\t\t AX25_ADDR_LEN);\n\t\tmsg->msg_namelen = sizeof(*sax);\n\t}\n\n\tskb_free_datagram(sk, skb);\n\n\trelease_sock(sk);\n\treturn copied;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-7266", "cwe_id": "CWE-20" }, { "id": 3086, "func": "\nstatic void bfq_idle_slice_timer_body(struct bfq_queue *bfqq)\n{\n\tstruct bfq_data *bfqd = bfqq->bfqd;\n\tenum bfqq_expiration reason;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&bfqd->lock, flags);\n\tbfq_clear_bfqq_wait_request(bfqq);\n\n\tif (bfqq != bfqd->in_service_queue) {\n\t\tspin_unlock_irqrestore(&bfqd->lock, flags);\n\t\treturn;\n\t}\n\n\tif (bfq_bfqq_budget_timeout(bfqq))\n\t\t/*\n\t\t * Also here the queue can be safely expired\n\t\t * for budget timeout without wasting\n\t\t * guarantees\n\t\t */\n\t\treason = BFQQE_BUDGET_TIMEOUT;\n\telse if (bfqq->queued[0] == 0 && bfqq->queued[1] == 0)\n\t\t/*\n\t\t * The queue may not be empty upon timer expiration,\n\t\t * because we may not disable the timer when the\n\t\t * first request of the in-service queue arrives\n\t\t * during disk idling.\n\t\t */\n\t\treason = BFQQE_TOO_IDLE;\n\telse\n\t\tgoto schedule_dispatch;\n\n\tbfq_bfqq_expire(bfqd, bfqq, true, reason);\n\nschedule_dispatch:\n\tspin_unlock_irqrestore(&bfqd->lock, flags);\n\tbfq_schedule_dispatch(bfqd);", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12657", "cwe_id": "CWE-416" }, { "id": 3086, "func": "static void\nbfq_idle_slice_timer_body(struct bfq_data *bfqd, struct bfq_queue *bfqq)\n{\n\tenum bfqq_expiration reason;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&bfqd->lock, flags);\n\n\t/*\n\t * Considering that bfqq may be in race, we should firstly check\n\t * whether bfqq is in service before doing something on it. If\n\t * the bfqq in race is not in service, it has already been expired\n\t * through __bfq_bfqq_expire func and its wait_request flags has\n\t * been cleared in __bfq_bfqd_reset_in_service func.\n\t */\n\tif (bfqq != bfqd->in_service_queue) {\n\t\tspin_unlock_irqrestore(&bfqd->lock, flags);\n\t\treturn;\n\t}\n\n\tbfq_clear_bfqq_wait_request(bfqq);\n\n\tif (bfq_bfqq_budget_timeout(bfqq))\n\t\t/*\n\t\t * Also here the queue can be safely expired\n\t\t * for budget timeout without wasting\n\t\t * guarantees\n\t\t */\n\t\treason = BFQQE_BUDGET_TIMEOUT;\n\telse if (bfqq->queued[0] == 0 && bfqq->queued[1] == 0)\n\t\t/*\n\t\t * The queue may not be empty upon timer expiration,\n\t\t * because we may not disable the timer when the\n\t\t * first request of the in-service queue arrives\n\t\t * during disk idling.\n\t\t */\n\t\treason = BFQQE_TOO_IDLE;\n\telse\n\t\tgoto schedule_dispatch;\n\n\tbfq_bfqq_expire(bfqd, bfqq, true, reason);\n\nschedule_dispatch:\n\tspin_unlock_irqrestore(&bfqd->lock, flags);\n\tbfq_schedule_dispatch(bfqd);", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12657", "cwe_id": "CWE-416" }, { "id": 788, "func": "ast_for_atom(struct compiling *c, const node *n)\n{\n /* atom: '(' [yield_expr|testlist_comp] ')' | '[' [listmaker] ']'\n | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+\n */\n node *ch = CHILD(n, 0);\n\n switch (TYPE(ch)) {\n case NAME: {\n /* All names start in Load context, but may later be\n changed. */\n PyObject *name = NEW_IDENTIFIER(ch);\n if (!name)\n return NULL;\n return Name(name, Load, LINENO(n), n->n_col_offset, c->c_arena);\n }\n case STRING: {\n PyObject *kind, *str = parsestrplus(c, n);\n const char *raw, *s = STR(CHILD(n, 0));\n int quote = Py_CHARMASK(*s);\n /* currently Python allows up to 2 string modifiers */\n char *ch, s_kind[3] = {0, 0, 0};\n ch = s_kind;\n raw = s;\n while (*raw && *raw != '\\'' && *raw != '\"') {\n *ch++ = *raw++;\n }\n kind = PyUnicode_FromString(s_kind);\n if (!kind) {\n return NULL;\n }\n if (!str) {\n#ifdef Py_USING_UNICODE\n if (PyErr_ExceptionMatches(PyExc_UnicodeError)){\n PyObject *type, *value, *tback, *errstr;\n PyErr_Fetch(&type, &value, &tback);\n errstr = PyObject_Str(value);\n if (errstr) {\n char *s = \"\";\n char buf[128];\n s = _PyUnicode_AsString(errstr);\n PyOS_snprintf(buf, sizeof(buf), \"(unicode error) %s\", s);\n ast_error(n, buf);\n Py_DECREF(errstr);\n } else {\n ast_error(n, \"(unicode error) unknown error\");\n }\n Py_DECREF(type);\n Py_DECREF(value);\n Py_XDECREF(tback);\n }\n#endif\n return NULL;\n }\n PyArena_AddPyObject(c->c_arena, str);\n return Str(str, kind, LINENO(n), n->n_col_offset, c->c_arena);\n }\n case NUMBER: {\n PyObject *pynum = parsenumber(c, STR(ch));\n if (!pynum)\n return NULL;\n\n PyArena_AddPyObject(c->c_arena, pynum);\n return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena);\n }\n case LPAR: /* some parenthesized expressions */\n ch = CHILD(n, 1);\n\n if (TYPE(ch) == RPAR)\n return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);\n\n if (TYPE(ch) == yield_expr)\n return ast_for_expr(c, ch);\n\n return ast_for_testlist_comp(c, ch);\n case LSQB: /* list (or list comprehension) */\n ch = CHILD(n, 1);\n\n if (TYPE(ch) == RSQB)\n return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);\n\n REQ(ch, listmaker);\n if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {\n asdl_seq *elts = seq_for_testlist(c, ch);\n if (!elts)\n return NULL;\n\n return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena);\n }\n else\n return ast_for_listcomp(c, ch);\n case LBRACE: {\n /* dictorsetmaker:\n * (test ':' test (comp_for | (',' test ':' test)* [','])) |\n * (test (comp_for | (',' test)* [',']))\n */\n int i, size;\n asdl_seq *keys, *values;\n\n ch = CHILD(n, 1);\n if (TYPE(ch) == RBRACE) {\n /* it's an empty dict */\n return Dict(NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena);\n } else if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {\n /* it's a simple set */\n asdl_seq *elts;\n size = (NCH(ch) + 1) / 2; /* +1 in case no trailing comma */\n elts = asdl_seq_new(size, c->c_arena);\n if (!elts)\n return NULL;\n for (i = 0; i < NCH(ch); i += 2) {\n expr_ty expression;\n expression = ast_for_expr(c, CHILD(ch, i));\n if (!expression)\n return NULL;\n asdl_seq_SET(elts, i / 2, expression);\n }\n return Set(elts, LINENO(n), n->n_col_offset, c->c_arena);\n } else if (TYPE(CHILD(ch, 1)) == comp_for) {\n /* it's a set comprehension */\n return ast_for_setcomp(c, ch);\n } else if (NCH(ch) > 3 && TYPE(CHILD(ch, 3)) == comp_for) {\n return ast_for_dictcomp(c, ch);\n } else {\n /* it's a dict */\n size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */\n keys = asdl_seq_new(size, c->c_arena);\n if (!keys)\n return NULL;\n\n values = asdl_seq_new(size, c->c_arena);\n if (!values)\n return NULL;\n\n for (i = 0; i < NCH(ch); i += 4) {\n expr_ty expression;\n\n expression = ast_for_expr(c, CHILD(ch, i));\n if (!expression)\n return NULL;\n\n asdl_seq_SET(keys, i / 4, expression);\n\n expression = ast_for_expr(c, CHILD(ch, i + 2));\n if (!expression)\n return NULL;\n\n asdl_seq_SET(values, i / 4, expression);\n }\n return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena);\n }\n }\n case BACKQUOTE: { /* repr */\n expr_ty expression;\n if (Py_Py3kWarningFlag &&\n !ast_warn(c, n, \"backquote not supported in 3.x; use repr()\"))\n return NULL;\n expression = ast_for_testlist(c, CHILD(n, 1));\n if (!expression)\n return NULL;\n\n return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena);\n }\n default:\n PyErr_Format(PyExc_SystemError, \"unhandled atom %d\", TYPE(ch));\n return NULL;\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 788, "func": "ast_for_atom(struct compiling *c, const node *n)\n{\n /* atom: '(' [yield_expr|testlist_comp] ')' | '[' [listmaker] ']'\n | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+\n */\n node *ch = CHILD(n, 0);\n\n switch (TYPE(ch)) {\n case NAME: {\n /* All names start in Load context, but may later be\n changed. */\n PyObject *name = NEW_IDENTIFIER(ch);\n if (!name)\n return NULL;\n return Name(name, Load, LINENO(n), n->n_col_offset, c->c_arena);\n }\n case STRING: {\n PyObject *kind, *str = parsestrplus(c, n);\n const char *raw, *s = STR(CHILD(n, 0));\n /* currently Python allows up to 2 string modifiers */\n char *ch, s_kind[3] = {0, 0, 0};\n ch = s_kind;\n raw = s;\n while (*raw && *raw != '\\'' && *raw != '\"') {\n *ch++ = *raw++;\n }\n kind = PyUnicode_FromString(s_kind);\n if (!kind) {\n return NULL;\n }\n if (!str) {\n#ifdef Py_USING_UNICODE\n if (PyErr_ExceptionMatches(PyExc_UnicodeError)){\n PyObject *type, *value, *tback, *errstr;\n PyErr_Fetch(&type, &value, &tback);\n errstr = PyObject_Str(value);\n if (errstr) {\n const char *s = \"\";\n char buf[128];\n s = _PyUnicode_AsString(errstr);\n PyOS_snprintf(buf, sizeof(buf), \"(unicode error) %s\", s);\n ast_error(n, buf);\n Py_DECREF(errstr);\n } else {\n ast_error(n, \"(unicode error) unknown error\");\n }\n Py_DECREF(type);\n Py_DECREF(value);\n Py_XDECREF(tback);\n }\n#endif\n return NULL;\n }\n PyArena_AddPyObject(c->c_arena, str);\n return Str(str, kind, LINENO(n), n->n_col_offset, c->c_arena);\n }\n case NUMBER: {\n PyObject *pynum = parsenumber(c, STR(ch));\n if (!pynum)\n return NULL;\n\n PyArena_AddPyObject(c->c_arena, pynum);\n return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena);\n }\n case LPAR: /* some parenthesized expressions */\n ch = CHILD(n, 1);\n\n if (TYPE(ch) == RPAR)\n return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);\n\n if (TYPE(ch) == yield_expr)\n return ast_for_expr(c, ch);\n\n return ast_for_testlist_comp(c, ch);\n case LSQB: /* list (or list comprehension) */\n ch = CHILD(n, 1);\n\n if (TYPE(ch) == RSQB)\n return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);\n\n REQ(ch, listmaker);\n if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {\n asdl_seq *elts = seq_for_testlist(c, ch);\n if (!elts)\n return NULL;\n\n return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena);\n }\n else\n return ast_for_listcomp(c, ch);\n case LBRACE: {\n /* dictorsetmaker:\n * (test ':' test (comp_for | (',' test ':' test)* [','])) |\n * (test (comp_for | (',' test)* [',']))\n */\n int i, size;\n asdl_seq *keys, *values;\n\n ch = CHILD(n, 1);\n if (TYPE(ch) == RBRACE) {\n /* it's an empty dict */\n return Dict(NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena);\n } else if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {\n /* it's a simple set */\n asdl_seq *elts;\n size = (NCH(ch) + 1) / 2; /* +1 in case no trailing comma */\n elts = asdl_seq_new(size, c->c_arena);\n if (!elts)\n return NULL;\n for (i = 0; i < NCH(ch); i += 2) {\n expr_ty expression;\n expression = ast_for_expr(c, CHILD(ch, i));\n if (!expression)\n return NULL;\n asdl_seq_SET(elts, i / 2, expression);\n }\n return Set(elts, LINENO(n), n->n_col_offset, c->c_arena);\n } else if (TYPE(CHILD(ch, 1)) == comp_for) {\n /* it's a set comprehension */\n return ast_for_setcomp(c, ch);\n } else if (NCH(ch) > 3 && TYPE(CHILD(ch, 3)) == comp_for) {\n return ast_for_dictcomp(c, ch);\n } else {\n /* it's a dict */\n size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */\n keys = asdl_seq_new(size, c->c_arena);\n if (!keys)\n return NULL;\n\n values = asdl_seq_new(size, c->c_arena);\n if (!values)\n return NULL;\n\n for (i = 0; i < NCH(ch); i += 4) {\n expr_ty expression;\n\n expression = ast_for_expr(c, CHILD(ch, i));\n if (!expression)\n return NULL;\n\n asdl_seq_SET(keys, i / 4, expression);\n\n expression = ast_for_expr(c, CHILD(ch, i + 2));\n if (!expression)\n return NULL;\n\n asdl_seq_SET(values, i / 4, expression);\n }\n return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena);\n }\n }\n case BACKQUOTE: { /* repr */\n expr_ty expression;\n if (Py_Py3kWarningFlag &&\n !ast_warn(c, n, \"backquote not supported in 3.x; use repr()\"))\n return NULL;\n expression = ast_for_testlist(c, CHILD(n, 1));\n if (!expression)\n return NULL;\n\n return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena);\n }\n default:\n PyErr_Format(PyExc_SystemError, \"unhandled atom %d\", TYPE(ch));\n return NULL;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2236, "func": "static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,\n\t\t\t int mode)\n{\n\tstruct gfs2_inode *ip = GFS2_I(inode);\n\tstruct buffer_head *dibh;\n\tint error;\n\tu64 start = offset >> PAGE_CACHE_SHIFT;\n\tunsigned int start_offset = offset & ~PAGE_CACHE_MASK;\n\tu64 end = (offset + len - 1) >> PAGE_CACHE_SHIFT;\n\tpgoff_t curr;\n\tstruct page *page;\n\tunsigned int end_offset = (offset + len) & ~PAGE_CACHE_MASK;\n\tunsigned int from, to;\n\n\tif (!end_offset)\n\t\tend_offset = PAGE_CACHE_SIZE;\n\n\terror = gfs2_meta_inode_buffer(ip, &dibh);\n\tif (unlikely(error))\n\t\tgoto out;\n\n\tgfs2_trans_add_bh(ip->i_gl, dibh, 1);\n\n\tif (gfs2_is_stuffed(ip)) {\n\t\terror = gfs2_unstuff_dinode(ip, NULL);\n\t\tif (unlikely(error))\n\t\t\tgoto out;\n\t}\n\n\tcurr = start;\n\toffset = start << PAGE_CACHE_SHIFT;\n\tfrom = start_offset;\n\tto = PAGE_CACHE_SIZE;\n\twhile (curr <= end) {\n\t\tpage = grab_cache_page_write_begin(inode->i_mapping, curr,\n\t\t\t\t\t\t AOP_FLAG_NOFS);\n\t\tif (unlikely(!page)) {\n\t\t\terror = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\n\t\tif (curr == end)\n\t\t\tto = end_offset;\n\t\terror = write_empty_blocks(page, from, to, mode);\n\t\tif (!error && offset + to > inode->i_size &&\n\t\t !(mode & FALLOC_FL_KEEP_SIZE)) {\n\t\t\ti_size_write(inode, offset + to);\n\t\t}\n\t\tunlock_page(page);\n\t\tpage_cache_release(page);\n\t\tif (error)\n\t\t\tgoto out;\n\t\tcurr++;\n\t\toffset += PAGE_CACHE_SIZE;\n\t\tfrom = 0;\n\t}\n\n\tmark_inode_dirty(inode);\n\n\tbrelse(dibh);\n\nout:\n\treturn error;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-4098", "cwe_id": "CWE-119" }, { "id": 2236, "func": "static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,\n\t\t\t int mode)\n{\n\tstruct gfs2_inode *ip = GFS2_I(inode);\n\tstruct buffer_head *dibh;\n\tint error;\n\tunsigned int nr_blks;\n\tsector_t lblock = offset >> inode->i_blkbits;\n\n\terror = gfs2_meta_inode_buffer(ip, &dibh);\n\tif (unlikely(error))\n\t\treturn error;\n\n\tgfs2_trans_add_bh(ip->i_gl, dibh, 1);\n\n\tif (gfs2_is_stuffed(ip)) {\n\t\terror = gfs2_unstuff_dinode(ip, NULL);\n\t\tif (unlikely(error))\n\t\t\tgoto out;\n\t}\n\n\twhile (len) {\n\t\tstruct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };\n\t\tbh_map.b_size = len;\n\t\tset_buffer_zeronew(&bh_map);\n\n\t\terror = gfs2_block_map(inode, lblock, &bh_map, 1);\n\t\tif (unlikely(error))\n\t\t\tgoto out;\n\t\tlen -= bh_map.b_size;\n\t\tnr_blks = bh_map.b_size >> inode->i_blkbits;\n\t\tlblock += nr_blks;\n\t\tif (!buffer_new(&bh_map))\n\t\t\tcontinue;\n\t\tif (unlikely(!buffer_zeronew(&bh_map))) {\n\t\t\terror = -EIO;\n\t\t\tgoto out;\n\t\t}\n\t}\n\tif (offset + len > inode->i_size && !(mode & FALLOC_FL_KEEP_SIZE))\n\t\ti_size_write(inode, offset + len);\n\n\tmark_inode_dirty(inode);\n\nout:\n\tbrelse(dibh);\n\treturn error;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-4098", "cwe_id": "CWE-119" }, { "id": 2707, "func": "MONGO_EXPORT int bson_append_string_n( bson *b, const char *name, const char *value, int len ) {\n return bson_append_string_base( b, name, value, len, BSON_STRING );\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 2707, "func": "MONGO_EXPORT int bson_append_string_n( bson *b, const char *name, const char *value, size_t len ) {\n return bson_append_string_base( b, name, value, len, BSON_STRING );\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 2283, "func": "check_entry_size_and_hooks(struct ipt_entry *e,\n\t\t\t struct xt_table_info *newinfo,\n\t\t\t const unsigned char *base,\n\t\t\t const unsigned char *limit,\n\t\t\t const unsigned int *hook_entries,\n\t\t\t const unsigned int *underflows,\n\t\t\t unsigned int valid_hooks)\n{\n\tunsigned int h;\n\tint err;\n\n\tif ((unsigned long)e % __alignof__(struct ipt_entry) != 0 ||\n\t (unsigned char *)e + sizeof(struct ipt_entry) >= limit) {\n\t\tduprintf(\"Bad offset %p\\n\", e);\n\t\treturn -EINVAL;\n\t}\n\n\tif (e->next_offset\n\t < sizeof(struct ipt_entry) + sizeof(struct xt_entry_target)) {\n\t\tduprintf(\"checking: element %p size %u\\n\",\n\t\t\t e, e->next_offset);\n\t\treturn -EINVAL;\n\t}\n\n\terr = check_entry(e);\n\tif (err)\n\t\treturn err;\n\n\t/* Check hooks & underflows */\n\tfor (h = 0; h < NF_INET_NUMHOOKS; h++) {\n\t\tif (!(valid_hooks & (1 << h)))\n\t\t\tcontinue;\n\t\tif ((unsigned char *)e - base == hook_entries[h])\n\t\t\tnewinfo->hook_entry[h] = hook_entries[h];\n\t\tif ((unsigned char *)e - base == underflows[h]) {\n\t\t\tif (!check_underflow(e)) {\n\t\t\t\tpr_err(\"Underflows must be unconditional and \"\n\t\t\t\t \"use the STANDARD target with \"\n\t\t\t\t \"ACCEPT/DROP\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\tnewinfo->underflow[h] = underflows[h];\n\t\t}\n\t}\n\n\t/* Clear counters and comefrom */\n\te->counters = ((struct xt_counters) { 0, 0 });\n\te->comefrom = 0;\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-4998", "cwe_id": "CWE-119" }, { "id": 2283, "func": "check_entry_size_and_hooks(struct ipt_entry *e,\n\t\t\t struct xt_table_info *newinfo,\n\t\t\t const unsigned char *base,\n\t\t\t const unsigned char *limit,\n\t\t\t const unsigned int *hook_entries,\n\t\t\t const unsigned int *underflows,\n\t\t\t unsigned int valid_hooks)\n{\n\tunsigned int h;\n\tint err;\n\n\tif ((unsigned long)e % __alignof__(struct ipt_entry) != 0 ||\n\t (unsigned char *)e + sizeof(struct ipt_entry) >= limit ||\n\t (unsigned char *)e + e->next_offset > limit) {\n\t\tduprintf(\"Bad offset %p\\n\", e);\n\t\treturn -EINVAL;\n\t}\n\n\tif (e->next_offset\n\t < sizeof(struct ipt_entry) + sizeof(struct xt_entry_target)) {\n\t\tduprintf(\"checking: element %p size %u\\n\",\n\t\t\t e, e->next_offset);\n\t\treturn -EINVAL;\n\t}\n\n\terr = check_entry(e);\n\tif (err)\n\t\treturn err;\n\n\t/* Check hooks & underflows */\n\tfor (h = 0; h < NF_INET_NUMHOOKS; h++) {\n\t\tif (!(valid_hooks & (1 << h)))\n\t\t\tcontinue;\n\t\tif ((unsigned char *)e - base == hook_entries[h])\n\t\t\tnewinfo->hook_entry[h] = hook_entries[h];\n\t\tif ((unsigned char *)e - base == underflows[h]) {\n\t\t\tif (!check_underflow(e)) {\n\t\t\t\tpr_err(\"Underflows must be unconditional and \"\n\t\t\t\t \"use the STANDARD target with \"\n\t\t\t\t \"ACCEPT/DROP\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\tnewinfo->underflow[h] = underflows[h];\n\t\t}\n\t}\n\n\t/* Clear counters and comefrom */\n\te->counters = ((struct xt_counters) { 0, 0 });\n\te->comefrom = 0;\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-4998", "cwe_id": "CWE-119" }, { "id": 1688, "func": "R_API bool r_io_bank_map_add_top(RIO *io, const ut32 bankid, const ut32 mapid) {\n\tRIOBank *bank = r_io_bank_get (io, bankid);\n\tRIOMap *map = r_io_map_get (io, mapid);\n\tr_return_val_if_fail (io && bank && map, false);\n\tRIOMapRef *mapref = _mapref_from_map (map);\n\tif (!mapref) {\n\t\treturn false;\n\t}\n\tRIOSubMap *sm = r_io_submap_new (io, mapref);\n\tif (!sm) {\n\t\tfree (mapref);\n\t\treturn false;\n\t}\n\tRRBNode *entry = _find_entry_submap_node (bank, sm);\n\tif (!entry) {\n\t\t// no intersection with any submap, so just insert\n\t\tif (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\tfree (sm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tr_list_append (bank->maprefs, mapref);\n\t\treturn true;\n\t}\n\tbank->last_used = NULL;\n\tRIOSubMap *bd = (RIOSubMap *)entry->data;\n\tif (r_io_submap_to (bd) == r_io_submap_to (sm) &&\n\t\tr_io_submap_from (bd) >= r_io_submap_from (sm)) {\n\t\t// _find_entry_submap_node guarantees, that there is no submap\n\t\t// prior to bd in the range of sm, so instead of deleting and inserting\n\t\t// we can just memcpy\n\t\tmemcpy (bd, sm, sizeof (RIOSubMap));\n\t\tfree (sm);\n\t\tr_list_append (bank->maprefs, mapref);\n\t\treturn true;\n\t}\n\tif (r_io_submap_from (bd) < r_io_submap_from (sm) &&\n\t\tr_io_submap_to (sm) < r_io_submap_to (bd)) {\n\t\t// split bd into 2 maps => bd and bdsm\n\t\tRIOSubMap *bdsm = R_NEWCOPY (RIOSubMap, bd);\n\t\tif (!bdsm) {\n\t\t\tfree (sm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tr_io_submap_set_from (bdsm, r_io_submap_to (sm) + 1);\n\t\tr_io_submap_set_to (bd, r_io_submap_from (sm) - 1);\n\t\t// TODO: insert and check return value, before adjusting sm size\n\t\tif (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\tfree (sm);\n\t\t\tfree (bdsm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tif (!r_crbtree_insert (bank->submaps, bdsm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\tr_crbtree_delete (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\tfree (sm);\n\t\t\tfree (bdsm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tr_list_append (bank->maprefs, mapref);\n\t\treturn true;\n\t}\n\n\t// guaranteed intersection\n\tif (r_io_submap_from (bd) < r_io_submap_from (sm)) {\n\t\tr_io_submap_set_to (bd, r_io_submap_from (sm) - 1);\n\t\tentry = r_rbnode_next (entry);\n\t}\n\twhile (entry && r_io_submap_to (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) {\n\t\t//delete all submaps that are completly included in sm\n\t\tRRBNode *next = r_rbnode_next (entry);\n\t\t// this can be optimized, there is no need to do search here\n\t\tr_crbtree_delete (bank->submaps, entry->data, _find_sm_by_from_vaddr_cb, NULL);\n\t\tentry = next;\n\t}\n\tif (entry && r_io_submap_from (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) {\n\t\tbd = (RIOSubMap *)entry->data;\n\t\tr_io_submap_set_from (bd, r_io_submap_to (sm) + 1);\n\t}\n\tif (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\tfree (sm);\n\t\tfree (mapref);\n\t\treturn false;\n\t}\n\tr_list_append (bank->maprefs, mapref);\n\treturn true;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-0139", "cwe_id": "CWE-416" }, { "id": 1688, "func": "R_API bool r_io_bank_map_add_top(RIO *io, const ut32 bankid, const ut32 mapid) {\n\tRIOBank *bank = r_io_bank_get (io, bankid);\n\tRIOMap *map = r_io_map_get (io, mapid);\n\tr_return_val_if_fail (io && bank && map, false);\n\tRIOMapRef *mapref = _mapref_from_map (map);\n\tif (!mapref) {\n\t\treturn false;\n\t}\n\tRIOSubMap *sm = r_io_submap_new (io, mapref);\n\tif (!sm) {\n\t\tfree (mapref);\n\t\treturn false;\n\t}\n\tRRBNode *entry = _find_entry_submap_node (bank, sm);\n\tif (!entry) {\n\t\t// no intersection with any submap, so just insert\n\t\tif (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\tfree (sm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tr_list_append (bank->maprefs, mapref);\n\t\treturn true;\n\t}\n\tbank->last_used = NULL;\n\tRIOSubMap *bd = (RIOSubMap *)entry->data;\n\tif (r_io_submap_to (bd) == r_io_submap_to (sm) &&\n\t\tr_io_submap_from (bd) >= r_io_submap_from (sm)) {\n\t\t// _find_entry_submap_node guarantees, that there is no submap\n\t\t// prior to bd in the range of sm, so instead of deleting and inserting\n\t\t// we can just memcpy\n\t\tmemcpy (bd, sm, sizeof (RIOSubMap));\n\t\tfree (sm);\n\t\tr_list_append (bank->maprefs, mapref);\n\t\treturn true;\n\t}\n\tif (r_io_submap_from (bd) < r_io_submap_from (sm) &&\n\t\tr_io_submap_to (sm) < r_io_submap_to (bd)) {\n\t\t// split bd into 2 maps => bd and bdsm\n\t\tRIOSubMap *bdsm = R_NEWCOPY (RIOSubMap, bd);\n\t\tif (!bdsm) {\n\t\t\tfree (sm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tr_io_submap_set_from (bdsm, r_io_submap_to (sm) + 1);\n\t\tr_io_submap_set_to (bd, r_io_submap_from (sm) - 1);\n\t\t// TODO: insert and check return value, before adjusting sm size\n\t\tif (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\tfree (sm);\n\t\t\tfree (bdsm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tif (!r_crbtree_insert (bank->submaps, bdsm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\t\tr_crbtree_delete (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL);\n\t\t\tfree (sm);\n\t\t\tfree (bdsm);\n\t\t\tfree (mapref);\n\t\t\treturn false;\n\t\t}\n\t\tr_list_append (bank->maprefs, mapref);\n\t\treturn true;\n\t}\n\n\t// guaranteed intersection\n\tif (r_io_submap_from (bd) < r_io_submap_from (sm)) {\n\t\tr_io_submap_set_to (bd, r_io_submap_from (sm) - 1);\n\t\tentry = r_rbnode_next (entry);\n\t}\n\twhile (entry && r_io_submap_to (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) {\n\t\t//delete all submaps that are completly included in sm\n\t\tRRBNode *next = r_rbnode_next (entry);\n\t\t// this can be optimized, there is no need to do search here\n\t\tbool a = r_crbtree_delete (bank->submaps, entry->data, _find_sm_by_from_vaddr_cb, NULL);\n\t\tif (!a) {\n\t\t\tbreak;\n\t\t}\n\t\tentry = next;\n\t}\n\tif (entry && r_io_submap_from (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) {\n\t\tbd = (RIOSubMap *)entry->data;\n\t\tr_io_submap_set_from (bd, r_io_submap_to (sm) + 1);\n\t}\n\tif (!r_crbtree_insert (bank->submaps, sm, _find_sm_by_from_vaddr_cb, NULL)) {\n\t\tfree (sm);\n\t\tfree (mapref);\n\t\treturn false;\n\t}\n\tr_list_append (bank->maprefs, mapref);\n\treturn true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-0139", "cwe_id": "CWE-416" }, { "id": 3271, "func": "u32 gf_bs_read_ue_log_idx3(GF_BitStream *bs, const char *fname, s32 idx1, s32 idx2, s32 idx3)\n{\n\tu32 val=0, code;\n\ts32 nb_lead = -1;\n\tu32 bits = 0;\n\tfor (code=0; !code; nb_lead++) {\n\t\tif (nb_lead>=32) {\n\t\t\t//gf_bs_read_int keeps returning 0 on EOS, so if no more bits available, rbsp was truncated otherwise code is broken in rbsp)\n\t\t\t//we only test once nb_lead>=32 to avoid testing at each bit read\n\t\t\tif (!gf_bs_available(bs)) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CODING, (\"[Core] exp-golomb read failed, not enough bits in bitstream !\\n\"));\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CODING, (\"[Core] corrupted exp-golomb code, %d leading zeros, max 31 allowed !\\n\", nb_lead));\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\n\t\tcode = gf_bs_read_int(bs, 1);\n\t\tbits++;\n\t}\n\n\tif (nb_lead) {\n\t\tval = gf_bs_read_int(bs, nb_lead);\n\t\tval += (1 << nb_lead) - 1;\n\t\tbits += nb_lead;\n\t}\n\n\tif (fname) {\n\t\tgf_bs_log_idx(bs, bits, fname, val, idx1, idx2, idx3);\n\t}\n\treturn val;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-40564", "cwe_id": "CWE-476" }, { "id": 3271, "func": "u32 gf_bs_read_ue_log_idx3(GF_BitStream *bs, const char *fname, s32 idx1, s32 idx2, s32 idx3)\n{\n\tu32 val=0, code;\n\ts32 nb_lead = -1;\n\tu32 bits = 0;\n\tfor (code=0; !code; nb_lead++) {\n\t\tif (nb_lead>=32) {\n\t\t\t//gf_bs_read_int keeps returning 0 on EOS, so if no more bits available, rbsp was truncated otherwise code is broken in rbsp)\n\t\t\t//we only test once nb_lead>=32 to avoid testing at each bit read\n\t\t\tif (!gf_bs_available(bs)) {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CODING, (\"[Core] exp-golomb read failed, not enough bits in bitstream !\\n\"));\n\t\t\t} else {\n\t\t\t\tGF_LOG(GF_LOG_ERROR, GF_LOG_CODING, (\"[Core] corrupted exp-golomb code, %d leading zeros, max 31 allowed !\\n\", nb_lead));\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\n\t\tcode = gf_bs_read_int(bs, 1);\n\t\tbits++;\n\t}\n\n\tif (nb_lead) {\n\t\tu32 leads=1;\n\t\tval = gf_bs_read_int(bs, nb_lead);\n\t\tleads <<= nb_lead;\n\t\tleads -= 1;\n\t\tval += leads;\n//\t\tval += (1 << nb_lead) - 1;\n\t\tbits += nb_lead;\n\t}\n\n\tif (fname) {\n\t\tgf_bs_log_idx(bs, bits, fname, val, idx1, idx2, idx3);\n\t}\n\treturn val;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-40564", "cwe_id": "CWE-476" }, { "id": 1348, "func": "int input_set_keycode(struct input_dev *dev,\n\t\t const struct input_keymap_entry *ke)\n{\n\tunsigned long flags;\n\tunsigned int old_keycode;\n\tint retval;\n\n\tif (ke->keycode > KEY_MAX)\n\t\treturn -EINVAL;\n\n\tspin_lock_irqsave(&dev->event_lock, flags);\n\n\tretval = dev->setkeycode(dev, ke, &old_keycode);\n\tif (retval)\n\t\tgoto out;\n\n\t/* Make sure KEY_RESERVED did not get enabled. */\n\t__clear_bit(KEY_RESERVED, dev->keybit);\n\n\t/*\n\t * Simulate keyup event if keycode is not present\n\t * in the keymap anymore\n\t */\n\tif (test_bit(EV_KEY, dev->evbit) &&\n\t !is_event_supported(old_keycode, dev->keybit, KEY_MAX) &&\n\t __test_and_clear_bit(old_keycode, dev->key)) {\n\t\tstruct input_value vals[] = {\n\t\t\t{ EV_KEY, old_keycode, 0 },\n\t\t\tinput_value_sync\n\t\t};\n\n\t\tinput_pass_values(dev, vals, ARRAY_SIZE(vals));\n\t}\n\n out:\n\tspin_unlock_irqrestore(&dev->event_lock, flags);\n\n\treturn retval;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-20636", "cwe_id": "CWE-787" }, { "id": 1348, "func": "int input_set_keycode(struct input_dev *dev,\n\t\t const struct input_keymap_entry *ke)\n{\n\tunsigned long flags;\n\tunsigned int old_keycode;\n\tint retval;\n\n\tif (ke->keycode > KEY_MAX)\n\t\treturn -EINVAL;\n\n\tspin_lock_irqsave(&dev->event_lock, flags);\n\n\tretval = dev->setkeycode(dev, ke, &old_keycode);\n\tif (retval)\n\t\tgoto out;\n\n\t/* Make sure KEY_RESERVED did not get enabled. */\n\t__clear_bit(KEY_RESERVED, dev->keybit);\n\n\t/*\n\t * Simulate keyup event if keycode is not present\n\t * in the keymap anymore\n\t */\n\tif (old_keycode > KEY_MAX) {\n\t\tdev_warn(dev->dev.parent ?: &dev->dev,\n\t\t\t \"%s: got too big old keycode %#x\\n\",\n\t\t\t __func__, old_keycode);\n\t} else if (test_bit(EV_KEY, dev->evbit) &&\n\t\t !is_event_supported(old_keycode, dev->keybit, KEY_MAX) &&\n\t\t __test_and_clear_bit(old_keycode, dev->key)) {\n\t\tstruct input_value vals[] = {\n\t\t\t{ EV_KEY, old_keycode, 0 },\n\t\t\tinput_value_sync\n\t\t};\n\n\t\tinput_pass_values(dev, vals, ARRAY_SIZE(vals));\n\t}\n\n out:\n\tspin_unlock_irqrestore(&dev->event_lock, flags);\n\n\treturn retval;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-20636", "cwe_id": "CWE-787" }, { "id": 2457, "func": "HexOutStream::overrun(int itemSize, int nItems) {\n if (itemSize > bufSize)\n throw Exception(\"HexOutStream overrun: max itemSize exceeded\");\n\n writeBuffer();\n\n if (itemSize * nItems > end - ptr)\n nItems = (end - ptr) / itemSize;\n\n return nItems;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 2457, "func": "HexOutStream::overrun(size_t itemSize, size_t nItems) {\n if (itemSize > bufSize)\n throw Exception(\"HexOutStream overrun: max itemSize exceeded\");\n\n writeBuffer();\n\n if (itemSize * nItems > (size_t)(end - ptr))\n nItems = (end - ptr) / itemSize;\n\n return nItems;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 99, "func": "int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,\n\t\t\t unsigned char *out, size_t *out_len)\n{\n\tunsigned char *op;\n\tconst unsigned char *ip;\n\tsize_t t, next;\n\tsize_t state = 0;\n\tconst unsigned char *m_pos;\n\tconst unsigned char * const ip_end = in + in_len;\n\tunsigned char * const op_end = out + *out_len;\n\n\top = out;\n\tip = in;\n\n\tif (unlikely(in_len < 3))\n\t\tgoto input_overrun;\n\tif (*ip > 17) {\n\t\tt = *ip++ - 17;\n\t\tif (t < 4) {\n\t\t\tnext = t;\n\t\t\tgoto match_next;\n\t\t}\n\t\tgoto copy_literal_run;\n\t}\n\n\tfor (;;) {\n\t\tt = *ip++;\n\t\tif (t < 16) {\n\t\t\tif (likely(state == 0)) {\n\t\t\t\tif (unlikely(t == 0)) {\n\t\t\t\t\twhile (unlikely(*ip == 0)) {\n\t\t\t\t\t\tt += 255;\n\t\t\t\t\t\tip++;\n\t\t\t\t\t\tNEED_IP(1);\n\t\t\t\t\t}\n\t\t\t\t\tt += 15 + *ip++;\n\t\t\t\t}\n\t\t\t\tt += 3;\ncopy_literal_run:\n#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)\n\t\t\t\tif (likely(HAVE_IP(t + 15) && HAVE_OP(t + 15))) {\n\t\t\t\t\tconst unsigned char *ie = ip + t;\n\t\t\t\t\tunsigned char *oe = op + t;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tCOPY8(op, ip);\n\t\t\t\t\t\top += 8;\n\t\t\t\t\t\tip += 8;\n\t\t\t\t\t\tCOPY8(op, ip);\n\t\t\t\t\t\top += 8;\n\t\t\t\t\t\tip += 8;\n\t\t\t\t\t} while (ip < ie);\n\t\t\t\t\tip = ie;\n\t\t\t\t\top = oe;\n\t\t\t\t} else\n#endif\n\t\t\t\t{\n\t\t\t\t\tNEED_OP(t);\n\t\t\t\t\tNEED_IP(t + 3);\n\t\t\t\t\tdo {\n\t\t\t\t\t\t*op++ = *ip++;\n\t\t\t\t\t} while (--t > 0);\n\t\t\t\t}\n\t\t\t\tstate = 4;\n\t\t\t\tcontinue;\n\t\t\t} else if (state != 4) {\n\t\t\t\tnext = t & 3;\n\t\t\t\tm_pos = op - 1;\n\t\t\t\tm_pos -= t >> 2;\n\t\t\t\tm_pos -= *ip++ << 2;\n\t\t\t\tTEST_LB(m_pos);\n\t\t\t\tNEED_OP(2);\n\t\t\t\top[0] = m_pos[0];\n\t\t\t\top[1] = m_pos[1];\n\t\t\t\top += 2;\n\t\t\t\tgoto match_next;\n\t\t\t} else {\n\t\t\t\tnext = t & 3;\n\t\t\t\tm_pos = op - (1 + M2_MAX_OFFSET);\n\t\t\t\tm_pos -= t >> 2;\n\t\t\t\tm_pos -= *ip++ << 2;\n\t\t\t\tt = 3;\n\t\t\t}\n\t\t} else if (t >= 64) {\n\t\t\tnext = t & 3;\n\t\t\tm_pos = op - 1;\n\t\t\tm_pos -= (t >> 2) & 7;\n\t\t\tm_pos -= *ip++ << 3;\n\t\t\tt = (t >> 5) - 1 + (3 - 1);\n\t\t} else if (t >= 32) {\n\t\t\tt = (t & 31) + (3 - 1);\n\t\t\tif (unlikely(t == 2)) {\n\t\t\t\twhile (unlikely(*ip == 0)) {\n\t\t\t\t\tt += 255;\n\t\t\t\t\tip++;\n\t\t\t\t\tNEED_IP(1);\n\t\t\t\t}\n\t\t\t\tt += 31 + *ip++;\n\t\t\t\tNEED_IP(2);\n\t\t\t}\n\t\t\tm_pos = op - 1;\n\t\t\tnext = get_unaligned_le16(ip);\n\t\t\tip += 2;\n\t\t\tm_pos -= next >> 2;\n\t\t\tnext &= 3;\n\t\t} else {\n\t\t\tm_pos = op;\n\t\t\tm_pos -= (t & 8) << 11;\n\t\t\tt = (t & 7) + (3 - 1);\n\t\t\tif (unlikely(t == 2)) {\n\t\t\t\twhile (unlikely(*ip == 0)) {\n\t\t\t\t\tt += 255;\n\t\t\t\t\tip++;\n\t\t\t\t\tNEED_IP(1);\n\t\t\t\t}\n\t\t\t\tt += 7 + *ip++;\n\t\t\t\tNEED_IP(2);\n\t\t\t}\n\t\t\tnext = get_unaligned_le16(ip);\n\t\t\tip += 2;\n\t\t\tm_pos -= next >> 2;\n\t\t\tnext &= 3;\n\t\t\tif (m_pos == op)\n\t\t\t\tgoto eof_found;\n\t\t\tm_pos -= 0x4000;\n\t\t}\n\t\tTEST_LB(m_pos);\n#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)\n\t\tif (op - m_pos >= 8) {\n\t\t\tunsigned char *oe = op + t;\n\t\t\tif (likely(HAVE_OP(t + 15))) {\n\t\t\t\tdo {\n\t\t\t\t\tCOPY8(op, m_pos);\n\t\t\t\t\top += 8;\n\t\t\t\t\tm_pos += 8;\n\t\t\t\t\tCOPY8(op, m_pos);\n\t\t\t\t\top += 8;\n\t\t\t\t\tm_pos += 8;\n\t\t\t\t} while (op < oe);\n\t\t\t\top = oe;\n\t\t\t\tif (HAVE_IP(6)) {\n\t\t\t\t\tstate = next;\n\t\t\t\t\tCOPY4(op, ip);\n\t\t\t\t\top += next;\n\t\t\t\t\tip += next;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tNEED_OP(t);\n\t\t\t\tdo {\n\t\t\t\t\t*op++ = *m_pos++;\n\t\t\t\t} while (op < oe);\n\t\t\t}\n\t\t} else\n#endif\n\t\t{\n\t\t\tunsigned char *oe = op + t;\n\t\t\tNEED_OP(t);\n\t\t\top[0] = m_pos[0];\n\t\t\top[1] = m_pos[1];\n\t\t\top += 2;\n\t\t\tm_pos += 2;\n\t\t\tdo {\n\t\t\t\t*op++ = *m_pos++;\n\t\t\t} while (op < oe);\n\t\t}\nmatch_next:\n\t\tstate = next;\n\t\tt = next;\n#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)\n\t\tif (likely(HAVE_IP(6) && HAVE_OP(4))) {\n\t\t\tCOPY4(op, ip);\n\t\t\top += t;\n\t\t\tip += t;\n\t\t} else\n#endif\n\t\t{\n\t\t\tNEED_IP(t + 3);\n\t\t\tNEED_OP(t);\n\t\t\twhile (t > 0) {\n\t\t\t\t*op++ = *ip++;\n\t\t\t\tt--;\n\t\t\t}\n\t\t}\n\t}\n\neof_found:\n\t*out_len = op - out;\n\treturn (t != 3 ? LZO_E_ERROR :\n\t\tip == ip_end ? LZO_E_OK :\n\t\tip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN);\n\ninput_overrun:\n\t*out_len = op - out;\n\treturn LZO_E_INPUT_OVERRUN;\n\noutput_overrun:\n\t*out_len = op - out;\n\treturn LZO_E_OUTPUT_OVERRUN;\n\nlookbehind_overrun:\n\t*out_len = op - out;\n\treturn LZO_E_LOOKBEHIND_OVERRUN;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-4608", "cwe_id": "CWE-190" }, { "id": 99, "func": "int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,\n\t\t\t unsigned char *out, size_t *out_len)\n{\n\tunsigned char *op;\n\tconst unsigned char *ip;\n\tsize_t t, next;\n\tsize_t state = 0;\n\tconst unsigned char *m_pos;\n\tconst unsigned char * const ip_end = in + in_len;\n\tunsigned char * const op_end = out + *out_len;\n\n\top = out;\n\tip = in;\n\n\tif (unlikely(in_len < 3))\n\t\tgoto input_overrun;\n\tif (*ip > 17) {\n\t\tt = *ip++ - 17;\n\t\tif (t < 4) {\n\t\t\tnext = t;\n\t\t\tgoto match_next;\n\t\t}\n\t\tgoto copy_literal_run;\n\t}\n\n\tfor (;;) {\n\t\tt = *ip++;\n\t\tif (t < 16) {\n\t\t\tif (likely(state == 0)) {\n\t\t\t\tif (unlikely(t == 0)) {\n\t\t\t\t\twhile (unlikely(*ip == 0)) {\n\t\t\t\t\t\tt += 255;\n\t\t\t\t\t\tip++;\n\t\t\t\t\t\tNEED_IP(1, 0);\n\t\t\t\t\t}\n\t\t\t\t\tt += 15 + *ip++;\n\t\t\t\t}\n\t\t\t\tt += 3;\ncopy_literal_run:\n#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)\n\t\t\t\tif (likely(HAVE_IP(t, 15) && HAVE_OP(t, 15))) {\n\t\t\t\t\tconst unsigned char *ie = ip + t;\n\t\t\t\t\tunsigned char *oe = op + t;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tCOPY8(op, ip);\n\t\t\t\t\t\top += 8;\n\t\t\t\t\t\tip += 8;\n\t\t\t\t\t\tCOPY8(op, ip);\n\t\t\t\t\t\top += 8;\n\t\t\t\t\t\tip += 8;\n\t\t\t\t\t} while (ip < ie);\n\t\t\t\t\tip = ie;\n\t\t\t\t\top = oe;\n\t\t\t\t} else\n#endif\n\t\t\t\t{\n\t\t\t\t\tNEED_OP(t, 0);\n\t\t\t\t\tNEED_IP(t, 3);\n\t\t\t\t\tdo {\n\t\t\t\t\t\t*op++ = *ip++;\n\t\t\t\t\t} while (--t > 0);\n\t\t\t\t}\n\t\t\t\tstate = 4;\n\t\t\t\tcontinue;\n\t\t\t} else if (state != 4) {\n\t\t\t\tnext = t & 3;\n\t\t\t\tm_pos = op - 1;\n\t\t\t\tm_pos -= t >> 2;\n\t\t\t\tm_pos -= *ip++ << 2;\n\t\t\t\tTEST_LB(m_pos);\n\t\t\t\tNEED_OP(2, 0);\n\t\t\t\top[0] = m_pos[0];\n\t\t\t\top[1] = m_pos[1];\n\t\t\t\top += 2;\n\t\t\t\tgoto match_next;\n\t\t\t} else {\n\t\t\t\tnext = t & 3;\n\t\t\t\tm_pos = op - (1 + M2_MAX_OFFSET);\n\t\t\t\tm_pos -= t >> 2;\n\t\t\t\tm_pos -= *ip++ << 2;\n\t\t\t\tt = 3;\n\t\t\t}\n\t\t} else if (t >= 64) {\n\t\t\tnext = t & 3;\n\t\t\tm_pos = op - 1;\n\t\t\tm_pos -= (t >> 2) & 7;\n\t\t\tm_pos -= *ip++ << 3;\n\t\t\tt = (t >> 5) - 1 + (3 - 1);\n\t\t} else if (t >= 32) {\n\t\t\tt = (t & 31) + (3 - 1);\n\t\t\tif (unlikely(t == 2)) {\n\t\t\t\twhile (unlikely(*ip == 0)) {\n\t\t\t\t\tt += 255;\n\t\t\t\t\tip++;\n\t\t\t\t\tNEED_IP(1, 0);\n\t\t\t\t}\n\t\t\t\tt += 31 + *ip++;\n\t\t\t\tNEED_IP(2, 0);\n\t\t\t}\n\t\t\tm_pos = op - 1;\n\t\t\tnext = get_unaligned_le16(ip);\n\t\t\tip += 2;\n\t\t\tm_pos -= next >> 2;\n\t\t\tnext &= 3;\n\t\t} else {\n\t\t\tm_pos = op;\n\t\t\tm_pos -= (t & 8) << 11;\n\t\t\tt = (t & 7) + (3 - 1);\n\t\t\tif (unlikely(t == 2)) {\n\t\t\t\twhile (unlikely(*ip == 0)) {\n\t\t\t\t\tt += 255;\n\t\t\t\t\tip++;\n\t\t\t\t\tNEED_IP(1, 0);\n\t\t\t\t}\n\t\t\t\tt += 7 + *ip++;\n\t\t\t\tNEED_IP(2, 0);\n\t\t\t}\n\t\t\tnext = get_unaligned_le16(ip);\n\t\t\tip += 2;\n\t\t\tm_pos -= next >> 2;\n\t\t\tnext &= 3;\n\t\t\tif (m_pos == op)\n\t\t\t\tgoto eof_found;\n\t\t\tm_pos -= 0x4000;\n\t\t}\n\t\tTEST_LB(m_pos);\n#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)\n\t\tif (op - m_pos >= 8) {\n\t\t\tunsigned char *oe = op + t;\n\t\t\tif (likely(HAVE_OP(t, 15))) {\n\t\t\t\tdo {\n\t\t\t\t\tCOPY8(op, m_pos);\n\t\t\t\t\top += 8;\n\t\t\t\t\tm_pos += 8;\n\t\t\t\t\tCOPY8(op, m_pos);\n\t\t\t\t\top += 8;\n\t\t\t\t\tm_pos += 8;\n\t\t\t\t} while (op < oe);\n\t\t\t\top = oe;\n\t\t\t\tif (HAVE_IP(6, 0)) {\n\t\t\t\t\tstate = next;\n\t\t\t\t\tCOPY4(op, ip);\n\t\t\t\t\top += next;\n\t\t\t\t\tip += next;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tNEED_OP(t, 0);\n\t\t\t\tdo {\n\t\t\t\t\t*op++ = *m_pos++;\n\t\t\t\t} while (op < oe);\n\t\t\t}\n\t\t} else\n#endif\n\t\t{\n\t\t\tunsigned char *oe = op + t;\n\t\t\tNEED_OP(t, 0);\n\t\t\top[0] = m_pos[0];\n\t\t\top[1] = m_pos[1];\n\t\t\top += 2;\n\t\t\tm_pos += 2;\n\t\t\tdo {\n\t\t\t\t*op++ = *m_pos++;\n\t\t\t} while (op < oe);\n\t\t}\nmatch_next:\n\t\tstate = next;\n\t\tt = next;\n#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)\n\t\tif (likely(HAVE_IP(6, 0) && HAVE_OP(4, 0))) {\n\t\t\tCOPY4(op, ip);\n\t\t\top += t;\n\t\t\tip += t;\n\t\t} else\n#endif\n\t\t{\n\t\t\tNEED_IP(t, 3);\n\t\t\tNEED_OP(t, 0);\n\t\t\twhile (t > 0) {\n\t\t\t\t*op++ = *ip++;\n\t\t\t\tt--;\n\t\t\t}\n\t\t}\n\t}\n\neof_found:\n\t*out_len = op - out;\n\treturn (t != 3 ? LZO_E_ERROR :\n\t\tip == ip_end ? LZO_E_OK :\n\t\tip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN);\n\ninput_overrun:\n\t*out_len = op - out;\n\treturn LZO_E_INPUT_OVERRUN;\n\noutput_overrun:\n\t*out_len = op - out;\n\treturn LZO_E_OUTPUT_OVERRUN;\n\nlookbehind_overrun:\n\t*out_len = op - out;\n\treturn LZO_E_LOOKBEHIND_OVERRUN;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-4608", "cwe_id": "CWE-190" }, { "id": 1049, "func": "asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,\n\t\t\t\t unsigned int vlen, unsigned int flags,\n\t\t\t\t struct compat_timespec __user *timeout)\n{\n\tint datagrams;\n\tstruct timespec ktspec;\n\n\tif (flags & MSG_CMSG_COMPAT)\n\t\treturn -EINVAL;\n\n\tif (COMPAT_USE_64BIT_TIME)\n\t\treturn __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,\n\t\t\t\t flags | MSG_CMSG_COMPAT,\n\t\t\t\t (struct timespec *) timeout);\n\n\tif (timeout == NULL)\n\t\treturn __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,\n\t\t\t\t flags | MSG_CMSG_COMPAT, NULL);\n\n\tif (get_compat_timespec(&ktspec, timeout))\n\t\treturn -EFAULT;\n\n\tdatagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,\n\t\t\t\t flags | MSG_CMSG_COMPAT, &ktspec);\n\tif (datagrams > 0 && put_compat_timespec(&ktspec, timeout))\n\t\tdatagrams = -EFAULT;\n\n\treturn datagrams;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-0038", "cwe_id": "CWE-20" }, { "id": 1049, "func": "asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,\n\t\t\t\t unsigned int vlen, unsigned int flags,\n\t\t\t\t struct compat_timespec __user *timeout)\n{\n\tint datagrams;\n\tstruct timespec ktspec;\n\n\tif (flags & MSG_CMSG_COMPAT)\n\t\treturn -EINVAL;\n\n\tif (timeout == NULL)\n\t\treturn __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,\n\t\t\t\t flags | MSG_CMSG_COMPAT, NULL);\n\n\tif (compat_get_timespec(&ktspec, timeout))\n\t\treturn -EFAULT;\n\n\tdatagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,\n\t\t\t\t flags | MSG_CMSG_COMPAT, &ktspec);\n\tif (datagrams > 0 && compat_put_timespec(&ktspec, timeout))\n\t\tdatagrams = -EFAULT;\n\n\treturn datagrams;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-0038", "cwe_id": "CWE-20" }, { "id": 1294, "func": "LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)\n{\n\tstatic const char module[] = \"LZWDecodeCompat\";\n\tLZWCodecState *sp = DecoderState(tif);\n\tchar *op = (char*) op0;\n\tlong occ = (long) occ0;\n\tchar *tp;\n\tunsigned char *bp;\n\tint code, nbits;\n\tlong nextbits, nextdata, nbitsmask;\n\tcode_t *codep, *free_entp, *maxcodep, *oldcodep;\n\n\t(void) s;\n\tassert(sp != NULL);\n\n\t/*\n\t Fail if value does not fit in long.\n\t*/\n\tif ((tmsize_t) occ != occ0)\n\t return (0);\n\n\t/*\n\t * Restart interrupted output operation.\n\t */\n\tif (sp->dec_restart) {\n\t\tlong residue;\n\n\t\tcodep = sp->dec_codep;\n\t\tresidue = codep->length - sp->dec_restart;\n\t\tif (residue > occ) {\n\t\t\t/*\n\t\t\t * Residue from previous decode is sufficient\n\t\t\t * to satisfy decode request. Skip to the\n\t\t\t * start of the decoded string, place decoded\n\t\t\t * values in the output buffer, and return.\n\t\t\t */\n\t\t\tsp->dec_restart += occ;\n\t\t\tdo {\n\t\t\t\tcodep = codep->next;\n\t\t\t} while (--residue > occ);\n\t\t\ttp = op + occ;\n\t\t\tdo {\n\t\t\t\t*--tp = codep->value;\n\t\t\t\tcodep = codep->next;\n\t\t\t} while (--occ);\n\t\t\treturn (1);\n\t\t}\n\t\t/*\n\t\t * Residue satisfies only part of the decode request.\n\t\t */\n\t\top += residue;\n\t\tocc -= residue;\n\t\ttp = op;\n\t\tdo {\n\t\t\t*--tp = codep->value;\n\t\t\tcodep = codep->next;\n\t\t} while (--residue);\n\t\tsp->dec_restart = 0;\n\t}\n\n\tbp = (unsigned char *)tif->tif_rawcp;\n#ifdef LZW_CHECKEOS\n\tsp->dec_bitsleft = (((uint64)tif->tif_rawcc) << 3);\n#endif\n\tnbits = sp->lzw_nbits;\n\tnextdata = sp->lzw_nextdata;\n\tnextbits = sp->lzw_nextbits;\n\tnbitsmask = sp->dec_nbitsmask;\n\toldcodep = sp->dec_oldcodep;\n\tfree_entp = sp->dec_free_entp;\n\tmaxcodep = sp->dec_maxcodep;\n\n\twhile (occ > 0) {\n\t\tNextCode(tif, sp, bp, code, GetNextCodeCompat);\n\t\tif (code == CODE_EOI)\n\t\t\tbreak;\n\t\tif (code == CODE_CLEAR) {\n\t\t\tdo {\n\t\t\t\tfree_entp = sp->dec_codetab + CODE_FIRST;\n\t\t\t\t_TIFFmemset(free_entp, 0,\n\t\t\t\t\t (CSIZE - CODE_FIRST) * sizeof (code_t));\n\t\t\t\tnbits = BITS_MIN;\n\t\t\t\tnbitsmask = MAXCODE(BITS_MIN);\n\t\t\t\tmaxcodep = sp->dec_codetab + nbitsmask;\n\t\t\t\tNextCode(tif, sp, bp, code, GetNextCodeCompat);\n\t\t\t} while (code == CODE_CLEAR);\t/* consecutive CODE_CLEAR codes */\n\t\t\tif (code == CODE_EOI)\n\t\t\t\tbreak;\n\t\t\tif (code > CODE_CLEAR) {\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata, tif->tif_name,\n\t\t\t\t\"LZWDecode: Corrupted LZW table at scanline %d\",\n\t\t\t\t\t tif->tif_row);\n\t\t\t\treturn (0);\n\t\t\t}\n\t\t\t*op++ = (char)code;\n\t\t\tocc--;\n\t\t\toldcodep = sp->dec_codetab + code;\n\t\t\tcontinue;\n\t\t}\n\t\tcodep = sp->dec_codetab + code;\n\n\t\t/*\n\t\t * Add the new entry to the code table.\n\t\t */\n\t\tif (free_entp < &sp->dec_codetab[0] ||\n\t\t free_entp >= &sp->dec_codetab[CSIZE]) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t \"Corrupted LZW table at scanline %d\", tif->tif_row);\n\t\t\treturn (0);\n\t\t}\n\n\t\tfree_entp->next = oldcodep;\n\t\tif (free_entp->next < &sp->dec_codetab[0] ||\n\t\t free_entp->next >= &sp->dec_codetab[CSIZE]) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t \"Corrupted LZW table at scanline %d\", tif->tif_row);\n\t\t\treturn (0);\n\t\t}\n\t\tfree_entp->firstchar = free_entp->next->firstchar;\n\t\tfree_entp->length = free_entp->next->length+1;\n\t\tfree_entp->value = (codep < free_entp) ?\n\t\t codep->firstchar : free_entp->firstchar;\n\t\tif (++free_entp > maxcodep) {\n\t\t\tif (++nbits > BITS_MAX)\t\t/* should not happen */\n\t\t\t\tnbits = BITS_MAX;\n\t\t\tnbitsmask = MAXCODE(nbits);\n\t\t\tmaxcodep = sp->dec_codetab + nbitsmask;\n\t\t}\n\t\toldcodep = codep;\n\t\tif (code >= 256) {\n\t\t\t/*\n\t\t\t * Code maps to a string, copy string\n\t\t\t * value to output (written in reverse).\n\t\t\t */\n\t\t\tif(codep->length == 0) {\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\t \"Wrong length of decoded \"\n\t\t\t\t \"string: data probably corrupted at scanline %d\",\n\t\t\t\t tif->tif_row);\n\t\t\t\treturn (0);\n\t\t\t}\n\t\t\tif (codep->length > occ) {\n\t\t\t\t/*\n\t\t\t\t * String is too long for decode buffer,\n\t\t\t\t * locate portion that will fit, copy to\n\t\t\t\t * the decode buffer, and setup restart\n\t\t\t\t * logic for the next decoding call.\n\t\t\t\t */\n\t\t\t\tsp->dec_codep = codep;\n\t\t\t\tdo {\n\t\t\t\t\tcodep = codep->next;\n\t\t\t\t} while (codep->length > occ);\n\t\t\t\tsp->dec_restart = occ;\n\t\t\t\ttp = op + occ;\n\t\t\t\tdo {\n\t\t\t\t\t*--tp = codep->value;\n\t\t\t\t\tcodep = codep->next;\n\t\t\t\t} while (--occ);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tassert(occ >= codep->length);\n\t\t\top += codep->length;\n\t\t\tocc -= codep->length;\n\t\t\ttp = op;\n\t\t\tdo {\n\t\t\t\t*--tp = codep->value;\n\t\t\t} while( (codep = codep->next) != NULL );\n\t\t} else {\n\t\t\t*op++ = (char)code;\n\t\t\tocc--;\n\t\t}\n\t}\n\n\ttif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp );\n\ttif->tif_rawcp = (uint8*) bp;\n\tsp->lzw_nbits = (unsigned short)nbits;\n\tsp->lzw_nextdata = nextdata;\n\tsp->lzw_nextbits = nextbits;\n\tsp->dec_nbitsmask = nbitsmask;\n\tsp->dec_oldcodep = oldcodep;\n\tsp->dec_free_entp = free_entp;\n\tsp->dec_maxcodep = maxcodep;\n\n\tif (occ > 0) {\n#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\"Not enough data at scanline %d (short %I64d bytes)\",\n\t\t\t tif->tif_row, (unsigned __int64) occ);\n#else\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\"Not enough data at scanline %d (short %llu bytes)\",\n\t\t\t tif->tif_row, (unsigned long long) occ);\n#endif\n\t\treturn (0);\n\t}\n\treturn (1);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-8905", "cwe_id": "CWE-787" }, { "id": 1294, "func": "LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)\n{\n\tstatic const char module[] = \"LZWDecodeCompat\";\n\tLZWCodecState *sp = DecoderState(tif);\n\tchar *op = (char*) op0;\n\tlong occ = (long) occ0;\n\tchar *tp;\n\tunsigned char *bp;\n\tint code, nbits;\n\tint len;\n\tlong nextbits, nextdata, nbitsmask;\n\tcode_t *codep, *free_entp, *maxcodep, *oldcodep;\n\n\t(void) s;\n\tassert(sp != NULL);\n\n\t/*\n\t Fail if value does not fit in long.\n\t*/\n\tif ((tmsize_t) occ != occ0)\n\t return (0);\n\n\t/*\n\t * Restart interrupted output operation.\n\t */\n\tif (sp->dec_restart) {\n\t\tlong residue;\n\n\t\tcodep = sp->dec_codep;\n\t\tresidue = codep->length - sp->dec_restart;\n\t\tif (residue > occ) {\n\t\t\t/*\n\t\t\t * Residue from previous decode is sufficient\n\t\t\t * to satisfy decode request. Skip to the\n\t\t\t * start of the decoded string, place decoded\n\t\t\t * values in the output buffer, and return.\n\t\t\t */\n\t\t\tsp->dec_restart += occ;\n\t\t\tdo {\n\t\t\t\tcodep = codep->next;\n\t\t\t} while (--residue > occ);\n\t\t\ttp = op + occ;\n\t\t\tdo {\n\t\t\t\t*--tp = codep->value;\n\t\t\t\tcodep = codep->next;\n\t\t\t} while (--occ);\n\t\t\treturn (1);\n\t\t}\n\t\t/*\n\t\t * Residue satisfies only part of the decode request.\n\t\t */\n\t\top += residue;\n\t\tocc -= residue;\n\t\ttp = op;\n\t\tdo {\n\t\t\t*--tp = codep->value;\n\t\t\tcodep = codep->next;\n\t\t} while (--residue);\n\t\tsp->dec_restart = 0;\n\t}\n\n\tbp = (unsigned char *)tif->tif_rawcp;\n#ifdef LZW_CHECKEOS\n\tsp->dec_bitsleft = (((uint64)tif->tif_rawcc) << 3);\n#endif\n\tnbits = sp->lzw_nbits;\n\tnextdata = sp->lzw_nextdata;\n\tnextbits = sp->lzw_nextbits;\n\tnbitsmask = sp->dec_nbitsmask;\n\toldcodep = sp->dec_oldcodep;\n\tfree_entp = sp->dec_free_entp;\n\tmaxcodep = sp->dec_maxcodep;\n\n\twhile (occ > 0) {\n\t\tNextCode(tif, sp, bp, code, GetNextCodeCompat);\n\t\tif (code == CODE_EOI)\n\t\t\tbreak;\n\t\tif (code == CODE_CLEAR) {\n\t\t\tdo {\n\t\t\t\tfree_entp = sp->dec_codetab + CODE_FIRST;\n\t\t\t\t_TIFFmemset(free_entp, 0,\n\t\t\t\t\t (CSIZE - CODE_FIRST) * sizeof (code_t));\n\t\t\t\tnbits = BITS_MIN;\n\t\t\t\tnbitsmask = MAXCODE(BITS_MIN);\n\t\t\t\tmaxcodep = sp->dec_codetab + nbitsmask;\n\t\t\t\tNextCode(tif, sp, bp, code, GetNextCodeCompat);\n\t\t\t} while (code == CODE_CLEAR);\t/* consecutive CODE_CLEAR codes */\n\t\t\tif (code == CODE_EOI)\n\t\t\t\tbreak;\n\t\t\tif (code > CODE_CLEAR) {\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata, tif->tif_name,\n\t\t\t\t\"LZWDecode: Corrupted LZW table at scanline %d\",\n\t\t\t\t\t tif->tif_row);\n\t\t\t\treturn (0);\n\t\t\t}\n\t\t\t*op++ = (char)code;\n\t\t\tocc--;\n\t\t\toldcodep = sp->dec_codetab + code;\n\t\t\tcontinue;\n\t\t}\n\t\tcodep = sp->dec_codetab + code;\n\n\t\t/*\n\t\t * Add the new entry to the code table.\n\t\t */\n\t\tif (free_entp < &sp->dec_codetab[0] ||\n\t\t free_entp >= &sp->dec_codetab[CSIZE]) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t \"Corrupted LZW table at scanline %d\", tif->tif_row);\n\t\t\treturn (0);\n\t\t}\n\n\t\tfree_entp->next = oldcodep;\n\t\tif (free_entp->next < &sp->dec_codetab[0] ||\n\t\t free_entp->next >= &sp->dec_codetab[CSIZE]) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t \"Corrupted LZW table at scanline %d\", tif->tif_row);\n\t\t\treturn (0);\n\t\t}\n\t\tfree_entp->firstchar = free_entp->next->firstchar;\n\t\tfree_entp->length = free_entp->next->length+1;\n\t\tfree_entp->value = (codep < free_entp) ?\n\t\t codep->firstchar : free_entp->firstchar;\n\t\tif (++free_entp > maxcodep) {\n\t\t\tif (++nbits > BITS_MAX)\t\t/* should not happen */\n\t\t\t\tnbits = BITS_MAX;\n\t\t\tnbitsmask = MAXCODE(nbits);\n\t\t\tmaxcodep = sp->dec_codetab + nbitsmask;\n\t\t}\n\t\toldcodep = codep;\n\t\tif (code >= 256) {\n\t\t\t/*\n\t\t\t * Code maps to a string, copy string\n\t\t\t * value to output (written in reverse).\n\t\t\t */\n\t\t\tif(codep->length == 0) {\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\t \"Wrong length of decoded \"\n\t\t\t\t \"string: data probably corrupted at scanline %d\",\n\t\t\t\t tif->tif_row);\n\t\t\t\treturn (0);\n\t\t\t}\n\t\t\tif (codep->length > occ) {\n\t\t\t\t/*\n\t\t\t\t * String is too long for decode buffer,\n\t\t\t\t * locate portion that will fit, copy to\n\t\t\t\t * the decode buffer, and setup restart\n\t\t\t\t * logic for the next decoding call.\n\t\t\t\t */\n\t\t\t\tsp->dec_codep = codep;\n\t\t\t\tdo {\n\t\t\t\t\tcodep = codep->next;\n\t\t\t\t} while (codep->length > occ);\n\t\t\t\tsp->dec_restart = occ;\n\t\t\t\ttp = op + occ;\n\t\t\t\tdo {\n\t\t\t\t\t*--tp = codep->value;\n\t\t\t\t\tcodep = codep->next;\n\t\t\t\t} while (--occ);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlen = codep->length;\n\t\t\ttp = op + len;\n\t\t\tdo {\n\t\t\t\tint t;\n\t\t\t\t--tp;\n\t\t\t\tt = codep->value;\n\t\t\t\tcodep = codep->next;\n\t\t\t\t*tp = (char)t;\n\t\t\t} while (codep && tp > op);\n\t\t\tassert(occ >= len);\n\t\t\top += len;\n\t\t\tocc -= len;\n\t\t} else {\n\t\t\t*op++ = (char)code;\n\t\t\tocc--;\n\t\t}\n\t}\n\n\ttif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp );\n\ttif->tif_rawcp = (uint8*) bp;\n\tsp->lzw_nbits = (unsigned short)nbits;\n\tsp->lzw_nextdata = nextdata;\n\tsp->lzw_nextbits = nextbits;\n\tsp->dec_nbitsmask = nbitsmask;\n\tsp->dec_oldcodep = oldcodep;\n\tsp->dec_free_entp = free_entp;\n\tsp->dec_maxcodep = maxcodep;\n\n\tif (occ > 0) {\n#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\"Not enough data at scanline %d (short %I64d bytes)\",\n\t\t\t tif->tif_row, (unsigned __int64) occ);\n#else\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t\"Not enough data at scanline %d (short %llu bytes)\",\n\t\t\t tif->tif_row, (unsigned long long) occ);\n#endif\n\t\treturn (0);\n\t}\n\treturn (1);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-8905", "cwe_id": "CWE-787" }, { "id": 906, "func": "convert_to_decimal (mpn_t a, size_t extra_zeroes)\n{\n mp_limb_t *a_ptr = a.limbs;\n size_t a_len = a.nlimbs;\n /* 0.03345 is slightly larger than log(2)/(9*log(10)). */\n size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1);\n char *c_ptr = (char *) malloc (xsum (c_len, extra_zeroes));\n if (c_ptr != NULL)\n {\n char *d_ptr = c_ptr;\n for (; extra_zeroes > 0; extra_zeroes--)\n *d_ptr++ = '0';\n while (a_len > 0)\n {\n /* Divide a by 10^9, in-place. */\n mp_limb_t remainder = 0;\n mp_limb_t *ptr = a_ptr + a_len;\n size_t count;\n for (count = a_len; count > 0; count--)\n {\n mp_twolimb_t num =\n ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;\n *ptr = num / 1000000000;\n remainder = num % 1000000000;\n }\n /* Store the remainder as 9 decimal digits. */\n for (count = 9; count > 0; count--)\n {\n *d_ptr++ = '0' + (remainder % 10);\n remainder = remainder / 10;\n }\n /* Normalize a. */\n if (a_ptr[a_len - 1] == 0)\n a_len--;\n }\n /* Remove leading zeroes. */\n while (d_ptr > c_ptr && d_ptr[-1] == '0')\n d_ptr--;\n /* But keep at least one zero. */\n if (d_ptr == c_ptr)\n *d_ptr++ = '0';\n /* Terminate the string. */\n *d_ptr = '\\0';\n }\n return c_ptr;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-17942", "cwe_id": "CWE-787" }, { "id": 906, "func": "convert_to_decimal (mpn_t a, size_t extra_zeroes)\n{\n mp_limb_t *a_ptr = a.limbs;\n size_t a_len = a.nlimbs;\n /* 0.03345 is slightly larger than log(2)/(9*log(10)). */\n size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1);\n /* We need extra_zeroes bytes for zeroes, followed by c_len bytes for the\n digits of a, followed by 1 byte for the terminating NUL. */\n char *c_ptr = (char *) malloc (xsum (xsum (extra_zeroes, c_len), 1));\n if (c_ptr != NULL)\n {\n char *d_ptr = c_ptr;\n for (; extra_zeroes > 0; extra_zeroes--)\n *d_ptr++ = '0';\n while (a_len > 0)\n {\n /* Divide a by 10^9, in-place. */\n mp_limb_t remainder = 0;\n mp_limb_t *ptr = a_ptr + a_len;\n size_t count;\n for (count = a_len; count > 0; count--)\n {\n mp_twolimb_t num =\n ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;\n *ptr = num / 1000000000;\n remainder = num % 1000000000;\n }\n /* Store the remainder as 9 decimal digits. */\n for (count = 9; count > 0; count--)\n {\n *d_ptr++ = '0' + (remainder % 10);\n remainder = remainder / 10;\n }\n /* Normalize a. */\n if (a_ptr[a_len - 1] == 0)\n a_len--;\n }\n /* Remove leading zeroes. */\n while (d_ptr > c_ptr && d_ptr[-1] == '0')\n d_ptr--;\n /* But keep at least one zero. */\n if (d_ptr == c_ptr)\n *d_ptr++ = '0';\n /* Terminate the string. */\n *d_ptr = '\\0';\n }\n return c_ptr;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-17942", "cwe_id": "CWE-787" }, { "id": 2606, "func": "ast_for_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_seq)\n{\n /* funcdef: 'def' NAME parameters ['->' test] ':' suite */\n return ast_for_funcdef_impl(c, n, decorator_seq,\n 0 /* is_async */);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2606, "func": "ast_for_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_seq)\n{\n /* funcdef: 'def' NAME parameters ['->' test] ':' suite */\n return ast_for_funcdef_impl(c, n, decorator_seq,\n false /* is_async */);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2115, "func": "GF_Err tenc_dump(GF_Box *a, FILE * trace)\n{\n\tGF_TrackEncryptionBox *ptr = (GF_TrackEncryptionBox*) a;\n\tif (!a) return GF_BAD_PARAM;\n\n\tgf_isom_box_dump_start(a, \"TrackEncryptionBox\", trace);\n\n\tfprintf(trace, \"isEncrypted=\\\"%d\\\"\", ptr->isProtected);\n\tif (ptr->Per_Sample_IV_Size)\n\t\tfprintf(trace, \" IV_size=\\\"%d\\\" KID=\\\"\", ptr->Per_Sample_IV_Size);\n\telse {\n\t\tfprintf(trace, \" constant_IV_size=\\\"%d\\\" constant_IV=\\\"\", ptr->constant_IV_size);\n\t\tdump_data_hex(trace, (char *) ptr->constant_IV, ptr->constant_IV_size);\n\t\tfprintf(trace, \"\\\" KID=\\\"\");\n\t}\n\tdump_data_hex(trace, (char *) ptr->KID, 16);\n\tif (ptr->version) \n\t\tfprintf(trace, \"\\\" crypt_byte_block=\\\"%d\\\" skip_byte_block=\\\"%d\", ptr->crypt_byte_block, ptr->skip_byte_block);\n\tfprintf(trace, \"\\\">\\n\");\n\tgf_isom_box_dump_done(\"TrackEncryptionBox\", a, trace);\n\treturn GF_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-13006", "cwe_id": "CWE-125" }, { "id": 2115, "func": "GF_Err tenc_dump(GF_Box *a, FILE * trace)\n{\n\tGF_TrackEncryptionBox *ptr = (GF_TrackEncryptionBox*) a;\n\tif (!a) return GF_BAD_PARAM;\n\n\tgf_isom_box_dump_start(a, \"TrackEncryptionBox\", trace);\n\n\tfprintf(trace, \"isEncrypted=\\\"%d\\\"\", ptr->isProtected);\n\tif (ptr->Per_Sample_IV_Size)\n\t\tfprintf(trace, \" IV_size=\\\"%d\\\" KID=\\\"\", ptr->Per_Sample_IV_Size);\n\telse {\n\t\tfprintf(trace, \" constant_IV_size=\\\"%d\\\" constant_IV=\\\"\", ptr->constant_IV_size);\n\t\tdump_data_hex(trace, (char *) ptr->constant_IV, ptr->constant_IV_size);\n\t\tfprintf(trace, \"\\\" KID=\\\"\");\n\t}\n\tdump_data_hex(trace, (char *) ptr->KID, 16);\n\tif (ptr->version)\n\t\tfprintf(trace, \"\\\" crypt_byte_block=\\\"%d\\\" skip_byte_block=\\\"%d\", ptr->crypt_byte_block, ptr->skip_byte_block);\n\tfprintf(trace, \"\\\">\\n\");\n\tgf_isom_box_dump_done(\"TrackEncryptionBox\", a, trace);\n\treturn GF_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-13006", "cwe_id": "CWE-125" }, { "id": 3197, "func": "hb_set_subtract (hb_set_t *set,\n\t\t const hb_set_t *other)\n{\n if (unlikely (hb_object_is_immutable (set)))\n return;\n\n set->subtract (*other);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-45931", "cwe_id": "CWE-787" }, { "id": 3197, "func": "hb_set_subtract (hb_set_t *set,\n\t\t const hb_set_t *other)\n{\n /* Immutible-safe. */\n set->subtract (*other);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-45931", "cwe_id": "CWE-787" }, { "id": 1666, "func": "TRIO_PUBLIC_STRING size_t trio_length TRIO_ARGS1((string), TRIO_CONST char* string)\n{\n\treturn strlen(string);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-4030", "cwe_id": "CWE-190" }, { "id": 1666, "func": "TRIO_PUBLIC_STRING size_t trio_length TRIO_ARGS1((string), TRIO_CONST char* string)\n{\n\treturn trio_length_max(string, INT_MAX);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-4030", "cwe_id": "CWE-190" }, { "id": 552, "func": "void Polygon::Insert( sal_uInt16 nPos, const Point& rPt )\n{\n ImplMakeUnique();\n\n if( nPos >= mpImplPolygon->mnPoints )\n nPos = mpImplPolygon->mnPoints;\n\n mpImplPolygon->ImplSplit( nPos, 1 );\n mpImplPolygon->mpPointAry[ nPos ] = rPt;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7870", "cwe_id": "CWE-787" }, { "id": 552, "func": "void Polygon::Insert( sal_uInt16 nPos, const Point& rPt )\n{\n ImplMakeUnique();\n\n if( nPos >= mpImplPolygon->mnPoints )\n nPos = mpImplPolygon->mnPoints;\n\n if (mpImplPolygon->ImplSplit(nPos, 1))\n mpImplPolygon->mpPointAry[ nPos ] = rPt;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7870", "cwe_id": "CWE-787" }, { "id": 1916, "func": "get_chainname_rulenum(const struct ipt_entry *s, const struct ipt_entry *e,\n\t\t const char *hookname, const char **chainname,\n\t\t const char **comment, unsigned int *rulenum)\n{\n\tconst struct xt_standard_target *t = (void *)ipt_get_target_c(s);\n\n\tif (strcmp(t->target.u.kernel.target->name, XT_ERROR_TARGET) == 0) {\n\t\t/* Head of user chain: ERROR target with chainname */\n\t\t*chainname = t->target.data;\n\t\t(*rulenum) = 0;\n\t} else if (s == e) {\n\t\t(*rulenum)++;\n\n\t\tif (s->target_offset == sizeof(struct ipt_entry) &&\n\t\t strcmp(t->target.u.kernel.target->name,\n\t\t\t XT_STANDARD_TARGET) == 0 &&\n\t\t t->verdict < 0 &&\n\t\t unconditional(&s->ip)) {\n\t\t\t/* Tail of chains: STANDARD target (return/policy) */\n\t\t\t*comment = *chainname == hookname\n\t\t\t\t? comments[NF_IP_TRACE_COMMENT_POLICY]\n\t\t\t\t: comments[NF_IP_TRACE_COMMENT_RETURN];\n\t\t}\n\t\treturn 1;\n\t} else\n\t\t(*rulenum)++;\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-3134", "cwe_id": "CWE-119" }, { "id": 1916, "func": "get_chainname_rulenum(const struct ipt_entry *s, const struct ipt_entry *e,\n\t\t const char *hookname, const char **chainname,\n\t\t const char **comment, unsigned int *rulenum)\n{\n\tconst struct xt_standard_target *t = (void *)ipt_get_target_c(s);\n\n\tif (strcmp(t->target.u.kernel.target->name, XT_ERROR_TARGET) == 0) {\n\t\t/* Head of user chain: ERROR target with chainname */\n\t\t*chainname = t->target.data;\n\t\t(*rulenum) = 0;\n\t} else if (s == e) {\n\t\t(*rulenum)++;\n\n\t\tif (unconditional(s) &&\n\t\t strcmp(t->target.u.kernel.target->name,\n\t\t\t XT_STANDARD_TARGET) == 0 &&\n\t\t t->verdict < 0) {\n\t\t\t/* Tail of chains: STANDARD target (return/policy) */\n\t\t\t*comment = *chainname == hookname\n\t\t\t\t? comments[NF_IP_TRACE_COMMENT_POLICY]\n\t\t\t\t: comments[NF_IP_TRACE_COMMENT_RETURN];\n\t\t}\n\t\treturn 1;\n\t} else\n\t\t(*rulenum)++;\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-3134", "cwe_id": "CWE-119" }, { "id": 255, "func": "static int futex_wait(u32 __user *uaddr, int fshared,\n\t\t u32 val, ktime_t *abs_time, u32 bitset, int clockrt)\n{\n\tstruct hrtimer_sleeper timeout, *to = NULL;\n\tstruct restart_block *restart;\n\tstruct futex_hash_bucket *hb;\n\tstruct futex_q q;\n\tint ret;\n\n\tif (!bitset)\n\t\treturn -EINVAL;\n\n\tq.pi_state = NULL;\n\tq.bitset = bitset;\n\tq.rt_waiter = NULL;\n\tq.requeue_pi_key = NULL;\n\n\tif (abs_time) {\n\t\tto = &timeout;\n\n\t\thrtimer_init_on_stack(&to->timer, clockrt ? CLOCK_REALTIME :\n\t\t\t\t CLOCK_MONOTONIC, HRTIMER_MODE_ABS);\n\t\thrtimer_init_sleeper(to, current);\n\t\thrtimer_set_expires_range_ns(&to->timer, *abs_time,\n\t\t\t\t\t current->timer_slack_ns);\n\t}\n\nretry:\n\t/* Prepare to wait on uaddr. */\n\tret = futex_wait_setup(uaddr, val, fshared, &q, &hb);\n\tif (ret)\n\t\tgoto out;\n\n\t/* queue_me and wait for wakeup, timeout, or a signal. */\n\tfutex_wait_queue_me(hb, &q, to);\n\n\t/* If we were woken (and unqueued), we succeeded, whatever. */\n\tret = 0;\n\tif (!unqueue_me(&q))\n\t\tgoto out_put_key;\n\tret = -ETIMEDOUT;\n\tif (to && !to->task)\n\t\tgoto out_put_key;\n\n\t/*\n\t * We expect signal_pending(current), but we might be the\n\t * victim of a spurious wakeup as well.\n\t */\n\tif (!signal_pending(current)) {\n\t\tput_futex_key(fshared, &q.key);\n\t\tgoto retry;\n\t}\n\n\tret = -ERESTARTSYS;\n\tif (!abs_time)\n\t\tgoto out_put_key;\n\n\trestart = ¤t_thread_info()->restart_block;\n\trestart->fn = futex_wait_restart;\n\trestart->futex.uaddr = (u32 *)uaddr;\n\trestart->futex.val = val;\n\trestart->futex.time = abs_time->tv64;\n\trestart->futex.bitset = bitset;\n\trestart->futex.flags = FLAGS_HAS_TIMEOUT;\n\n\tif (fshared)\n\t\trestart->futex.flags |= FLAGS_SHARED;\n\tif (clockrt)\n\t\trestart->futex.flags |= FLAGS_CLOCKRT;\n\n\tret = -ERESTART_RESTARTBLOCK;\n\nout_put_key:\n\tput_futex_key(fshared, &q.key);\nout:\n\tif (to) {\n\t\thrtimer_cancel(&to->timer);\n\t\tdestroy_hrtimer_on_stack(&to->timer);\n\t}\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-0205", "cwe_id": "CWE-119" }, { "id": 255, "func": "static int futex_wait(u32 __user *uaddr, int fshared,\n\t\t u32 val, ktime_t *abs_time, u32 bitset, int clockrt)\n{\n\tstruct hrtimer_sleeper timeout, *to = NULL;\n\tstruct restart_block *restart;\n\tstruct futex_hash_bucket *hb;\n\tstruct futex_q q;\n\tint ret;\n\n\tif (!bitset)\n\t\treturn -EINVAL;\n\n\tq.pi_state = NULL;\n\tq.bitset = bitset;\n\tq.rt_waiter = NULL;\n\tq.requeue_pi_key = NULL;\n\n\tif (abs_time) {\n\t\tto = &timeout;\n\n\t\thrtimer_init_on_stack(&to->timer, clockrt ? CLOCK_REALTIME :\n\t\t\t\t CLOCK_MONOTONIC, HRTIMER_MODE_ABS);\n\t\thrtimer_init_sleeper(to, current);\n\t\thrtimer_set_expires_range_ns(&to->timer, *abs_time,\n\t\t\t\t\t current->timer_slack_ns);\n\t}\n\nretry:\n\t/*\n\t * Prepare to wait on uaddr. On success, holds hb lock and increments\n\t * q.key refs.\n\t */\n\tret = futex_wait_setup(uaddr, val, fshared, &q, &hb);\n\tif (ret)\n\t\tgoto out;\n\n\t/* queue_me and wait for wakeup, timeout, or a signal. */\n\tfutex_wait_queue_me(hb, &q, to);\n\n\t/* If we were woken (and unqueued), we succeeded, whatever. */\n\tret = 0;\n\t/* unqueue_me() drops q.key ref */\n\tif (!unqueue_me(&q))\n\t\tgoto out;\n\tret = -ETIMEDOUT;\n\tif (to && !to->task)\n\t\tgoto out;\n\n\t/*\n\t * We expect signal_pending(current), but we might be the\n\t * victim of a spurious wakeup as well.\n\t */\n\tif (!signal_pending(current))\n\t\tgoto retry;\n\n\tret = -ERESTARTSYS;\n\tif (!abs_time)\n\t\tgoto out;\n\n\trestart = ¤t_thread_info()->restart_block;\n\trestart->fn = futex_wait_restart;\n\trestart->futex.uaddr = (u32 *)uaddr;\n\trestart->futex.val = val;\n\trestart->futex.time = abs_time->tv64;\n\trestart->futex.bitset = bitset;\n\trestart->futex.flags = FLAGS_HAS_TIMEOUT;\n\n\tif (fshared)\n\t\trestart->futex.flags |= FLAGS_SHARED;\n\tif (clockrt)\n\t\trestart->futex.flags |= FLAGS_CLOCKRT;\n\n\tret = -ERESTART_RESTARTBLOCK;\n\nout:\n\tif (to) {\n\t\thrtimer_cancel(&to->timer);\n\t\tdestroy_hrtimer_on_stack(&to->timer);\n\t}\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-0205", "cwe_id": "CWE-119" }, { "id": 1902, "func": "error_t enc624j600ReceivePacket(NetInterface *interface)\n{\n error_t error;\n uint16_t n;\n uint32_t status;\n Enc624j600Context *context;\n\n //Point to the driver context\n context = (Enc624j600Context *) interface->nicContext;\n\n //Verify that a packet is waiting by ensuring that PKTCNT is non-zero\n if(enc624j600ReadReg(interface, ENC624J600_REG_ESTAT) & ESTAT_PKTCNT)\n {\n //Point to the next packet\n enc624j600WriteReg(interface, ENC624J600_REG_ERXRDPT, context->nextPacket);\n\n //Read the first two bytes, which are the address of the next packet\n enc624j600ReadBuffer(interface, ENC624J600_CMD_RRXDATA,\n (uint8_t *) &context->nextPacket, sizeof(uint16_t));\n\n //Convert the value to host byte order\n context->nextPacket = letoh16(context->nextPacket);\n\n //Get the length of the received frame in bytes\n enc624j600ReadBuffer(interface, ENC624J600_CMD_RRXDATA,\n (uint8_t *) &n, sizeof(uint16_t));\n\n //Convert the value to host byte order\n n = letoh16(n);\n\n //Read the receive status vector (RSV)\n enc624j600ReadBuffer(interface, ENC624J600_CMD_RRXDATA,\n (uint8_t *) &status, sizeof(uint32_t));\n\n //Convert the value to host byte order\n status = letoh32(status);\n\n //Make sure no error occurred\n if((status & RSV_RECEIVED_OK) != 0)\n {\n //Limit the number of data to read\n n = MIN(n, ETH_MAX_FRAME_SIZE);\n //Read the Ethernet frame\n enc624j600ReadBuffer(interface, ENC624J600_CMD_RRXDATA, context->rxBuffer, n);\n //Valid packet received\n error = NO_ERROR;\n }\n else\n {\n //The received packet contains an error\n error = ERROR_INVALID_PACKET;\n }\n\n //Update the ERXTAIL pointer value to the point where the packet\n //has been processed, taking care to wrap back at the end of the\n //received memory buffer\n if(context->nextPacket == ENC624J600_RX_BUFFER_START)\n {\n enc624j600WriteReg(interface, ENC624J600_REG_ERXTAIL, ENC624J600_RX_BUFFER_STOP);\n }\n else\n {\n enc624j600WriteReg(interface, ENC624J600_REG_ERXTAIL, context->nextPacket - 2);\n }\n\n //Set PKTDEC to decrement the PKTCNT bits\n enc624j600SetBit(interface, ENC624J600_REG_ECON1, ECON1_PKTDEC);\n }\n else\n {\n //No more data in the receive buffer\n error = ERROR_BUFFER_EMPTY;\n }\n\n //Check whether a valid packet has been received\n if(!error)\n {\n NetRxAncillary ancillary;\n\n //Additional options can be passed to the stack along with the packet\n ancillary = NET_DEFAULT_RX_ANCILLARY;\n\n //Pass the packet to the upper layer\n nicProcessPacket(interface, context->rxBuffer, n, &ancillary);\n }\n\n //Return status code\n return error;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1902, "func": "error_t enc624j600ReceivePacket(NetInterface *interface)\n{\n error_t error;\n uint16_t length;\n uint32_t status;\n uint8_t header[8];\n Enc624j600Context *context;\n\n //Point to the driver context\n context = (Enc624j600Context *) interface->nicContext;\n\n //Verify that a packet is waiting by ensuring that PKTCNT is non-zero\n if(enc624j600ReadReg(interface, ENC624J600_ESTAT) & ENC624J600_ESTAT_PKTCNT)\n {\n //Point to the next packet\n enc624j600WriteReg(interface, ENC624J600_ERXRDPT, context->nextPacket);\n\n //The packet is preceded by a 8-byte header\n enc624j600ReadBuffer(interface, ENC624J600_CMD_RRXDATA, header, sizeof(header));\n\n //The first two bytes are the address of the next packet\n context->nextPacket = LOAD16LE(header);\n //Get the length of the received packet\n length = LOAD16LE(header + 2);\n //Get the receive status vector (RSV)\n status = LOAD32LE(header + 4);\n\n //Make sure no error occurred\n if((status & ENC624J600_RSV_RECEIVED_OK) != 0)\n {\n //Limit the number of data to read\n length = MIN(length, ETH_MAX_FRAME_SIZE);\n\n //Read the Ethernet frame\n enc624j600ReadBuffer(interface, ENC624J600_CMD_RRXDATA,\n context->rxBuffer, length);\n\n //Valid packet received\n error = NO_ERROR;\n }\n else\n {\n //The received packet contains an error\n error = ERROR_INVALID_PACKET;\n }\n\n //Update the ERXTAIL pointer value to the point where the packet\n //has been processed, taking care to wrap back at the end of the\n //received memory buffer\n if(context->nextPacket == ENC624J600_RX_BUFFER_START)\n {\n enc624j600WriteReg(interface, ENC624J600_ERXTAIL,\n ENC624J600_RX_BUFFER_STOP);\n }\n else\n {\n enc624j600WriteReg(interface, ENC624J600_ERXTAIL,\n context->nextPacket - 2);\n }\n\n //Set PKTDEC to decrement the PKTCNT bits\n enc624j600SetBit(interface, ENC624J600_ECON1, ENC624J600_ECON1_PKTDEC);\n }\n else\n {\n //No more data in the receive buffer\n error = ERROR_BUFFER_EMPTY;\n }\n\n //Check whether a valid packet has been received\n if(!error)\n {\n NetRxAncillary ancillary;\n\n //Additional options can be passed to the stack along with the packet\n ancillary = NET_DEFAULT_RX_ANCILLARY;\n\n //Pass the packet to the upper layer\n nicProcessPacket(interface, context->rxBuffer, length, &ancillary);\n }\n\n //Return status code\n return error;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1735, "func": "static int nntp_hcache_namer(const char *path, char *dest, size_t destlen)\n{\n return snprintf(dest, destlen, \"%s.hcache\", path);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-14362", "cwe_id": "CWE-119" }, { "id": 1735, "func": "static int nntp_hcache_namer(const char *path, char *dest, size_t destlen)\n{\n int count = snprintf(dest, destlen, \"%s.hcache\", path);\n\n /* Strip out any directories in the path */\n char *first = strchr(dest, '/');\n char *last = strrchr(dest, '/');\n if (first && last && (last > first))\n {\n memmove(first, last, strlen(last) + 1);\n count -= (last - first);\n }\n\n return count;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-14362", "cwe_id": "CWE-119" }, { "id": 2662, "func": "static void parse_content_range(URLContext *h, const char *p)\n{\n HTTPContext *s = h->priv_data;\n const char *slash;\n\n if (!strncmp(p, \"bytes \", 6)) {\n p += 6;\n s->off = strtoll(p, NULL, 10);\n if ((slash = strchr(p, '/')) && strlen(slash) > 0)\n s->filesize = strtoll(slash + 1, NULL, 10);\n }\n if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647))\n h->is_streamed = 0; /* we _can_ in fact seek */\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10190", "cwe_id": "CWE-119" }, { "id": 2662, "func": "static void parse_content_range(URLContext *h, const char *p)\n{\n HTTPContext *s = h->priv_data;\n const char *slash;\n\n if (!strncmp(p, \"bytes \", 6)) {\n p += 6;\n s->off = strtoull(p, NULL, 10);\n if ((slash = strchr(p, '/')) && strlen(slash) > 0)\n s->filesize = strtoull(slash + 1, NULL, 10);\n }\n if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647))\n h->is_streamed = 0; /* we _can_ in fact seek */\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10190", "cwe_id": "CWE-119" }, { "id": 3048, "func": "error_t getHostByName(NetInterface *interface,\n const char_t *name, IpAddr *ipAddr, uint_t flags)\n{\n error_t error;\n HostType type;\n HostnameResolver protocol;\n\n //Default address type depends on TCP/IP stack configuration\n#if (IPV4_SUPPORT == ENABLED)\n type = HOST_TYPE_IPV4;\n#elif (IPV6_SUPPORT == ENABLED)\n type = HOST_TYPE_IPV6;\n#else\n type = HOST_TYPE_ANY;\n#endif\n\n //Default name resolution protocol depends on TCP/IP stack configuration\n#if (DNS_CLIENT_SUPPORT == ENABLED)\n protocol = HOST_NAME_RESOLVER_DNS;\n#elif (MDNS_CLIENT_SUPPORT == ENABLED)\n protocol = HOST_NAME_RESOLVER_MDNS;\n#elif (NBNS_CLIENT_SUPPORT == ENABLED)\n protocol = HOST_NAME_RESOLVER_NBNS;\n#elif (LLMNR_CLIENT_SUPPORT == ENABLED)\n protocol = HOST_NAME_RESOLVER_LLMNR;\n#else\n protocol = HOST_NAME_RESOLVER_ANY;\n#endif\n\n //Check parameters\n if(name == NULL || ipAddr == NULL)\n return ERROR_INVALID_PARAMETER;\n\n //Use default network interface?\n if(interface == NULL)\n interface = netGetDefaultInterface();\n\n //The specified name can be either an IP or a host name\n error = ipStringToAddr(name, ipAddr);\n\n //Perform name resolution if necessary\n if(error)\n {\n //The user may provide a hint to choose between IPv4 and IPv6\n if(flags & HOST_TYPE_IPV4)\n type = HOST_TYPE_IPV4;\n else if(flags & HOST_TYPE_IPV6)\n type = HOST_TYPE_IPV6;\n\n //The user may provide a hint to to select the desired protocol to be used\n if(flags & HOST_NAME_RESOLVER_DNS)\n {\n //Use DNS to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_DNS;\n }\n else if(flags & HOST_NAME_RESOLVER_MDNS)\n {\n //Use mDNS to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_MDNS;\n }\n else if(flags & HOST_NAME_RESOLVER_NBNS)\n {\n //Use NBNS to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_NBNS;\n }\n else if(flags & HOST_NAME_RESOLVER_LLMNR)\n {\n //Use LLMNR to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_LLMNR;\n }\n else\n {\n //Retrieve the length of the host name to be resolved\n size_t n = osStrlen(name);\n\n //Select the most suitable protocol\n if(n >= 6 && !osStrcasecmp(name + n - 6, \".local\"))\n {\n#if (MDNS_CLIENT_SUPPORT == ENABLED)\n //Use mDNS to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_MDNS;\n#endif\n }\n else if(n <= 15 && !strchr(name, '.') && type == HOST_TYPE_IPV4)\n {\n#if (NBNS_CLIENT_SUPPORT == ENABLED)\n //Use NetBIOS Name Service to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_NBNS;\n#endif\n }\n else if(!strchr(name, '.'))\n {\n#if (LLMNR_CLIENT_SUPPORT == ENABLED)\n //Use LLMNR to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_LLMNR;\n#endif\n }\n }\n\n#if (DNS_CLIENT_SUPPORT == ENABLED)\n //Use DNS protocol?\n if(protocol == HOST_NAME_RESOLVER_DNS)\n {\n //Perform host name resolution\n error = dnsResolve(interface, name, type, ipAddr);\n }\n else\n#endif\n#if (MDNS_CLIENT_SUPPORT == ENABLED)\n //Use mDNS protocol?\n if(protocol == HOST_NAME_RESOLVER_MDNS)\n {\n //Perform host name resolution\n error = mdnsClientResolve(interface, name, type, ipAddr);\n }\n else\n#endif\n#if (NBNS_CLIENT_SUPPORT == ENABLED && IPV4_SUPPORT == ENABLED)\n //Use NetBIOS Name Service protocol?\n if(protocol == HOST_NAME_RESOLVER_NBNS)\n {\n //Perform host name resolution\n error = nbnsResolve(interface, name, ipAddr);\n }\n else\n#endif\n#if (LLMNR_CLIENT_SUPPORT == ENABLED)\n //Use LLMNR protocol?\n if(protocol == HOST_NAME_RESOLVER_LLMNR)\n {\n //Perform host name resolution\n error = llmnrResolve(interface, name, type, ipAddr);\n }\n else\n#endif\n //Invalid protocol?\n {\n //Report an error\n error = ERROR_INVALID_PARAMETER;\n }\n }\n\n //Return status code\n return error;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 3048, "func": "error_t getHostByName(NetInterface *interface,\n const char_t *name, IpAddr *ipAddr, uint_t flags)\n{\n error_t error;\n HostType type;\n HostnameResolver protocol;\n\n //Default address type depends on TCP/IP stack configuration\n#if (IPV4_SUPPORT == ENABLED)\n type = HOST_TYPE_IPV4;\n#elif (IPV6_SUPPORT == ENABLED)\n type = HOST_TYPE_IPV6;\n#else\n type = HOST_TYPE_ANY;\n#endif\n\n //Default name resolution protocol depends on TCP/IP stack configuration\n#if (DNS_CLIENT_SUPPORT == ENABLED)\n protocol = HOST_NAME_RESOLVER_DNS;\n#elif (MDNS_CLIENT_SUPPORT == ENABLED)\n protocol = HOST_NAME_RESOLVER_MDNS;\n#elif (NBNS_CLIENT_SUPPORT == ENABLED)\n protocol = HOST_NAME_RESOLVER_NBNS;\n#elif (LLMNR_CLIENT_SUPPORT == ENABLED)\n protocol = HOST_NAME_RESOLVER_LLMNR;\n#else\n protocol = HOST_NAME_RESOLVER_ANY;\n#endif\n\n //Check parameters\n if(name == NULL || ipAddr == NULL)\n return ERROR_INVALID_PARAMETER;\n\n //Use default network interface?\n if(interface == NULL)\n interface = netGetDefaultInterface();\n\n //The specified name can be either an IP or a host name\n error = ipStringToAddr(name, ipAddr);\n\n //Perform name resolution if necessary\n if(error)\n {\n //The user may provide a hint to choose between IPv4 and IPv6\n if(flags & HOST_TYPE_IPV4)\n type = HOST_TYPE_IPV4;\n else if(flags & HOST_TYPE_IPV6)\n type = HOST_TYPE_IPV6;\n\n //The user may provide a hint to to select the desired protocol to be used\n if(flags & HOST_NAME_RESOLVER_DNS)\n {\n //Use DNS to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_DNS;\n }\n else if(flags & HOST_NAME_RESOLVER_MDNS)\n {\n //Use mDNS to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_MDNS;\n }\n else if(flags & HOST_NAME_RESOLVER_NBNS)\n {\n //Use NBNS to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_NBNS;\n }\n else if(flags & HOST_NAME_RESOLVER_LLMNR)\n {\n //Use LLMNR to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_LLMNR;\n }\n else\n {\n //Retrieve the length of the host name to be resolved\n size_t n = osStrlen(name);\n\n //Select the most suitable protocol\n if(n >= 6 && !osStrcasecmp(name + n - 6, \".local\"))\n {\n#if (MDNS_CLIENT_SUPPORT == ENABLED)\n //Use mDNS to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_MDNS;\n#endif\n }\n else if(n <= 15 && !osStrchr(name, '.') && type == HOST_TYPE_IPV4)\n {\n#if (NBNS_CLIENT_SUPPORT == ENABLED)\n //Use NetBIOS Name Service to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_NBNS;\n#endif\n }\n else if(!osStrchr(name, '.'))\n {\n#if (LLMNR_CLIENT_SUPPORT == ENABLED)\n //Use LLMNR to resolve the specified host name\n protocol = HOST_NAME_RESOLVER_LLMNR;\n#endif\n }\n }\n\n#if (DNS_CLIENT_SUPPORT == ENABLED)\n //Use DNS protocol?\n if(protocol == HOST_NAME_RESOLVER_DNS)\n {\n //Perform host name resolution\n error = dnsResolve(interface, name, type, ipAddr);\n }\n else\n#endif\n#if (MDNS_CLIENT_SUPPORT == ENABLED)\n //Use mDNS protocol?\n if(protocol == HOST_NAME_RESOLVER_MDNS)\n {\n //Perform host name resolution\n error = mdnsClientResolve(interface, name, type, ipAddr);\n }\n else\n#endif\n#if (NBNS_CLIENT_SUPPORT == ENABLED && IPV4_SUPPORT == ENABLED)\n //Use NetBIOS Name Service protocol?\n if(protocol == HOST_NAME_RESOLVER_NBNS)\n {\n //Perform host name resolution\n error = nbnsResolve(interface, name, ipAddr);\n }\n else\n#endif\n#if (LLMNR_CLIENT_SUPPORT == ENABLED)\n //Use LLMNR protocol?\n if(protocol == HOST_NAME_RESOLVER_LLMNR)\n {\n //Perform host name resolution\n error = llmnrResolve(interface, name, type, ipAddr);\n }\n else\n#endif\n //Invalid protocol?\n {\n //Report an error\n error = ERROR_INVALID_PARAMETER;\n }\n }\n\n //Return status code\n return error;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 543, "func": "isis_print_id(const uint8_t *cp, int id_len)\n{\n int i;\n static char id[sizeof(\"xxxx.xxxx.xxxx.yy-zz\")];\n char *pos = id;\n\n for (i = 1; i <= SYSTEM_ID_LEN; i++) {\n snprintf(pos, sizeof(id) - (pos - id), \"%02x\", *cp++);\n\tpos += strlen(pos);\n\tif (i == 2 || i == 4)\n\t *pos++ = '.';\n\t}\n if (id_len >= NODE_ID_LEN) {\n snprintf(pos, sizeof(id) - (pos - id), \".%02x\", *cp++);\n\tpos += strlen(pos);\n }\n if (id_len == LSP_ID_LEN)\n snprintf(pos, sizeof(id) - (pos - id), \"-%02x\", *cp);\n return (id);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13035", "cwe_id": "CWE-125" }, { "id": 543, "func": "isis_print_id(const uint8_t *cp, int id_len)\n{\n int i;\n static char id[sizeof(\"xxxx.xxxx.xxxx.yy-zz\")];\n char *pos = id;\n int sysid_len;\n\n sysid_len = SYSTEM_ID_LEN;\n if (sysid_len > id_len)\n sysid_len = id_len;\n for (i = 1; i <= sysid_len; i++) {\n snprintf(pos, sizeof(id) - (pos - id), \"%02x\", *cp++);\n\tpos += strlen(pos);\n\tif (i == 2 || i == 4)\n\t *pos++ = '.';\n\t}\n if (id_len >= NODE_ID_LEN) {\n snprintf(pos, sizeof(id) - (pos - id), \".%02x\", *cp++);\n\tpos += strlen(pos);\n }\n if (id_len == LSP_ID_LEN)\n snprintf(pos, sizeof(id) - (pos - id), \"-%02x\", *cp);\n return (id);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13035", "cwe_id": "CWE-125" }, { "id": 873, "func": "print_ipcp_config_options(netdissect_options *ndo,\n const u_char *p, int length)\n{\n\tint len, opt;\n u_int compproto, ipcomp_subopttotallen, ipcomp_subopt, ipcomp_suboptlen;\n\n\tif (length < 2)\n\t\treturn 0;\n\tND_TCHECK2(*p, 2);\n\tlen = p[1];\n\topt = p[0];\n\tif (length < len)\n\t\treturn 0;\n\tif (len < 2) {\n\t\tND_PRINT((ndo, \"\\n\\t %s Option (0x%02x), length %u (length bogus, should be >= 2)\",\n\t\t tok2str(ipcpopt_values,\"unknown\",opt),\n\t\t opt,\n\t\t len));\n\t\treturn 0;\n\t}\n\n\tND_PRINT((ndo, \"\\n\\t %s Option (0x%02x), length %u\",\n\t tok2str(ipcpopt_values,\"unknown\",opt),\n\t opt,\n\t len));\n\n\tswitch (opt) {\n\tcase IPCPOPT_2ADDR:\t\t/* deprecated */\n\t\tif (len != 10) {\n\t\t\tND_PRINT((ndo, \" (length bogus, should be = 10)\"));\n\t\t\treturn len;\n\t\t}\n\t\tND_TCHECK2(*(p + 6), 4);\n\t\tND_PRINT((ndo, \": src %s, dst %s\",\n\t\t ipaddr_string(ndo, p + 2),\n\t\t ipaddr_string(ndo, p + 6)));\n\t\tbreak;\n\tcase IPCPOPT_IPCOMP:\n\t\tif (len < 4) {\n\t\t\tND_PRINT((ndo, \" (length bogus, should be >= 4)\"));\n\t\t\treturn 0;\n\t\t}\n\t\tND_TCHECK2(*(p + 2), 2);\n\t\tcompproto = EXTRACT_16BITS(p+2);\n\n\t\tND_PRINT((ndo, \": %s (0x%02x):\",\n\t\t tok2str(ipcpopt_compproto_values, \"Unknown\", compproto),\n\t\t compproto));\n\n\t\tswitch (compproto) {\n case PPP_VJC:\n\t\t\t/* XXX: VJ-Comp parameters should be decoded */\n break;\n case IPCPOPT_IPCOMP_HDRCOMP:\n if (len < IPCPOPT_IPCOMP_MINLEN) {\n \tND_PRINT((ndo, \" (length bogus, should be >= %u)\",\n \t\tIPCPOPT_IPCOMP_MINLEN));\n \treturn 0;\n }\n\n ND_TCHECK2(*(p + 2), IPCPOPT_IPCOMP_MINLEN);\n ND_PRINT((ndo, \"\\n\\t TCP Space %u, non-TCP Space %u\" \\\n \", maxPeriod %u, maxTime %u, maxHdr %u\",\n EXTRACT_16BITS(p+4),\n EXTRACT_16BITS(p+6),\n EXTRACT_16BITS(p+8),\n EXTRACT_16BITS(p+10),\n EXTRACT_16BITS(p+12)));\n\n /* suboptions present ? */\n if (len > IPCPOPT_IPCOMP_MINLEN) {\n ipcomp_subopttotallen = len - IPCPOPT_IPCOMP_MINLEN;\n p += IPCPOPT_IPCOMP_MINLEN;\n\n ND_PRINT((ndo, \"\\n\\t Suboptions, length %u\", ipcomp_subopttotallen));\n\n while (ipcomp_subopttotallen >= 2) {\n ND_TCHECK2(*p, 2);\n ipcomp_subopt = *p;\n ipcomp_suboptlen = *(p+1);\n\n /* sanity check */\n if (ipcomp_subopt == 0 ||\n ipcomp_suboptlen == 0 )\n break;\n\n /* XXX: just display the suboptions for now */\n ND_PRINT((ndo, \"\\n\\t\\t%s Suboption #%u, length %u\",\n tok2str(ipcpopt_compproto_subopt_values,\n \"Unknown\",\n ipcomp_subopt),\n ipcomp_subopt,\n ipcomp_suboptlen));\n\n ipcomp_subopttotallen -= ipcomp_suboptlen;\n p += ipcomp_suboptlen;\n }\n }\n break;\n default:\n break;\n\t\t}\n\t\tbreak;\n\n\tcase IPCPOPT_ADDR: /* those options share the same format - fall through */\n\tcase IPCPOPT_MOBILE4:\n\tcase IPCPOPT_PRIDNS:\n\tcase IPCPOPT_PRINBNS:\n\tcase IPCPOPT_SECDNS:\n\tcase IPCPOPT_SECNBNS:\n\t\tif (len != 6) {\n\t\t\tND_PRINT((ndo, \" (length bogus, should be = 6)\"));\n\t\t\treturn 0;\n\t\t}\n\t\tND_TCHECK2(*(p + 2), 4);\n\t\tND_PRINT((ndo, \": %s\", ipaddr_string(ndo, p + 2)));\n\t\tbreak;\n\tdefault:\n\t\t/*\n\t\t * Unknown option; dump it as raw bytes now if we're\n\t\t * not going to do so below.\n\t\t */\n\t\tif (ndo->ndo_vflag < 2)\n\t\t\tprint_unknown_data(ndo, &p[2], \"\\n\\t \", len - 2);\n\t\tbreak;\n\t}\n\tif (ndo->ndo_vflag > 1)\n\t\tprint_unknown_data(ndo, &p[2], \"\\n\\t \", len - 2); /* exclude TLV header */\n\treturn len;\n\ntrunc:\n\tND_PRINT((ndo, \"[|ipcp]\"));\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13029", "cwe_id": "CWE-125" }, { "id": 873, "func": "print_ipcp_config_options(netdissect_options *ndo,\n const u_char *p, int length)\n{\n\tint len, opt;\n u_int compproto, ipcomp_subopttotallen, ipcomp_subopt, ipcomp_suboptlen;\n\n\tif (length < 2)\n\t\treturn 0;\n\tND_TCHECK2(*p, 2);\n\tlen = p[1];\n\topt = p[0];\n\tif (length < len)\n\t\treturn 0;\n\tif (len < 2) {\n\t\tND_PRINT((ndo, \"\\n\\t %s Option (0x%02x), length %u (length bogus, should be >= 2)\",\n\t\t tok2str(ipcpopt_values,\"unknown\",opt),\n\t\t opt,\n\t\t len));\n\t\treturn 0;\n\t}\n\n\tND_PRINT((ndo, \"\\n\\t %s Option (0x%02x), length %u\",\n\t tok2str(ipcpopt_values,\"unknown\",opt),\n\t opt,\n\t len));\n\n\tswitch (opt) {\n\tcase IPCPOPT_2ADDR:\t\t/* deprecated */\n\t\tif (len != 10) {\n\t\t\tND_PRINT((ndo, \" (length bogus, should be = 10)\"));\n\t\t\treturn len;\n\t\t}\n\t\tND_TCHECK2(*(p + 6), 4);\n\t\tND_PRINT((ndo, \": src %s, dst %s\",\n\t\t ipaddr_string(ndo, p + 2),\n\t\t ipaddr_string(ndo, p + 6)));\n\t\tbreak;\n\tcase IPCPOPT_IPCOMP:\n\t\tif (len < 4) {\n\t\t\tND_PRINT((ndo, \" (length bogus, should be >= 4)\"));\n\t\t\treturn 0;\n\t\t}\n\t\tND_TCHECK_16BITS(p+2);\n\t\tcompproto = EXTRACT_16BITS(p+2);\n\n\t\tND_PRINT((ndo, \": %s (0x%02x):\",\n\t\t tok2str(ipcpopt_compproto_values, \"Unknown\", compproto),\n\t\t compproto));\n\n\t\tswitch (compproto) {\n case PPP_VJC:\n\t\t\t/* XXX: VJ-Comp parameters should be decoded */\n break;\n case IPCPOPT_IPCOMP_HDRCOMP:\n if (len < IPCPOPT_IPCOMP_MINLEN) {\n \tND_PRINT((ndo, \" (length bogus, should be >= %u)\",\n \t\tIPCPOPT_IPCOMP_MINLEN));\n \treturn 0;\n }\n\n ND_TCHECK2(*(p + 2), IPCPOPT_IPCOMP_MINLEN);\n ND_PRINT((ndo, \"\\n\\t TCP Space %u, non-TCP Space %u\" \\\n \", maxPeriod %u, maxTime %u, maxHdr %u\",\n EXTRACT_16BITS(p+4),\n EXTRACT_16BITS(p+6),\n EXTRACT_16BITS(p+8),\n EXTRACT_16BITS(p+10),\n EXTRACT_16BITS(p+12)));\n\n /* suboptions present ? */\n if (len > IPCPOPT_IPCOMP_MINLEN) {\n ipcomp_subopttotallen = len - IPCPOPT_IPCOMP_MINLEN;\n p += IPCPOPT_IPCOMP_MINLEN;\n\n ND_PRINT((ndo, \"\\n\\t Suboptions, length %u\", ipcomp_subopttotallen));\n\n while (ipcomp_subopttotallen >= 2) {\n ND_TCHECK2(*p, 2);\n ipcomp_subopt = *p;\n ipcomp_suboptlen = *(p+1);\n\n /* sanity check */\n if (ipcomp_subopt == 0 ||\n ipcomp_suboptlen == 0 )\n break;\n\n /* XXX: just display the suboptions for now */\n ND_PRINT((ndo, \"\\n\\t\\t%s Suboption #%u, length %u\",\n tok2str(ipcpopt_compproto_subopt_values,\n \"Unknown\",\n ipcomp_subopt),\n ipcomp_subopt,\n ipcomp_suboptlen));\n\n ipcomp_subopttotallen -= ipcomp_suboptlen;\n p += ipcomp_suboptlen;\n }\n }\n break;\n default:\n break;\n\t\t}\n\t\tbreak;\n\n\tcase IPCPOPT_ADDR: /* those options share the same format - fall through */\n\tcase IPCPOPT_MOBILE4:\n\tcase IPCPOPT_PRIDNS:\n\tcase IPCPOPT_PRINBNS:\n\tcase IPCPOPT_SECDNS:\n\tcase IPCPOPT_SECNBNS:\n\t\tif (len != 6) {\n\t\t\tND_PRINT((ndo, \" (length bogus, should be = 6)\"));\n\t\t\treturn 0;\n\t\t}\n\t\tND_TCHECK2(*(p + 2), 4);\n\t\tND_PRINT((ndo, \": %s\", ipaddr_string(ndo, p + 2)));\n\t\tbreak;\n\tdefault:\n\t\t/*\n\t\t * Unknown option; dump it as raw bytes now if we're\n\t\t * not going to do so below.\n\t\t */\n\t\tif (ndo->ndo_vflag < 2)\n\t\t\tprint_unknown_data(ndo, &p[2], \"\\n\\t \", len - 2);\n\t\tbreak;\n\t}\n\tif (ndo->ndo_vflag > 1)\n\t\tprint_unknown_data(ndo, &p[2], \"\\n\\t \", len - 2); /* exclude TLV header */\n\treturn len;\n\ntrunc:\n\tND_PRINT((ndo, \"[|ipcp]\"));\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13029", "cwe_id": "CWE-125" }, { "id": 1713, "func": " */\nstatic void php_wddx_pop_element(void *user_data, const XML_Char *name)\n{\n\tst_entry \t\t\t*ent1, *ent2;\n\twddx_stack \t\t\t*stack = (wddx_stack *)user_data;\n\tHashTable \t\t\t*target_hash;\n\tzend_class_entry \t**pce;\n\tzval\t\t\t\t*obj;\n\tzval\t\t\t\t*tmp;\n\tTSRMLS_FETCH();\n\n/* OBJECTS_FIXME */\n\tif (stack->top == 0) {\n\t\treturn;\n\t}\n\n\tif (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) ||\n\t\t!strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) ||\n\t \t!strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) ||\n\t\t!strcmp(name, EL_RECORDSET) || !strcmp(name, EL_BINARY) ||\n\t\t!strcmp(name, EL_DATETIME)) {\n\t\twddx_stack_top(stack, (void**)&ent1);\n\n\t\tif (!ent1->data) {\n\t\t\tif (stack->top > 1) {\n\t\t\t\tstack->top--;\n\t\t\t\tefree(ent1);\n\t\t\t} else {\n\t\t\t\tstack->done = 1;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (!strcmp(name, EL_BINARY)) {\n\t\t\tint new_len=0;\n\t\t\tunsigned char *new_str;\n\n\t\t\tnew_str = php_base64_decode(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data), &new_len);\n\t\t\tSTR_FREE(Z_STRVAL_P(ent1->data));\n\t\t\tif (new_str) {\n\t\t\t\tZ_STRVAL_P(ent1->data) = new_str;\n\t\t\t\tZ_STRLEN_P(ent1->data) = new_len;\n\t\t\t} else {\n\t\t\t\tZVAL_EMPTY_STRING(ent1->data);\n\t\t\t}\n\t\t}\n\n\t\t/* Call __wakeup() method on the object. */\n\t\tif (Z_TYPE_P(ent1->data) == IS_OBJECT) {\n\t\t\tzval *fname, *retval = NULL;\n\n\t\t\tMAKE_STD_ZVAL(fname);\n\t\t\tZVAL_STRING(fname, \"__wakeup\", 1);\n\n\t\t\tcall_user_function_ex(NULL, &ent1->data, fname, &retval, 0, 0, 0, NULL TSRMLS_CC);\n\n\t\t\tzval_dtor(fname);\n\t\t\tFREE_ZVAL(fname);\n\t\t\tif (retval) {\n\t\t\t\tzval_ptr_dtor(&retval);\n\t\t\t}\n\t\t}\n\n\t\tif (stack->top > 1) {\n\t\t\tstack->top--;\n\t\t\twddx_stack_top(stack, (void**)&ent2);\n\n\t\t\t/* if non-existent field */\n\t\t\tif (ent2->data == NULL) {\n\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\tefree(ent1);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Z_TYPE_P(ent2->data) == IS_ARRAY || Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\ttarget_hash = HASH_OF(ent2->data);\n\n\t\t\t\tif (ent1->varname) {\n\t\t\t\t\tif (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&\n\t\t\t\t\t\tZ_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) &&\n\t\t\t\t\t\tent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) {\n\t\t\t\t\t\tzend_bool incomplete_class = 0;\n\n\t\t\t\t\t\tzend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\tif (zend_hash_find(EG(class_table), Z_STRVAL_P(ent1->data),\n\t\t\t\t\t\t\t\t\t\t Z_STRLEN_P(ent1->data)+1, (void **) &pce)==FAILURE) {\n\t\t\t\t\t\t\tincomplete_class = 1;\n\t\t\t\t\t\t\tpce = &PHP_IC_ENTRY;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/* Initialize target object */\n\t\t\t\t\t\tMAKE_STD_ZVAL(obj);\n\t\t\t\t\t\tobject_init_ex(obj, *pce);\n\n\t\t\t\t\t\t/* Merge current hashtable with object's default properties */\n\t\t\t\t\t\tzend_hash_merge(Z_OBJPROP_P(obj),\n\t\t\t\t\t\t\t\t\t\tZ_ARRVAL_P(ent2->data),\n\t\t\t\t\t\t\t\t\t\t(void (*)(void *)) zval_add_ref,\n\t\t\t\t\t\t\t\t\t\t(void *) &tmp, sizeof(zval *), 0);\n\n\t\t\t\t\t\tif (incomplete_class) {\n\t\t\t\t\t\t\tphp_store_class_name(obj, Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/* Clean up old array entry */\n\t\t\t\t\t\tzval_ptr_dtor(&ent2->data);\n\n\t\t\t\t\t\t/* Set stack entry to point to the newly created object */\n\t\t\t\t\t\tent2->data = obj;\n\n\t\t\t\t\t\t/* Clean up class name var entry */\n\t\t\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\t\t} else if (Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\t\t\tzend_class_entry *old_scope = EG(scope);\n\n\t\t\t\t\t\tEG(scope) = Z_OBJCE_P(ent2->data);\n\t\t\t\t\t\tZ_DELREF_P(ent1->data);\n\t\t\t\t\t\tadd_property_zval(ent2->data, ent1->varname, ent1->data);\n\t\t\t\t\t\tEG(scope) = old_scope;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tzend_symtable_update(target_hash, ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t\t}\n\t\t\t\t\tefree(ent1->varname);\n\t\t\t\t} else\t{\n\t\t\t\t\tzend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t}\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t} else {\n\t\t\tstack->done = 1;\n\t\t}\n\t} else if (!strcmp(name, EL_VAR) && stack->varname) {\n\t\tefree(stack->varname);\n\t\tstack->varname = NULL;\n\t} else if (!strcmp(name, EL_FIELD)) {\n\t\tst_entry *ent;\n\t\twddx_stack_top(stack, (void **)&ent);\n\t\tefree(ent);\n\t\tstack->top--;\n\t}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9934", "cwe_id": "CWE-476" }, { "id": 1713, "func": " */\nstatic void php_wddx_pop_element(void *user_data, const XML_Char *name)\n{\n\tst_entry \t\t\t*ent1, *ent2;\n\twddx_stack \t\t\t*stack = (wddx_stack *)user_data;\n\tHashTable \t\t\t*target_hash;\n\tzend_class_entry \t**pce;\n\tzval\t\t\t\t*obj;\n\tzval\t\t\t\t*tmp;\n\tTSRMLS_FETCH();\n\n/* OBJECTS_FIXME */\n\tif (stack->top == 0) {\n\t\treturn;\n\t}\n\n\tif (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) ||\n\t\t!strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) ||\n\t \t!strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) ||\n\t\t!strcmp(name, EL_RECORDSET) || !strcmp(name, EL_BINARY) ||\n\t\t!strcmp(name, EL_DATETIME)) {\n\t\twddx_stack_top(stack, (void**)&ent1);\n\n\t\tif (!ent1->data) {\n\t\t\tif (stack->top > 1) {\n\t\t\t\tstack->top--;\n\t\t\t\tefree(ent1);\n\t\t\t} else {\n\t\t\t\tstack->done = 1;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (!strcmp(name, EL_BINARY)) {\n\t\t\tint new_len=0;\n\t\t\tunsigned char *new_str;\n\n\t\t\tnew_str = php_base64_decode(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data), &new_len);\n\t\t\tSTR_FREE(Z_STRVAL_P(ent1->data));\n\t\t\tif (new_str) {\n\t\t\t\tZ_STRVAL_P(ent1->data) = new_str;\n\t\t\t\tZ_STRLEN_P(ent1->data) = new_len;\n\t\t\t} else {\n\t\t\t\tZVAL_EMPTY_STRING(ent1->data);\n\t\t\t}\n\t\t}\n\n\t\t/* Call __wakeup() method on the object. */\n\t\tif (Z_TYPE_P(ent1->data) == IS_OBJECT) {\n\t\t\tzval *fname, *retval = NULL;\n\n\t\t\tMAKE_STD_ZVAL(fname);\n\t\t\tZVAL_STRING(fname, \"__wakeup\", 1);\n\n\t\t\tcall_user_function_ex(NULL, &ent1->data, fname, &retval, 0, 0, 0, NULL TSRMLS_CC);\n\n\t\t\tzval_dtor(fname);\n\t\t\tFREE_ZVAL(fname);\n\t\t\tif (retval) {\n\t\t\t\tzval_ptr_dtor(&retval);\n\t\t\t}\n\t\t}\n\n\t\tif (stack->top > 1) {\n\t\t\tstack->top--;\n\t\t\twddx_stack_top(stack, (void**)&ent2);\n\n\t\t\t/* if non-existent field */\n\t\t\tif (ent2->data == NULL) {\n\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\tefree(ent1);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Z_TYPE_P(ent2->data) == IS_ARRAY || Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\ttarget_hash = HASH_OF(ent2->data);\n\n\t\t\t\tif (ent1->varname) {\n\t\t\t\t\tif (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&\n\t\t\t\t\t\tZ_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) &&\n\t\t\t\t\t\tent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) {\n\t\t\t\t\t\tzend_bool incomplete_class = 0;\n\n\t\t\t\t\t\tzend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\tif (zend_hash_find(EG(class_table), Z_STRVAL_P(ent1->data),\n\t\t\t\t\t\t\t\t\t\t Z_STRLEN_P(ent1->data)+1, (void **) &pce)==FAILURE) {\n\t\t\t\t\t\t\tincomplete_class = 1;\n\t\t\t\t\t\t\tpce = &PHP_IC_ENTRY;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (pce != &PHP_IC_ENTRY && ((*pce)->serialize || (*pce)->unserialize)) {\n\t\t\t\t\t\t\tent2->data = NULL;\n\t\t\t\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Class %s can not be unserialized\", Z_STRVAL_P(ent1->data));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t/* Initialize target object */\n\t\t\t\t\t\t\tMAKE_STD_ZVAL(obj);\n\t\t\t\t\t\t\tobject_init_ex(obj, *pce);\n\n\t\t\t\t\t\t\t/* Merge current hashtable with object's default properties */\n\t\t\t\t\t\t\tzend_hash_merge(Z_OBJPROP_P(obj),\n\t\t\t\t\t\t\t\t\t\t\tZ_ARRVAL_P(ent2->data),\n\t\t\t\t\t\t\t\t\t\t\t(void (*)(void *)) zval_add_ref,\n\t\t\t\t\t\t\t\t\t\t\t(void *) &tmp, sizeof(zval *), 0);\n\n\t\t\t\t\t\t\tif (incomplete_class) {\n\t\t\t\t\t\t\t\tphp_store_class_name(obj, Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t/* Clean up old array entry */\n\t\t\t\t\t\t\tzval_ptr_dtor(&ent2->data);\n\n\t\t\t\t\t\t\t/* Set stack entry to point to the newly created object */\n\t\t\t\t\t\t\tent2->data = obj;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t/* Clean up class name var entry */\n\t\t\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\t\t} else if (Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\t\t\tzend_class_entry *old_scope = EG(scope);\n\n\t\t\t\t\t\tEG(scope) = Z_OBJCE_P(ent2->data);\n\t\t\t\t\t\tZ_DELREF_P(ent1->data);\n\t\t\t\t\t\tadd_property_zval(ent2->data, ent1->varname, ent1->data);\n\t\t\t\t\t\tEG(scope) = old_scope;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tzend_symtable_update(target_hash, ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t\t}\n\t\t\t\t\tefree(ent1->varname);\n\t\t\t\t} else\t{\n\t\t\t\t\tzend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t}\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t} else {\n\t\t\tstack->done = 1;\n\t\t}\n\t} else if (!strcmp(name, EL_VAR) && stack->varname) {\n\t\tefree(stack->varname);\n\t\tstack->varname = NULL;\n\t} else if (!strcmp(name, EL_FIELD)) {\n\t\tst_entry *ent;\n\t\twddx_stack_top(stack, (void **)&ent);\n\t\tefree(ent);\n\t\tstack->top--;\n\t}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9934", "cwe_id": "CWE-476" }, { "id": 3125, "func": "static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe,\n\t\t\t\t struct file *out, loff_t *ppos,\n\t\t\t\t size_t len, unsigned int flags)\n{\n\tunsigned nbuf;\n\tunsigned idx;\n\tstruct pipe_buffer *bufs;\n\tstruct fuse_copy_state cs;\n\tstruct fuse_dev *fud;\n\tsize_t rem;\n\tssize_t ret;\n\n\tfud = fuse_get_dev(out);\n\tif (!fud)\n\t\treturn -EPERM;\n\n\tpipe_lock(pipe);\n\n\tbufs = kvmalloc_array(pipe->nrbufs, sizeof(struct pipe_buffer),\n\t\t\t GFP_KERNEL);\n\tif (!bufs) {\n\t\tpipe_unlock(pipe);\n\t\treturn -ENOMEM;\n\t}\n\n\tnbuf = 0;\n\trem = 0;\n\tfor (idx = 0; idx < pipe->nrbufs && rem < len; idx++)\n\t\trem += pipe->bufs[(pipe->curbuf + idx) & (pipe->buffers - 1)].len;\n\n\tret = -EINVAL;\n\tif (rem < len) {\n\t\tpipe_unlock(pipe);\n\t\tgoto out;\n\t}\n\n\trem = len;\n\twhile (rem) {\n\t\tstruct pipe_buffer *ibuf;\n\t\tstruct pipe_buffer *obuf;\n\n\t\tBUG_ON(nbuf >= pipe->buffers);\n\t\tBUG_ON(!pipe->nrbufs);\n\t\tibuf = &pipe->bufs[pipe->curbuf];\n\t\tobuf = &bufs[nbuf];\n\n\t\tif (rem >= ibuf->len) {\n\t\t\t*obuf = *ibuf;\n\t\t\tibuf->ops = NULL;\n\t\t\tpipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);\n\t\t\tpipe->nrbufs--;\n\t\t} else {\n\t\t\tpipe_buf_get(pipe, ibuf);\n\t\t\t*obuf = *ibuf;\n\t\t\tobuf->flags &= ~PIPE_BUF_FLAG_GIFT;\n\t\t\tobuf->len = rem;\n\t\t\tibuf->offset += obuf->len;\n\t\t\tibuf->len -= obuf->len;\n\t\t}\n\t\tnbuf++;\n\t\trem -= obuf->len;\n\t}\n\tpipe_unlock(pipe);\n\n\tfuse_copy_init(&cs, 0, NULL);\n\tcs.pipebufs = bufs;\n\tcs.nr_segs = nbuf;\n\tcs.pipe = pipe;\n\n\tif (flags & SPLICE_F_MOVE)\n\t\tcs.move_pages = 1;\n\n\tret = fuse_dev_do_write(fud, &cs, len);\n\n\tpipe_lock(pipe);\n\tfor (idx = 0; idx < nbuf; idx++)\n\t\tpipe_buf_release(pipe, &bufs[idx]);\n\tpipe_unlock(pipe);\n\nout:\n\tkvfree(bufs);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-11487", "cwe_id": "CWE-416" }, { "id": 3125, "func": "static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe,\n\t\t\t\t struct file *out, loff_t *ppos,\n\t\t\t\t size_t len, unsigned int flags)\n{\n\tunsigned nbuf;\n\tunsigned idx;\n\tstruct pipe_buffer *bufs;\n\tstruct fuse_copy_state cs;\n\tstruct fuse_dev *fud;\n\tsize_t rem;\n\tssize_t ret;\n\n\tfud = fuse_get_dev(out);\n\tif (!fud)\n\t\treturn -EPERM;\n\n\tpipe_lock(pipe);\n\n\tbufs = kvmalloc_array(pipe->nrbufs, sizeof(struct pipe_buffer),\n\t\t\t GFP_KERNEL);\n\tif (!bufs) {\n\t\tpipe_unlock(pipe);\n\t\treturn -ENOMEM;\n\t}\n\n\tnbuf = 0;\n\trem = 0;\n\tfor (idx = 0; idx < pipe->nrbufs && rem < len; idx++)\n\t\trem += pipe->bufs[(pipe->curbuf + idx) & (pipe->buffers - 1)].len;\n\n\tret = -EINVAL;\n\tif (rem < len)\n\t\tgoto out_free;\n\n\trem = len;\n\twhile (rem) {\n\t\tstruct pipe_buffer *ibuf;\n\t\tstruct pipe_buffer *obuf;\n\n\t\tBUG_ON(nbuf >= pipe->buffers);\n\t\tBUG_ON(!pipe->nrbufs);\n\t\tibuf = &pipe->bufs[pipe->curbuf];\n\t\tobuf = &bufs[nbuf];\n\n\t\tif (rem >= ibuf->len) {\n\t\t\t*obuf = *ibuf;\n\t\t\tibuf->ops = NULL;\n\t\t\tpipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);\n\t\t\tpipe->nrbufs--;\n\t\t} else {\n\t\t\tif (!pipe_buf_get(pipe, ibuf))\n\t\t\t\tgoto out_free;\n\n\t\t\t*obuf = *ibuf;\n\t\t\tobuf->flags &= ~PIPE_BUF_FLAG_GIFT;\n\t\t\tobuf->len = rem;\n\t\t\tibuf->offset += obuf->len;\n\t\t\tibuf->len -= obuf->len;\n\t\t}\n\t\tnbuf++;\n\t\trem -= obuf->len;\n\t}\n\tpipe_unlock(pipe);\n\n\tfuse_copy_init(&cs, 0, NULL);\n\tcs.pipebufs = bufs;\n\tcs.nr_segs = nbuf;\n\tcs.pipe = pipe;\n\n\tif (flags & SPLICE_F_MOVE)\n\t\tcs.move_pages = 1;\n\n\tret = fuse_dev_do_write(fud, &cs, len);\n\n\tpipe_lock(pipe);\nout_free:\n\tfor (idx = 0; idx < nbuf; idx++)\n\t\tpipe_buf_release(pipe, &bufs[idx]);\n\tpipe_unlock(pipe);\n\n\tkvfree(bufs);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-11487", "cwe_id": "CWE-416" }, { "id": 1277, "func": "static ssize_t environ_read(struct file *file, char __user *buf,\n\t\t\tsize_t count, loff_t *ppos)\n{\n\tchar *page;\n\tunsigned long src = *ppos;\n\tint ret = 0;\n\tstruct mm_struct *mm = file->private_data;\n\tunsigned long env_start, env_end;\n\n\tif (!mm)\n\t\treturn 0;\n\n\tpage = (char *)__get_free_page(GFP_TEMPORARY);\n\tif (!page)\n\t\treturn -ENOMEM;\n\n\tret = 0;\n\tif (!atomic_inc_not_zero(&mm->mm_users))\n\t\tgoto free;\n\n\tdown_read(&mm->mmap_sem);\n\tenv_start = mm->env_start;\n\tenv_end = mm->env_end;\n\tup_read(&mm->mmap_sem);\n\n\twhile (count > 0) {\n\t\tsize_t this_len, max_len;\n\t\tint retval;\n\n\t\tif (src >= (env_end - env_start))\n\t\t\tbreak;\n\n\t\tthis_len = env_end - (env_start + src);\n\n\t\tmax_len = min_t(size_t, PAGE_SIZE, count);\n\t\tthis_len = min(max_len, this_len);\n\n\t\tretval = access_remote_vm(mm, (env_start + src),\n\t\t\tpage, this_len, 0);\n\n\t\tif (retval <= 0) {\n\t\t\tret = retval;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (copy_to_user(buf, page, retval)) {\n\t\t\tret = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\n\t\tret += retval;\n\t\tsrc += retval;\n\t\tbuf += retval;\n\t\tcount -= retval;\n\t}\n\t*ppos = src;\n\tmmput(mm);\n\nfree:\n\tfree_page((unsigned long) page);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-7916", "cwe_id": "CWE-362" }, { "id": 1277, "func": "static ssize_t environ_read(struct file *file, char __user *buf,\n\t\t\tsize_t count, loff_t *ppos)\n{\n\tchar *page;\n\tunsigned long src = *ppos;\n\tint ret = 0;\n\tstruct mm_struct *mm = file->private_data;\n\tunsigned long env_start, env_end;\n\n\t/* Ensure the process spawned far enough to have an environment. */\n\tif (!mm || !mm->env_end)\n\t\treturn 0;\n\n\tpage = (char *)__get_free_page(GFP_TEMPORARY);\n\tif (!page)\n\t\treturn -ENOMEM;\n\n\tret = 0;\n\tif (!atomic_inc_not_zero(&mm->mm_users))\n\t\tgoto free;\n\n\tdown_read(&mm->mmap_sem);\n\tenv_start = mm->env_start;\n\tenv_end = mm->env_end;\n\tup_read(&mm->mmap_sem);\n\n\twhile (count > 0) {\n\t\tsize_t this_len, max_len;\n\t\tint retval;\n\n\t\tif (src >= (env_end - env_start))\n\t\t\tbreak;\n\n\t\tthis_len = env_end - (env_start + src);\n\n\t\tmax_len = min_t(size_t, PAGE_SIZE, count);\n\t\tthis_len = min(max_len, this_len);\n\n\t\tretval = access_remote_vm(mm, (env_start + src),\n\t\t\tpage, this_len, 0);\n\n\t\tif (retval <= 0) {\n\t\t\tret = retval;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (copy_to_user(buf, page, retval)) {\n\t\t\tret = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\n\t\tret += retval;\n\t\tsrc += retval;\n\t\tbuf += retval;\n\t\tcount -= retval;\n\t}\n\t*ppos = src;\n\tmmput(mm);\n\nfree:\n\tfree_page((unsigned long) page);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-7916", "cwe_id": "CWE-362" }, { "id": 2808, "func": "checked_xcalloc (size_t num, size_t size)\n{\n alloc_limit_assert (\"checked_xcalloc\", (num *size));\n return xcalloc (num, size);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-6308", "cwe_id": "CWE-190" }, { "id": 2808, "func": "checked_xcalloc (size_t num, size_t size)\n{\n size_t res;\n if (check_mul_overflow(num, size, &res))\n abort();\n\n alloc_limit_assert (\"checked_xcalloc\", (res));\n return xcalloc (num, size);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-6308", "cwe_id": "CWE-190" }, { "id": 1492, "func": "static size_t optsize (lua_State *L, char opt, const char **fmt) {\n switch (opt) {\n case 'B': case 'b': return sizeof(char);\n case 'H': case 'h': return sizeof(short);\n case 'L': case 'l': return sizeof(long);\n case 'T': return sizeof(size_t);\n case 'f': return sizeof(float);\n case 'd': return sizeof(double);\n case 'x': return 1;\n case 'c': return getnum(L, fmt, 1);\n case 'i': case 'I': {\n int sz = getnum(L, fmt, sizeof(int));\n if (sz > MAXINTSIZE)\n luaL_error(L, \"integral size %d is larger than limit of %d\",\n sz, MAXINTSIZE);\n return sz;\n }\n default: return 0; /* other cases do not need alignment */\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-11219", "cwe_id": "CWE-190" }, { "id": 1492, "func": "static size_t optsize (lua_State *L, char opt, const char **fmt) {\n switch (opt) {\n case 'B': case 'b': return sizeof(char);\n case 'H': case 'h': return sizeof(short);\n case 'L': case 'l': return sizeof(long);\n case 'T': return sizeof(size_t);\n case 'f': return sizeof(float);\n case 'd': return sizeof(double);\n case 'x': return 1;\n case 'c': return getnum(fmt, 1);\n case 'i': case 'I': {\n int sz = getnum(fmt, sizeof(int));\n if (sz > MAXINTSIZE)\n luaL_error(L, \"integral size %d is larger than limit of %d\",\n sz, MAXINTSIZE);\n return sz;\n }\n default: return 0; /* other cases do not need alignment */\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-11219", "cwe_id": "CWE-190" }, { "id": 2731, "func": "static int update_write_order_info(rdpContext* context, wStream* s, ORDER_INFO* orderInfo,\n size_t offset)\n{\n\tsize_t position;\n\tWINPR_UNUSED(context);\n\tposition = Stream_GetPosition(s);\n\tStream_SetPosition(s, offset);\n\tStream_Write_UINT8(s, orderInfo->controlFlags); /* controlFlags (1 byte) */\n\n\tif (orderInfo->controlFlags & ORDER_TYPE_CHANGE)\n\t\tStream_Write_UINT8(s, orderInfo->orderType); /* orderType (1 byte) */\n\n\tupdate_write_field_flags(s, orderInfo->fieldFlags, orderInfo->controlFlags,\n\t PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo->orderType]);\n\tupdate_write_bounds(s, orderInfo);\n\tStream_SetPosition(s, position);\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-11095", "cwe_id": "CWE-125" }, { "id": 2731, "func": "static int update_write_order_info(rdpContext* context, wStream* s, ORDER_INFO* orderInfo,\n size_t offset)\n{\n\tsize_t position;\n\tWINPR_UNUSED(context);\n\tposition = Stream_GetPosition(s);\n\tStream_SetPosition(s, offset);\n\tStream_Write_UINT8(s, orderInfo->controlFlags); /* controlFlags (1 byte) */\n\n\tif (orderInfo->controlFlags & ORDER_TYPE_CHANGE)\n\t\tStream_Write_UINT8(s, orderInfo->orderType); /* orderType (1 byte) */\n\n\tupdate_write_field_flags(s, orderInfo->fieldFlags, orderInfo->controlFlags,\n\t get_primary_drawing_order_field_bytes(orderInfo->orderType, NULL));\n\tupdate_write_bounds(s, orderInfo);\n\tStream_SetPosition(s, position);\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-11095", "cwe_id": "CWE-125" }, { "id": 1623, "func": "get_matching_data(krb5_context context,\n pkinit_plg_crypto_context plg_cryptoctx,\n pkinit_req_crypto_context req_cryptoctx, X509 *cert,\n pkinit_cert_matching_data **md_out)\n{\n krb5_error_code ret = ENOMEM;\n pkinit_cert_matching_data *md = NULL;\n krb5_principal *pkinit_sans = NULL, *upn_sans = NULL;\n size_t i, j;\n char buf[DN_BUF_LEN];\n unsigned int bufsize = sizeof(buf);\n\n *md_out = NULL;\n\n md = calloc(1, sizeof(*md));\n if (md == NULL)\n goto cleanup;\n\n /* Get the subject name (in rfc2253 format). */\n X509_NAME_oneline_ex(X509_get_subject_name(cert), buf, &bufsize,\n XN_FLAG_SEP_COMMA_PLUS);\n md->subject_dn = strdup(buf);\n if (md->subject_dn == NULL) {\n ret = ENOMEM;\n goto cleanup;\n }\n\n /* Get the issuer name (in rfc2253 format). */\n X509_NAME_oneline_ex(X509_get_issuer_name(cert), buf, &bufsize,\n XN_FLAG_SEP_COMMA_PLUS);\n md->issuer_dn = strdup(buf);\n if (md->issuer_dn == NULL) {\n ret = ENOMEM;\n goto cleanup;\n }\n\n /* Get the SAN data. */\n ret = crypto_retrieve_X509_sans(context, plg_cryptoctx, req_cryptoctx,\n cert, &pkinit_sans, &upn_sans, NULL);\n if (ret)\n goto cleanup;\n\n j = 0;\n if (pkinit_sans != NULL) {\n for (i = 0; pkinit_sans[i] != NULL; i++)\n j++;\n }\n if (upn_sans != NULL) {\n for (i = 0; upn_sans[i] != NULL; i++)\n j++;\n }\n if (j != 0) {\n md->sans = calloc((size_t)j+1, sizeof(*md->sans));\n if (md->sans == NULL) {\n ret = ENOMEM;\n goto cleanup;\n }\n j = 0;\n if (pkinit_sans != NULL) {\n for (i = 0; pkinit_sans[i] != NULL; i++)\n md->sans[j++] = pkinit_sans[i];\n free(pkinit_sans);\n }\n if (upn_sans != NULL) {\n for (i = 0; upn_sans[i] != NULL; i++)\n md->sans[j++] = upn_sans[i];\n free(upn_sans);\n }\n md->sans[j] = NULL;\n } else\n md->sans = NULL;\n\n /* Get the KU and EKU data. */\n ret = crypto_retrieve_X509_key_usage(context, plg_cryptoctx,\n req_cryptoctx, cert, &md->ku_bits,\n &md->eku_bits);\n if (ret)\n goto cleanup;\n\n *md_out = md;\n md = NULL;\n\ncleanup:\n crypto_cert_free_matching_data(context, md);\n return ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-15088", "cwe_id": "CWE-119" }, { "id": 1623, "func": "get_matching_data(krb5_context context,\n pkinit_plg_crypto_context plg_cryptoctx,\n pkinit_req_crypto_context req_cryptoctx, X509 *cert,\n pkinit_cert_matching_data **md_out)\n{\n krb5_error_code ret = ENOMEM;\n pkinit_cert_matching_data *md = NULL;\n krb5_principal *pkinit_sans = NULL, *upn_sans = NULL;\n size_t i, j;\n\n *md_out = NULL;\n\n md = calloc(1, sizeof(*md));\n if (md == NULL)\n goto cleanup;\n\n ret = rfc2253_name(X509_get_subject_name(cert), &md->subject_dn);\n if (ret)\n goto cleanup;\n ret = rfc2253_name(X509_get_issuer_name(cert), &md->issuer_dn);\n if (ret)\n goto cleanup;\n\n /* Get the SAN data. */\n ret = crypto_retrieve_X509_sans(context, plg_cryptoctx, req_cryptoctx,\n cert, &pkinit_sans, &upn_sans, NULL);\n if (ret)\n goto cleanup;\n\n j = 0;\n if (pkinit_sans != NULL) {\n for (i = 0; pkinit_sans[i] != NULL; i++)\n j++;\n }\n if (upn_sans != NULL) {\n for (i = 0; upn_sans[i] != NULL; i++)\n j++;\n }\n if (j != 0) {\n md->sans = calloc((size_t)j+1, sizeof(*md->sans));\n if (md->sans == NULL) {\n ret = ENOMEM;\n goto cleanup;\n }\n j = 0;\n if (pkinit_sans != NULL) {\n for (i = 0; pkinit_sans[i] != NULL; i++)\n md->sans[j++] = pkinit_sans[i];\n free(pkinit_sans);\n }\n if (upn_sans != NULL) {\n for (i = 0; upn_sans[i] != NULL; i++)\n md->sans[j++] = upn_sans[i];\n free(upn_sans);\n }\n md->sans[j] = NULL;\n } else\n md->sans = NULL;\n\n /* Get the KU and EKU data. */\n ret = crypto_retrieve_X509_key_usage(context, plg_cryptoctx,\n req_cryptoctx, cert, &md->ku_bits,\n &md->eku_bits);\n if (ret)\n goto cleanup;\n\n *md_out = md;\n md = NULL;\n\ncleanup:\n crypto_cert_free_matching_data(context, md);\n return ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-15088", "cwe_id": "CWE-119" }, { "id": 1091, "func": "builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,\n const char *mode, int flags, int dont_inherit,\n int optimize)\n/*[clinic end generated code: output=1fa176e33452bb63 input=0ff726f595eb9fcd]*/\n{\n PyObject *source_copy;\n const char *str;\n int compile_mode = -1;\n int is_ast;\n PyCompilerFlags cf;\n int start[] = {Py_file_input, Py_eval_input, Py_single_input};\n PyObject *result;\n\n cf.cf_flags = flags | PyCF_SOURCE_IS_UTF8;\n\n if (flags &\n ~(PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_DONT_IMPLY_DEDENT | PyCF_ONLY_AST))\n {\n PyErr_SetString(PyExc_ValueError,\n \"compile(): unrecognised flags\");\n goto error;\n }\n /* XXX Warn if (supplied_flags & PyCF_MASK_OBSOLETE) != 0? */\n\n if (optimize < -1 || optimize > 2) {\n PyErr_SetString(PyExc_ValueError,\n \"compile(): invalid optimize value\");\n goto error;\n }\n\n if (!dont_inherit) {\n PyEval_MergeCompilerFlags(&cf);\n }\n\n if (strcmp(mode, \"exec\") == 0)\n compile_mode = 0;\n else if (strcmp(mode, \"eval\") == 0)\n compile_mode = 1;\n else if (strcmp(mode, \"single\") == 0)\n compile_mode = 2;\n else {\n PyErr_SetString(PyExc_ValueError,\n \"compile() mode must be 'exec', 'eval' or 'single'\");\n goto error;\n }\n\n is_ast = PyAST_Check(source);\n if (is_ast == -1)\n goto error;\n if (is_ast) {\n if (flags & PyCF_ONLY_AST) {\n Py_INCREF(source);\n result = source;\n }\n else {\n PyArena *arena;\n mod_ty mod;\n\n arena = PyArena_New();\n if (arena == NULL)\n goto error;\n mod = PyAST_obj2mod(source, arena, compile_mode);\n if (mod == NULL) {\n PyArena_Free(arena);\n goto error;\n }\n if (!PyAST_Validate(mod)) {\n PyArena_Free(arena);\n goto error;\n }\n result = (PyObject*)PyAST_CompileObject(mod, filename,\n &cf, optimize, arena);\n PyArena_Free(arena);\n }\n goto finally;\n }\n\n str = source_as_string(source, \"compile\", \"string, bytes or AST\", &cf, &source_copy);\n if (str == NULL)\n goto error;\n\n result = Py_CompileStringObject(str, filename, start[compile_mode], &cf, optimize);\n Py_XDECREF(source_copy);\n goto finally;\n\nerror:\n result = NULL;\nfinally:\n Py_DECREF(filename);\n return result;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1091, "func": "builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,\n const char *mode, int flags, int dont_inherit,\n int optimize)\n/*[clinic end generated code: output=1fa176e33452bb63 input=0ff726f595eb9fcd]*/\n{\n PyObject *source_copy;\n const char *str;\n int compile_mode = -1;\n int is_ast;\n PyCompilerFlags cf;\n int start[] = {Py_file_input, Py_eval_input, Py_single_input, Py_func_type_input};\n PyObject *result;\n\n cf.cf_flags = flags | PyCF_SOURCE_IS_UTF8;\n\n if (flags &\n ~(PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_DONT_IMPLY_DEDENT | PyCF_ONLY_AST | PyCF_TYPE_COMMENTS))\n {\n PyErr_SetString(PyExc_ValueError,\n \"compile(): unrecognised flags\");\n goto error;\n }\n /* XXX Warn if (supplied_flags & PyCF_MASK_OBSOLETE) != 0? */\n\n if (optimize < -1 || optimize > 2) {\n PyErr_SetString(PyExc_ValueError,\n \"compile(): invalid optimize value\");\n goto error;\n }\n\n if (!dont_inherit) {\n PyEval_MergeCompilerFlags(&cf);\n }\n\n if (strcmp(mode, \"exec\") == 0)\n compile_mode = 0;\n else if (strcmp(mode, \"eval\") == 0)\n compile_mode = 1;\n else if (strcmp(mode, \"single\") == 0)\n compile_mode = 2;\n else if (strcmp(mode, \"func_type\") == 0) {\n if (!(flags & PyCF_ONLY_AST)) {\n PyErr_SetString(PyExc_ValueError,\n \"compile() mode 'func_type' requires flag PyCF_ONLY_AST\");\n goto error;\n }\n compile_mode = 3;\n }\n else {\n const char *msg;\n if (flags & PyCF_ONLY_AST)\n msg = \"compile() mode must be 'exec', 'eval', 'single' or 'func_type'\";\n else\n msg = \"compile() mode must be 'exec', 'eval' or 'single'\";\n PyErr_SetString(PyExc_ValueError, msg);\n goto error;\n }\n\n is_ast = PyAST_Check(source);\n if (is_ast == -1)\n goto error;\n if (is_ast) {\n if (flags & PyCF_ONLY_AST) {\n Py_INCREF(source);\n result = source;\n }\n else {\n PyArena *arena;\n mod_ty mod;\n\n arena = PyArena_New();\n if (arena == NULL)\n goto error;\n mod = PyAST_obj2mod(source, arena, compile_mode);\n if (mod == NULL) {\n PyArena_Free(arena);\n goto error;\n }\n if (!PyAST_Validate(mod)) {\n PyArena_Free(arena);\n goto error;\n }\n result = (PyObject*)PyAST_CompileObject(mod, filename,\n &cf, optimize, arena);\n PyArena_Free(arena);\n }\n goto finally;\n }\n\n str = source_as_string(source, \"compile\", \"string, bytes or AST\", &cf, &source_copy);\n if (str == NULL)\n goto error;\n\n result = Py_CompileStringObject(str, filename, start[compile_mode], &cf, optimize);\n Py_XDECREF(source_copy);\n goto finally;\n\nerror:\n result = NULL;\nfinally:\n Py_DECREF(filename);\n return result;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1293, "func": " void Compute(OpKernelContext* context) override {\n const Tensor& diagonal = context->input(0);\n\n // MatrixDiag and MatrixDiagV2 both use this OpKernel. MatrixDiag only has\n // one input, so we have to check the number of inputs before reading\n // additional parameters in MatrixDiagV2.\n int32 lower_diag_index = 0;\n int32 upper_diag_index = 0;\n int32 num_rows = -1;\n int32 num_cols = -1;\n T padding_value(0);\n\n // MatrixDiagOpV2-specific.\n if (context->num_inputs() > kNumV1Inputs) {\n auto& diag_index = context->input(1);\n OP_REQUIRES(context,\n TensorShapeUtils::IsScalar(diag_index.shape()) ||\n TensorShapeUtils::IsVector(diag_index.shape()),\n errors::InvalidArgument(\n \"diag_index must be a scalar or vector, received shape: \",\n diag_index.shape().DebugString()));\n lower_diag_index = diag_index.flat()(0);\n upper_diag_index = lower_diag_index;\n if (TensorShapeUtils::IsVector(diag_index.shape())) {\n auto diag_index_size = diag_index.dim_size(0);\n OP_REQUIRES(\n context, 0 < diag_index_size && diag_index_size <= 2,\n errors::InvalidArgument(\n \"diag_index must have only one or two elements, received \",\n diag_index_size, \" elements.\"));\n if (diag_index_size > 1) {\n upper_diag_index = diag_index.flat()(1);\n }\n }\n num_rows = context->input(2).flat()(0);\n num_cols = context->input(3).flat()(0);\n padding_value = context->input(4).flat()(0);\n }\n\n // Size validations.\n const TensorShape& diagonal_shape = diagonal.shape();\n const int diag_rank = diagonal_shape.dims();\n const Eigen::Index num_diags = upper_diag_index - lower_diag_index + 1;\n OP_REQUIRES(context, TensorShapeUtils::IsVectorOrHigher(diagonal_shape),\n errors::InvalidArgument(\n \"diagonal must be at least 1-dim, received shape: \",\n diagonal.shape().DebugString()));\n OP_REQUIRES(\n context, lower_diag_index <= upper_diag_index,\n errors::InvalidArgument(\n \"lower_diag_index must not be larger than upper_diag_index: \",\n lower_diag_index, \" > \", upper_diag_index));\n OP_REQUIRES(context,\n lower_diag_index == upper_diag_index ||\n diagonal_shape.dim_size(diag_rank - 2) == num_diags,\n errors::InvalidArgument(\n \"The number of diagonals provided in the input does not \"\n \"match the lower_diag_index and upper_diag_index range.\"));\n\n const Eigen::Index max_diag_len = diagonal_shape.dim_size(diag_rank - 1);\n const int32 min_num_rows = max_diag_len - std::min(upper_diag_index, 0);\n const int32 min_num_cols = max_diag_len + std::max(lower_diag_index, 0);\n OP_REQUIRES(context, num_rows == -1 || num_rows >= min_num_rows,\n errors::InvalidArgument(\"The number of rows is too small.\"));\n OP_REQUIRES(context, num_cols == -1 || num_cols >= min_num_cols,\n errors::InvalidArgument(\"The number of columns is too small.\"));\n\n // If both num_rows and num_cols are unknown, assume that output is square.\n // Otherwise, use smallest possible values.\n if (num_rows == -1 && num_cols == -1) {\n num_rows = std::max(min_num_rows, min_num_cols);\n num_cols = num_rows;\n } else if (num_rows == -1) {\n num_rows = min_num_rows;\n } else if (num_cols == -1) {\n num_cols = min_num_cols;\n }\n OP_REQUIRES(context, num_rows == min_num_rows || num_cols == min_num_cols,\n errors::InvalidArgument(\n \"The number of rows or columns is not consistent with \"\n \"the specified d_lower, d_upper, and diagonal.\"));\n\n TensorShape output_shape = diagonal_shape;\n if (num_diags == 1) { // Output has rank `rank+1`.\n output_shape.set_dim(diag_rank - 1, num_rows);\n output_shape.AddDim(num_cols);\n } else { // Output has rank `rank`.\n output_shape.set_dim(diag_rank - 2, num_rows);\n output_shape.set_dim(diag_rank - 1, num_cols);\n }\n\n Tensor* output = nullptr;\n OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output));\n auto output_reshaped = output->flat_inner_dims();\n auto diag_reshaped = diagonal.flat();\n functor::MatrixDiag::Compute(\n context, context->eigen_device(), diag_reshaped,\n output_reshaped, lower_diag_index, upper_diag_index, max_diag_len,\n padding_value, left_align_superdiagonal_, left_align_subdiagonal_);\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-29515", "cwe_id": "CWE-476" }, { "id": 1293, "func": " void Compute(OpKernelContext* context) override {\n const Tensor& diagonal = context->input(0);\n\n // MatrixDiag and MatrixDiagV2 both use this OpKernel. MatrixDiag only has\n // one input, so we have to check the number of inputs before reading\n // additional parameters in MatrixDiagV2.\n int32 lower_diag_index = 0;\n int32 upper_diag_index = 0;\n int32 num_rows = -1;\n int32 num_cols = -1;\n T padding_value(0);\n\n // MatrixDiagOpV2-specific.\n if (context->num_inputs() > kNumV1Inputs) {\n auto& diag_index = context->input(1);\n OP_REQUIRES(context,\n TensorShapeUtils::IsScalar(diag_index.shape()) ||\n TensorShapeUtils::IsVector(diag_index.shape()),\n errors::InvalidArgument(\n \"diag_index must be a scalar or vector, received shape: \",\n diag_index.shape().DebugString()));\n lower_diag_index = diag_index.flat()(0);\n upper_diag_index = lower_diag_index;\n if (TensorShapeUtils::IsVector(diag_index.shape())) {\n auto diag_index_size = diag_index.dim_size(0);\n OP_REQUIRES(\n context, 0 < diag_index_size && diag_index_size <= 2,\n errors::InvalidArgument(\n \"diag_index must have only one or two elements, received \",\n diag_index_size, \" elements.\"));\n if (diag_index_size > 1) {\n upper_diag_index = diag_index.flat()(1);\n }\n }\n\n auto& num_rows_tensor = context->input(2);\n OP_REQUIRES(context, TensorShapeUtils::IsScalar(num_rows_tensor.shape()),\n errors::InvalidArgument(\"num_rows must be a scalar\"));\n num_rows = num_rows_tensor.flat()(0);\n\n auto& num_cols_tensor = context->input(3);\n OP_REQUIRES(context, TensorShapeUtils::IsScalar(num_cols_tensor.shape()),\n errors::InvalidArgument(\"num_cols must be a scalar\"));\n num_cols = num_cols_tensor.flat()(0);\n\n auto& padding_value_tensor = context->input(4);\n OP_REQUIRES(context,\n TensorShapeUtils::IsScalar(padding_value_tensor.shape()),\n errors::InvalidArgument(\"padding_value must be a scalar\"));\n padding_value = padding_value_tensor.flat()(0);\n }\n\n // Size validations.\n const TensorShape& diagonal_shape = diagonal.shape();\n const int diag_rank = diagonal_shape.dims();\n const Eigen::Index num_diags = upper_diag_index - lower_diag_index + 1;\n OP_REQUIRES(context, TensorShapeUtils::IsVectorOrHigher(diagonal_shape),\n errors::InvalidArgument(\n \"diagonal must be at least 1-dim, received shape: \",\n diagonal.shape().DebugString()));\n OP_REQUIRES(\n context, lower_diag_index <= upper_diag_index,\n errors::InvalidArgument(\n \"lower_diag_index must not be larger than upper_diag_index: \",\n lower_diag_index, \" > \", upper_diag_index));\n OP_REQUIRES(context,\n lower_diag_index == upper_diag_index ||\n diagonal_shape.dim_size(diag_rank - 2) == num_diags,\n errors::InvalidArgument(\n \"The number of diagonals provided in the input does not \"\n \"match the lower_diag_index and upper_diag_index range.\"));\n\n const Eigen::Index max_diag_len = diagonal_shape.dim_size(diag_rank - 1);\n const int32 min_num_rows = max_diag_len - std::min(upper_diag_index, 0);\n const int32 min_num_cols = max_diag_len + std::max(lower_diag_index, 0);\n OP_REQUIRES(context, num_rows == -1 || num_rows >= min_num_rows,\n errors::InvalidArgument(\"The number of rows is too small.\"));\n OP_REQUIRES(context, num_cols == -1 || num_cols >= min_num_cols,\n errors::InvalidArgument(\"The number of columns is too small.\"));\n\n // If both num_rows and num_cols are unknown, assume that output is square.\n // Otherwise, use smallest possible values.\n if (num_rows == -1 && num_cols == -1) {\n num_rows = std::max(min_num_rows, min_num_cols);\n num_cols = num_rows;\n } else if (num_rows == -1) {\n num_rows = min_num_rows;\n } else if (num_cols == -1) {\n num_cols = min_num_cols;\n }\n OP_REQUIRES(context, num_rows == min_num_rows || num_cols == min_num_cols,\n errors::InvalidArgument(\n \"The number of rows or columns is not consistent with \"\n \"the specified d_lower, d_upper, and diagonal.\"));\n\n TensorShape output_shape = diagonal_shape;\n if (num_diags == 1) { // Output has rank `rank+1`.\n output_shape.set_dim(diag_rank - 1, num_rows);\n output_shape.AddDim(num_cols);\n } else { // Output has rank `rank`.\n output_shape.set_dim(diag_rank - 2, num_rows);\n output_shape.set_dim(diag_rank - 1, num_cols);\n }\n\n Tensor* output = nullptr;\n OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output));\n auto output_reshaped = output->flat_inner_dims();\n auto diag_reshaped = diagonal.flat();\n functor::MatrixDiag::Compute(\n context, context->eigen_device(), diag_reshaped,\n output_reshaped, lower_diag_index, upper_diag_index, max_diag_len,\n padding_value, left_align_superdiagonal_, left_align_subdiagonal_);\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-29515", "cwe_id": "CWE-476" }, { "id": 1924, "func": " void Compute(OpKernelContext* context) override {\n const Tensor* input_indices;\n const Tensor* input_values;\n const Tensor* input_shape;\n SparseTensorsMap* map;\n\n OP_REQUIRES_OK(context, context->input(\"sparse_indices\", &input_indices));\n OP_REQUIRES_OK(context, context->input(\"sparse_values\", &input_values));\n OP_REQUIRES_OK(context, context->input(\"sparse_shape\", &input_shape));\n OP_REQUIRES_OK(context, GetMap(context, true /* is_writing */, &map));\n\n OP_REQUIRES(context, TensorShapeUtils::IsMatrix(input_indices->shape()),\n errors::InvalidArgument(\n \"Input indices should be a matrix but received shape \",\n input_indices->shape().DebugString()));\n OP_REQUIRES(context, TensorShapeUtils::IsVector(input_values->shape()),\n errors::InvalidArgument(\n \"Input values should be a vector but received shape \",\n input_values->shape().DebugString()));\n OP_REQUIRES(context, TensorShapeUtils::IsVector(input_shape->shape()),\n errors::InvalidArgument(\n \"Input shape should be a vector but received shape \",\n input_shape->shape().DebugString()));\n OP_REQUIRES(\n context,\n input_values->shape().dim_size(0) == input_indices->shape().dim_size(0),\n errors::InvalidArgument(\n \"Number of values must match first dimension of indices. \", \"Got \",\n input_values->shape().dim_size(0),\n \" values, indices shape: \", input_indices->shape().DebugString()));\n OP_REQUIRES(\n context,\n input_shape->shape().dim_size(0) == input_indices->shape().dim_size(1),\n errors::InvalidArgument(\n \"Number of dimensions must match second dimension of indices. \",\n \"Got \", input_shape->shape().dim_size(0),\n \" dimensions, indices shape: \",\n input_indices->shape().DebugString()));\n\n int rank = input_shape->NumElements();\n\n OP_REQUIRES(\n context, rank > 1,\n errors::InvalidArgument(\n \"Rank of input SparseTensor should be > 1, but saw rank: \", rank));\n\n auto input_shape_vec = input_shape->vec();\n int new_num_elements = 1;\n bool overflow_ocurred = false;\n for (int i = 0; i < input_shape_vec.size(); i++) {\n new_num_elements =\n MultiplyWithoutOverflow(new_num_elements, input_shape_vec(i));\n if (new_num_elements < 0) {\n overflow_ocurred = true;\n break;\n }\n }\n\n OP_REQUIRES(\n context, !overflow_ocurred,\n errors::Internal(\"Encountered overflow from large input shape.\"));\n\n TensorShape tensor_input_shape(input_shape_vec);\n gtl::InlinedVector std_order(rank);\n std::iota(std_order.begin(), std_order.end(), 0);\n SparseTensor input_st;\n OP_REQUIRES_OK(context, SparseTensor::Create(*input_indices, *input_values,\n tensor_input_shape, std_order,\n &input_st));\n\n const int64_t N = input_shape_vec(0);\n\n Tensor sparse_handles(DT_INT64, TensorShape({N}));\n auto sparse_handles_t = sparse_handles.vec();\n\n OP_REQUIRES_OK(context, input_st.IndicesValid());\n\n // We can generate the output shape proto string now, for all\n // minibatch entries.\n TensorShape output_shape;\n OP_REQUIRES_OK(context, TensorShapeUtils::MakeShape(\n input_shape_vec.data() + 1,\n input_shape->NumElements() - 1, &output_shape));\n\n // Get groups by minibatch dimension\n std::unordered_set visited;\n sparse::GroupIterable minibatch = input_st.group({0});\n for (const auto& subset : minibatch) {\n const int64_t b = subset.group()[0];\n visited.insert(b);\n OP_REQUIRES(\n context, b > -1 && b < N,\n errors::InvalidArgument(\n \"Received unexpected column 0 value in input SparseTensor: \", b,\n \" < 0 or >= N (= \", N, \")\"));\n\n const auto indices = subset.indices();\n const auto values = subset.values();\n const int64_t num_entries = values.size();\n\n Tensor output_indices = Tensor(DT_INT64, {num_entries, rank - 1});\n Tensor output_values = Tensor(DataTypeToEnum::value, {num_entries});\n\n auto output_indices_t = output_indices.matrix();\n auto output_values_t = output_values.vec();\n\n for (int i = 0; i < num_entries; ++i) {\n for (int d = 1; d < rank; ++d) {\n output_indices_t(i, d - 1) = indices(i, d);\n }\n output_values_t(i) = values(i);\n }\n\n SparseTensor st_i;\n OP_REQUIRES_OK(context,\n SparseTensor::Create(output_indices, output_values,\n output_shape, &st_i));\n int64_t handle;\n OP_REQUIRES_OK(context, map->AddSparseTensor(context, st_i, &handle));\n sparse_handles_t(b) = handle;\n }\n\n // Fill in any gaps; we must provide an empty ST for batch entries\n // the grouper didn't find.\n if (visited.size() < N) {\n Tensor empty_indices(DT_INT64, {0, rank - 1});\n Tensor empty_values(DataTypeToEnum::value, {0});\n SparseTensor empty_st;\n OP_REQUIRES_OK(context, SparseTensor::Create(empty_indices, empty_values,\n output_shape, &empty_st));\n\n for (int64_t b = 0; b < N; ++b) {\n // We skipped this batch entry.\n if (visited.find(b) == visited.end()) {\n int64_t handle;\n OP_REQUIRES_OK(context,\n map->AddSparseTensor(context, empty_st, &handle));\n sparse_handles_t(b) = handle;\n }\n }\n }\n\n context->set_output(0, sparse_handles);\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-23568", "cwe_id": "CWE-190" }, { "id": 1924, "func": " void Compute(OpKernelContext* context) override {\n const Tensor* input_indices;\n const Tensor* input_values;\n const Tensor* input_shape;\n SparseTensorsMap* map;\n\n OP_REQUIRES_OK(context, context->input(\"sparse_indices\", &input_indices));\n OP_REQUIRES_OK(context, context->input(\"sparse_values\", &input_values));\n OP_REQUIRES_OK(context, context->input(\"sparse_shape\", &input_shape));\n OP_REQUIRES_OK(context, GetMap(context, true /* is_writing */, &map));\n\n OP_REQUIRES(context, TensorShapeUtils::IsMatrix(input_indices->shape()),\n errors::InvalidArgument(\n \"Input indices should be a matrix but received shape \",\n input_indices->shape().DebugString()));\n OP_REQUIRES(context, TensorShapeUtils::IsVector(input_values->shape()),\n errors::InvalidArgument(\n \"Input values should be a vector but received shape \",\n input_values->shape().DebugString()));\n OP_REQUIRES(context, TensorShapeUtils::IsVector(input_shape->shape()),\n errors::InvalidArgument(\n \"Input shape should be a vector but received shape \",\n input_shape->shape().DebugString()));\n OP_REQUIRES(\n context,\n input_values->shape().dim_size(0) == input_indices->shape().dim_size(0),\n errors::InvalidArgument(\n \"Number of values must match first dimension of indices. \", \"Got \",\n input_values->shape().dim_size(0),\n \" values, indices shape: \", input_indices->shape().DebugString()));\n OP_REQUIRES(\n context,\n input_shape->shape().dim_size(0) == input_indices->shape().dim_size(1),\n errors::InvalidArgument(\n \"Number of dimensions must match second dimension of indices. \",\n \"Got \", input_shape->shape().dim_size(0),\n \" dimensions, indices shape: \",\n input_indices->shape().DebugString()));\n\n int rank = input_shape->NumElements();\n\n OP_REQUIRES(\n context, rank > 1,\n errors::InvalidArgument(\n \"Rank of input SparseTensor should be > 1, but saw rank: \", rank));\n\n auto input_shape_vec = input_shape->vec();\n\n TensorShape tensor_input_shape;\n OP_REQUIRES_OK(context, TensorShape::BuildTensorShape(input_shape_vec,\n &tensor_input_shape));\n gtl::InlinedVector std_order(rank);\n std::iota(std_order.begin(), std_order.end(), 0);\n SparseTensor input_st;\n OP_REQUIRES_OK(context, SparseTensor::Create(*input_indices, *input_values,\n tensor_input_shape, std_order,\n &input_st));\n\n const int64_t N = input_shape_vec(0);\n\n Tensor sparse_handles(DT_INT64, TensorShape({N}));\n auto sparse_handles_t = sparse_handles.vec();\n\n OP_REQUIRES_OK(context, input_st.IndicesValid());\n\n // We can generate the output shape proto string now, for all\n // minibatch entries.\n TensorShape output_shape;\n OP_REQUIRES_OK(context, TensorShapeUtils::MakeShape(\n input_shape_vec.data() + 1,\n input_shape->NumElements() - 1, &output_shape));\n\n // Get groups by minibatch dimension\n std::unordered_set visited;\n sparse::GroupIterable minibatch = input_st.group({0});\n for (const auto& subset : minibatch) {\n const int64_t b = subset.group()[0];\n visited.insert(b);\n OP_REQUIRES(\n context, b > -1 && b < N,\n errors::InvalidArgument(\n \"Received unexpected column 0 value in input SparseTensor: \", b,\n \" < 0 or >= N (= \", N, \")\"));\n\n const auto indices = subset.indices();\n const auto values = subset.values();\n const int64_t num_entries = values.size();\n\n Tensor output_indices = Tensor(DT_INT64, {num_entries, rank - 1});\n Tensor output_values = Tensor(DataTypeToEnum::value, {num_entries});\n\n auto output_indices_t = output_indices.matrix();\n auto output_values_t = output_values.vec();\n\n for (int i = 0; i < num_entries; ++i) {\n for (int d = 1; d < rank; ++d) {\n output_indices_t(i, d - 1) = indices(i, d);\n }\n output_values_t(i) = values(i);\n }\n\n SparseTensor st_i;\n OP_REQUIRES_OK(context,\n SparseTensor::Create(output_indices, output_values,\n output_shape, &st_i));\n int64_t handle;\n OP_REQUIRES_OK(context, map->AddSparseTensor(context, st_i, &handle));\n sparse_handles_t(b) = handle;\n }\n\n // Fill in any gaps; we must provide an empty ST for batch entries\n // the grouper didn't find.\n if (visited.size() < N) {\n Tensor empty_indices(DT_INT64, {0, rank - 1});\n Tensor empty_values(DataTypeToEnum::value, {0});\n SparseTensor empty_st;\n OP_REQUIRES_OK(context, SparseTensor::Create(empty_indices, empty_values,\n output_shape, &empty_st));\n\n for (int64_t b = 0; b < N; ++b) {\n // We skipped this batch entry.\n if (visited.find(b) == visited.end()) {\n int64_t handle;\n OP_REQUIRES_OK(context,\n map->AddSparseTensor(context, empty_st, &handle));\n sparse_handles_t(b) = handle;\n }\n }\n }\n\n context->set_output(0, sparse_handles);\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-23568", "cwe_id": "CWE-190" }, { "id": 370, "func": "BGD_DECLARE(void) gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out)\n{\n\tint x, y, c, b, sx, sy, p;\n\tchar *name, *f;\n\tsize_t i, l;\n\n\tname = file_name;\n\tif ((f = strrchr(name, '/')) != NULL) name = f+1;\n\tif ((f = strrchr(name, '\\\\')) != NULL) name = f+1;\n\tname = strdup(name);\n\tif ((f = strrchr(name, '.')) != NULL && !strcasecmp(f, \".XBM\")) *f = '\\0';\n\tif ((l = strlen(name)) == 0) {\n\t\tfree(name);\n\t\tname = strdup(\"image\");\n\t} else {\n\t\tfor (i=0; i_width 1234 */\n\tgdCtxPuts(out, \"#define \");\n\tgdCtxPuts(out, name);\n\tgdCtxPuts(out, \"_width \");\n\tgdCtxPrintf(out, \"%d\\n\", gdImageSX(image));\n\n\t/* #define _height 1234 */\n\tgdCtxPuts(out, \"#define \");\n\tgdCtxPuts(out, name);\n\tgdCtxPuts(out, \"_height \");\n\tgdCtxPrintf(out, \"%d\\n\", gdImageSY(image));\n\n\t/* static unsigned char _bits[] = {\\n */\n\tgdCtxPuts(out, \"static unsigned char \");\n\tgdCtxPuts(out, name);\n\tgdCtxPuts(out, \"_bits[] = {\\n \");\n\n\tfree(name);\n\n\tb = 1;\n\tp = 0;\n\tc = 0;\n\tsx = gdImageSX(image);\n\tsy = gdImageSY(image);\n\tfor (y = 0; y < sy; y++) {\n\t\tfor (x = 0; x < sx; x++) {\n\t\t\tif (gdImageGetPixel(image, x, y) == fg) {\n\t\t\t\tc |= b;\n\t\t\t}\n\t\t\tif ((b == 128) || (x == sx && y == sy)) {\n\t\t\t\tb = 1;\n\t\t\t\tif (p) {\n\t\t\t\t\tgdCtxPuts(out, \", \");\n\t\t\t\t\tif (!(p%12)) {\n\t\t\t\t\t\tgdCtxPuts(out, \"\\n \");\n\t\t\t\t\t\tp = 12;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tp++;\n\t\t\t\tgdCtxPrintf(out, \"0x%02X\", c);\n\t\t\t\tc = 0;\n\t\t\t} else {\n\t\t\t\tb <<= 1;\n\t\t\t}\n\t\t}\n\t}\n\tgdCtxPuts(out, \"};\\n\");\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5116", "cwe_id": "CWE-119" }, { "id": 478, "func": "obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)\n{\n int isinstance;\n\n PyObject *tmp = NULL;\n\n if (obj == Py_None) {\n *out = NULL;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n asdl_seq* body;\n\n if (_PyObject_LookupAttrId(obj, &PyId_body, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"body\\\" missing from Module\");\n return 1;\n }\n else {\n int res;\n Py_ssize_t len;\n Py_ssize_t i;\n if (!PyList_Check(tmp)) {\n PyErr_Format(PyExc_TypeError, \"Module field \\\"body\\\" must be a list, not a %.200s\", tmp->ob_type->tp_name);\n goto failed;\n }\n len = PyList_GET_SIZE(tmp);\n body = _Py_asdl_seq_new(len, arena);\n if (body == NULL) goto failed;\n for (i = 0; i < len; i++) {\n stmt_ty val;\n res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val, arena);\n if (res != 0) goto failed;\n if (len != PyList_GET_SIZE(tmp)) {\n PyErr_SetString(PyExc_RuntimeError, \"Module field \\\"body\\\" changed size during iteration\");\n goto failed;\n }\n asdl_seq_SET(body, i, val);\n }\n Py_CLEAR(tmp);\n }\n *out = Module(body, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n asdl_seq* body;\n\n if (_PyObject_LookupAttrId(obj, &PyId_body, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"body\\\" missing from Interactive\");\n return 1;\n }\n else {\n int res;\n Py_ssize_t len;\n Py_ssize_t i;\n if (!PyList_Check(tmp)) {\n PyErr_Format(PyExc_TypeError, \"Interactive field \\\"body\\\" must be a list, not a %.200s\", tmp->ob_type->tp_name);\n goto failed;\n }\n len = PyList_GET_SIZE(tmp);\n body = _Py_asdl_seq_new(len, arena);\n if (body == NULL) goto failed;\n for (i = 0; i < len; i++) {\n stmt_ty val;\n res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val, arena);\n if (res != 0) goto failed;\n if (len != PyList_GET_SIZE(tmp)) {\n PyErr_SetString(PyExc_RuntimeError, \"Interactive field \\\"body\\\" changed size during iteration\");\n goto failed;\n }\n asdl_seq_SET(body, i, val);\n }\n Py_CLEAR(tmp);\n }\n *out = Interactive(body, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n expr_ty body;\n\n if (_PyObject_LookupAttrId(obj, &PyId_body, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"body\\\" missing from Expression\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_expr(tmp, &body, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n *out = Expression(body, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n asdl_seq* body;\n\n if (_PyObject_LookupAttrId(obj, &PyId_body, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"body\\\" missing from Suite\");\n return 1;\n }\n else {\n int res;\n Py_ssize_t len;\n Py_ssize_t i;\n if (!PyList_Check(tmp)) {\n PyErr_Format(PyExc_TypeError, \"Suite field \\\"body\\\" must be a list, not a %.200s\", tmp->ob_type->tp_name);\n goto failed;\n }\n len = PyList_GET_SIZE(tmp);\n body = _Py_asdl_seq_new(len, arena);\n if (body == NULL) goto failed;\n for (i = 0; i < len; i++) {\n stmt_ty val;\n res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val, arena);\n if (res != 0) goto failed;\n if (len != PyList_GET_SIZE(tmp)) {\n PyErr_SetString(PyExc_RuntimeError, \"Suite field \\\"body\\\" changed size during iteration\");\n goto failed;\n }\n asdl_seq_SET(body, i, val);\n }\n Py_CLEAR(tmp);\n }\n *out = Suite(body, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n\n PyErr_Format(PyExc_TypeError, \"expected some sort of mod, but got %R\", obj);\n failed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 478, "func": "obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)\n{\n int isinstance;\n\n PyObject *tmp = NULL;\n\n if (obj == Py_None) {\n *out = NULL;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n asdl_seq* body;\n asdl_seq* type_ignores;\n\n if (_PyObject_LookupAttrId(obj, &PyId_body, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"body\\\" missing from Module\");\n return 1;\n }\n else {\n int res;\n Py_ssize_t len;\n Py_ssize_t i;\n if (!PyList_Check(tmp)) {\n PyErr_Format(PyExc_TypeError, \"Module field \\\"body\\\" must be a list, not a %.200s\", tmp->ob_type->tp_name);\n goto failed;\n }\n len = PyList_GET_SIZE(tmp);\n body = _Py_asdl_seq_new(len, arena);\n if (body == NULL) goto failed;\n for (i = 0; i < len; i++) {\n stmt_ty val;\n res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val, arena);\n if (res != 0) goto failed;\n if (len != PyList_GET_SIZE(tmp)) {\n PyErr_SetString(PyExc_RuntimeError, \"Module field \\\"body\\\" changed size during iteration\");\n goto failed;\n }\n asdl_seq_SET(body, i, val);\n }\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_type_ignores, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"type_ignores\\\" missing from Module\");\n return 1;\n }\n else {\n int res;\n Py_ssize_t len;\n Py_ssize_t i;\n if (!PyList_Check(tmp)) {\n PyErr_Format(PyExc_TypeError, \"Module field \\\"type_ignores\\\" must be a list, not a %.200s\", tmp->ob_type->tp_name);\n goto failed;\n }\n len = PyList_GET_SIZE(tmp);\n type_ignores = _Py_asdl_seq_new(len, arena);\n if (type_ignores == NULL) goto failed;\n for (i = 0; i < len; i++) {\n type_ignore_ty val;\n res = obj2ast_type_ignore(PyList_GET_ITEM(tmp, i), &val, arena);\n if (res != 0) goto failed;\n if (len != PyList_GET_SIZE(tmp)) {\n PyErr_SetString(PyExc_RuntimeError, \"Module field \\\"type_ignores\\\" changed size during iteration\");\n goto failed;\n }\n asdl_seq_SET(type_ignores, i, val);\n }\n Py_CLEAR(tmp);\n }\n *out = Module(body, type_ignores, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n asdl_seq* body;\n\n if (_PyObject_LookupAttrId(obj, &PyId_body, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"body\\\" missing from Interactive\");\n return 1;\n }\n else {\n int res;\n Py_ssize_t len;\n Py_ssize_t i;\n if (!PyList_Check(tmp)) {\n PyErr_Format(PyExc_TypeError, \"Interactive field \\\"body\\\" must be a list, not a %.200s\", tmp->ob_type->tp_name);\n goto failed;\n }\n len = PyList_GET_SIZE(tmp);\n body = _Py_asdl_seq_new(len, arena);\n if (body == NULL) goto failed;\n for (i = 0; i < len; i++) {\n stmt_ty val;\n res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val, arena);\n if (res != 0) goto failed;\n if (len != PyList_GET_SIZE(tmp)) {\n PyErr_SetString(PyExc_RuntimeError, \"Interactive field \\\"body\\\" changed size during iteration\");\n goto failed;\n }\n asdl_seq_SET(body, i, val);\n }\n Py_CLEAR(tmp);\n }\n *out = Interactive(body, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n expr_ty body;\n\n if (_PyObject_LookupAttrId(obj, &PyId_body, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"body\\\" missing from Expression\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_expr(tmp, &body, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n *out = Expression(body, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionType_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n asdl_seq* argtypes;\n expr_ty returns;\n\n if (_PyObject_LookupAttrId(obj, &PyId_argtypes, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"argtypes\\\" missing from FunctionType\");\n return 1;\n }\n else {\n int res;\n Py_ssize_t len;\n Py_ssize_t i;\n if (!PyList_Check(tmp)) {\n PyErr_Format(PyExc_TypeError, \"FunctionType field \\\"argtypes\\\" must be a list, not a %.200s\", tmp->ob_type->tp_name);\n goto failed;\n }\n len = PyList_GET_SIZE(tmp);\n argtypes = _Py_asdl_seq_new(len, arena);\n if (argtypes == NULL) goto failed;\n for (i = 0; i < len; i++) {\n expr_ty val;\n res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &val, arena);\n if (res != 0) goto failed;\n if (len != PyList_GET_SIZE(tmp)) {\n PyErr_SetString(PyExc_RuntimeError, \"FunctionType field \\\"argtypes\\\" changed size during iteration\");\n goto failed;\n }\n asdl_seq_SET(argtypes, i, val);\n }\n Py_CLEAR(tmp);\n }\n if (_PyObject_LookupAttrId(obj, &PyId_returns, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"returns\\\" missing from FunctionType\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_expr(tmp, &returns, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n *out = FunctionType(argtypes, returns, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n asdl_seq* body;\n\n if (_PyObject_LookupAttrId(obj, &PyId_body, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"body\\\" missing from Suite\");\n return 1;\n }\n else {\n int res;\n Py_ssize_t len;\n Py_ssize_t i;\n if (!PyList_Check(tmp)) {\n PyErr_Format(PyExc_TypeError, \"Suite field \\\"body\\\" must be a list, not a %.200s\", tmp->ob_type->tp_name);\n goto failed;\n }\n len = PyList_GET_SIZE(tmp);\n body = _Py_asdl_seq_new(len, arena);\n if (body == NULL) goto failed;\n for (i = 0; i < len; i++) {\n stmt_ty val;\n res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val, arena);\n if (res != 0) goto failed;\n if (len != PyList_GET_SIZE(tmp)) {\n PyErr_SetString(PyExc_RuntimeError, \"Suite field \\\"body\\\" changed size during iteration\");\n goto failed;\n }\n asdl_seq_SET(body, i, val);\n }\n Py_CLEAR(tmp);\n }\n *out = Suite(body, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n\n PyErr_Format(PyExc_TypeError, \"expected some sort of mod, but got %R\", obj);\n failed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1941, "func": " void operator()(const CPUDevice& d, typename TTypes::ConstTensor input,\n typename TTypes::ConstTensor filter,\n typename TTypes::ConstTensor out_backprop,\n int stride_rows, int stride_cols, int rate_rows,\n int rate_cols, int pad_top, int pad_left,\n typename TTypes::Tensor in_backprop) {\n const int batch = input.dimension(0);\n const int input_rows = input.dimension(1);\n const int input_cols = input.dimension(2);\n const int depth = input.dimension(3);\n\n const int filter_rows = filter.dimension(0);\n const int filter_cols = filter.dimension(1);\n\n const int output_rows = out_backprop.dimension(1);\n const int output_cols = out_backprop.dimension(2);\n\n // Initialize gradient with all zeros.\n in_backprop.setZero();\n\n // This is a reference implementation, likely to be slow.\n // TODO(gpapan): Write multi-threaded implementation.\n // In the case of multiple argmax branches, we only back-propagate along the\n // last branch, i.e., the one with largest value of `h * filter_cols + w`,\n // similarly to the max-pooling backward routines.\n for (int b = 0; b < batch; ++b) {\n for (int h_out = 0; h_out < output_rows; ++h_out) {\n int h_beg = h_out * stride_rows - pad_top;\n for (int w_out = 0; w_out < output_cols; ++w_out) {\n int w_beg = w_out * stride_cols - pad_left;\n for (int d = 0; d < depth; ++d) {\n T cur_val = Eigen::NumTraits::lowest();\n int h_in_max = (h_beg < 0) ? 0 : h_beg;\n int w_in_max = (w_beg < 0) ? 0 : w_beg;\n for (int h = 0; h < filter_rows; ++h) {\n const int h_in = h_beg + h * rate_rows;\n if (h_in >= 0 && h_in < input_rows) {\n for (int w = 0; w < filter_cols; ++w) {\n const int w_in = w_beg + w * rate_cols;\n if (w_in >= 0 && w_in < input_cols) {\n const T val = input(b, h_in, w_in, d) + filter(h, w, d);\n if (val > cur_val) {\n cur_val = val;\n h_in_max = h_in;\n w_in_max = w_in;\n }\n }\n }\n }\n }\n in_backprop(b, h_in_max, w_in_max, d) +=\n out_backprop(b, h_out, w_out, d);\n }\n }\n }\n }\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-29566", "cwe_id": "CWE-787" }, { "id": 1941, "func": " void operator()(const CPUDevice& d, typename TTypes::ConstTensor input,\n typename TTypes::ConstTensor filter,\n typename TTypes::ConstTensor out_backprop,\n int stride_rows, int stride_cols, int rate_rows,\n int rate_cols, int pad_top, int pad_left,\n typename TTypes::Tensor in_backprop) {\n const int batch = input.dimension(0);\n const int input_rows = input.dimension(1);\n const int input_cols = input.dimension(2);\n const int depth = input.dimension(3);\n\n const int filter_rows = filter.dimension(0);\n const int filter_cols = filter.dimension(1);\n\n const int output_rows = out_backprop.dimension(1);\n const int output_cols = out_backprop.dimension(2);\n\n // Initialize gradient with all zeros.\n in_backprop.setZero();\n\n // This is a reference implementation, likely to be slow.\n // TODO(gpapan): Write multi-threaded implementation.\n // In the case of multiple argmax branches, we only back-propagate along the\n // last branch, i.e., the one with largest value of `h * filter_cols + w`,\n // similarly to the max-pooling backward routines.\n for (int b = 0; b < batch; ++b) {\n for (int h_out = 0; h_out < output_rows; ++h_out) {\n int h_beg = h_out * stride_rows - pad_top;\n for (int w_out = 0; w_out < output_cols; ++w_out) {\n int w_beg = w_out * stride_cols - pad_left;\n for (int d = 0; d < depth; ++d) {\n T cur_val = Eigen::NumTraits::lowest();\n int h_in_max = (h_beg < 0) ? 0 : h_beg;\n int w_in_max = (w_beg < 0) ? 0 : w_beg;\n for (int h = 0; h < filter_rows; ++h) {\n const int h_in = h_beg + h * rate_rows;\n if (h_in >= 0 && h_in < input_rows) {\n for (int w = 0; w < filter_cols; ++w) {\n const int w_in = w_beg + w * rate_cols;\n if (w_in >= 0 && w_in < input_cols) {\n const T val = input(b, h_in, w_in, d) + filter(h, w, d);\n if (val > cur_val) {\n cur_val = val;\n h_in_max = h_in;\n w_in_max = w_in;\n }\n }\n }\n }\n }\n if (h_in_max < input_rows && w_in_max < input_cols) {\n in_backprop(b, h_in_max, w_in_max, d) +=\n out_backprop(b, h_out, w_out, d);\n }\n }\n }\n }\n }\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-29566", "cwe_id": "CWE-787" }, { "id": 1007, "func": "int FdOutStream::overrun(int itemSize, int nItems)\n{\n if (itemSize > bufSize)\n throw Exception(\"FdOutStream overrun: max itemSize exceeded\");\n\n // First try to get rid of the data we have\n flush();\n\n // Still not enough space?\n if (itemSize > end - ptr) {\n // Can we shuffle things around?\n // (don't do this if it gains us less than 25%)\n if ((sentUpTo - start > bufSize / 4) &&\n (itemSize < bufSize - (ptr - sentUpTo))) {\n memmove(start, sentUpTo, ptr - sentUpTo);\n ptr = start + (ptr - sentUpTo);\n sentUpTo = start;\n } else {\n // Have to get rid of more data, so turn off non-blocking\n // for a bit...\n bool realBlocking;\n\n realBlocking = blocking;\n blocking = true;\n flush();\n blocking = realBlocking;\n }\n }\n\n // Can we fit all the items asked for?\n if (itemSize * nItems > end - ptr)\n nItems = (end - ptr) / itemSize;\n\n return nItems;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 1007, "func": "size_t FdOutStream::overrun(size_t itemSize, size_t nItems)\n{\n if (itemSize > bufSize)\n throw Exception(\"FdOutStream overrun: max itemSize exceeded\");\n\n // First try to get rid of the data we have\n flush();\n\n // Still not enough space?\n if (itemSize > (size_t)(end - ptr)) {\n // Can we shuffle things around?\n // (don't do this if it gains us less than 25%)\n if (((size_t)(sentUpTo - start) > bufSize / 4) &&\n (itemSize < bufSize - (ptr - sentUpTo))) {\n memmove(start, sentUpTo, ptr - sentUpTo);\n ptr = start + (ptr - sentUpTo);\n sentUpTo = start;\n } else {\n // Have to get rid of more data, so turn off non-blocking\n // for a bit...\n bool realBlocking;\n\n realBlocking = blocking;\n blocking = true;\n flush();\n blocking = realBlocking;\n }\n }\n\n // Can we fit all the items asked for?\n if (itemSize * nItems > (size_t)(end - ptr))\n nItems = (end - ptr) / itemSize;\n\n return nItems;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 1587, "func": "static int cmd_handle_untagged(struct ImapData *idata)\n{\n unsigned int count = 0;\n char *s = imap_next_word(idata->buf);\n char *pn = imap_next_word(s);\n\n if ((idata->state >= IMAP_SELECTED) && isdigit((unsigned char) *s))\n {\n pn = s;\n s = imap_next_word(s);\n\n /* EXISTS and EXPUNGE are always related to the SELECTED mailbox for the\n * connection, so update that one.\n */\n if (mutt_str_strncasecmp(\"EXISTS\", s, 6) == 0)\n {\n mutt_debug(2, \"Handling EXISTS\\n\");\n\n /* new mail arrived */\n if (mutt_str_atoui(pn, &count) < 0)\n {\n mutt_debug(1, \"Malformed EXISTS: '%s'\\n\", pn);\n }\n\n if (!(idata->reopen & IMAP_EXPUNGE_PENDING) && count < idata->max_msn)\n {\n /* Notes 6.0.3 has a tendency to report fewer messages exist than\n * it should. */\n mutt_debug(1, \"Message count is out of sync\\n\");\n return 0;\n }\n /* at least the InterChange server sends EXISTS messages freely,\n * even when there is no new mail */\n else if (count == idata->max_msn)\n mutt_debug(3, \"superfluous EXISTS message.\\n\");\n else\n {\n if (!(idata->reopen & IMAP_EXPUNGE_PENDING))\n {\n mutt_debug(2, \"New mail in %s - %d messages total.\\n\", idata->mailbox, count);\n idata->reopen |= IMAP_NEWMAIL_PENDING;\n }\n idata->new_mail_count = count;\n }\n }\n /* pn vs. s: need initial seqno */\n else if (mutt_str_strncasecmp(\"EXPUNGE\", s, 7) == 0)\n cmd_parse_expunge(idata, pn);\n else if (mutt_str_strncasecmp(\"FETCH\", s, 5) == 0)\n cmd_parse_fetch(idata, pn);\n }\n else if (mutt_str_strncasecmp(\"CAPABILITY\", s, 10) == 0)\n cmd_parse_capability(idata, s);\n else if (mutt_str_strncasecmp(\"OK [CAPABILITY\", s, 14) == 0)\n cmd_parse_capability(idata, pn);\n else if (mutt_str_strncasecmp(\"OK [CAPABILITY\", pn, 14) == 0)\n cmd_parse_capability(idata, imap_next_word(pn));\n else if (mutt_str_strncasecmp(\"LIST\", s, 4) == 0)\n cmd_parse_list(idata, s);\n else if (mutt_str_strncasecmp(\"LSUB\", s, 4) == 0)\n cmd_parse_lsub(idata, s);\n else if (mutt_str_strncasecmp(\"MYRIGHTS\", s, 8) == 0)\n cmd_parse_myrights(idata, s);\n else if (mutt_str_strncasecmp(\"SEARCH\", s, 6) == 0)\n cmd_parse_search(idata, s);\n else if (mutt_str_strncasecmp(\"STATUS\", s, 6) == 0)\n cmd_parse_status(idata, s);\n else if (mutt_str_strncasecmp(\"ENABLED\", s, 7) == 0)\n cmd_parse_enabled(idata, s);\n else if (mutt_str_strncasecmp(\"BYE\", s, 3) == 0)\n {\n mutt_debug(2, \"Handling BYE\\n\");\n\n /* check if we're logging out */\n if (idata->status == IMAP_BYE)\n return 0;\n\n /* server shut down our connection */\n s += 3;\n SKIPWS(s);\n mutt_error(\"%s\", s);\n cmd_handle_fatal(idata);\n\n return -1;\n }\n else if (ImapServernoise && (mutt_str_strncasecmp(\"NO\", s, 2) == 0))\n {\n mutt_debug(2, \"Handling untagged NO\\n\");\n\n /* Display the warning message from the server */\n mutt_error(\"%s\", s + 3);\n }\n\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-14349", "cwe_id": "CWE-20" }, { "id": 1587, "func": "static int cmd_handle_untagged(struct ImapData *idata)\n{\n unsigned int count = 0;\n char *s = imap_next_word(idata->buf);\n char *pn = imap_next_word(s);\n\n if ((idata->state >= IMAP_SELECTED) && isdigit((unsigned char) *s))\n {\n pn = s;\n s = imap_next_word(s);\n\n /* EXISTS and EXPUNGE are always related to the SELECTED mailbox for the\n * connection, so update that one.\n */\n if (mutt_str_strncasecmp(\"EXISTS\", s, 6) == 0)\n {\n mutt_debug(2, \"Handling EXISTS\\n\");\n\n /* new mail arrived */\n if (mutt_str_atoui(pn, &count) < 0)\n {\n mutt_debug(1, \"Malformed EXISTS: '%s'\\n\", pn);\n }\n\n if (!(idata->reopen & IMAP_EXPUNGE_PENDING) && count < idata->max_msn)\n {\n /* Notes 6.0.3 has a tendency to report fewer messages exist than\n * it should. */\n mutt_debug(1, \"Message count is out of sync\\n\");\n return 0;\n }\n /* at least the InterChange server sends EXISTS messages freely,\n * even when there is no new mail */\n else if (count == idata->max_msn)\n mutt_debug(3, \"superfluous EXISTS message.\\n\");\n else\n {\n if (!(idata->reopen & IMAP_EXPUNGE_PENDING))\n {\n mutt_debug(2, \"New mail in %s - %d messages total.\\n\", idata->mailbox, count);\n idata->reopen |= IMAP_NEWMAIL_PENDING;\n }\n idata->new_mail_count = count;\n }\n }\n /* pn vs. s: need initial seqno */\n else if (mutt_str_strncasecmp(\"EXPUNGE\", s, 7) == 0)\n cmd_parse_expunge(idata, pn);\n else if (mutt_str_strncasecmp(\"FETCH\", s, 5) == 0)\n cmd_parse_fetch(idata, pn);\n }\n else if (mutt_str_strncasecmp(\"CAPABILITY\", s, 10) == 0)\n cmd_parse_capability(idata, s);\n else if (mutt_str_strncasecmp(\"OK [CAPABILITY\", s, 14) == 0)\n cmd_parse_capability(idata, pn);\n else if (mutt_str_strncasecmp(\"OK [CAPABILITY\", pn, 14) == 0)\n cmd_parse_capability(idata, imap_next_word(pn));\n else if (mutt_str_strncasecmp(\"LIST\", s, 4) == 0)\n cmd_parse_list(idata, s);\n else if (mutt_str_strncasecmp(\"LSUB\", s, 4) == 0)\n cmd_parse_lsub(idata, s);\n else if (mutt_str_strncasecmp(\"MYRIGHTS\", s, 8) == 0)\n cmd_parse_myrights(idata, s);\n else if (mutt_str_strncasecmp(\"SEARCH\", s, 6) == 0)\n cmd_parse_search(idata, s);\n else if (mutt_str_strncasecmp(\"STATUS\", s, 6) == 0)\n cmd_parse_status(idata, s);\n else if (mutt_str_strncasecmp(\"ENABLED\", s, 7) == 0)\n cmd_parse_enabled(idata, s);\n else if (mutt_str_strncasecmp(\"BYE\", s, 3) == 0)\n {\n mutt_debug(2, \"Handling BYE\\n\");\n\n /* check if we're logging out */\n if (idata->status == IMAP_BYE)\n return 0;\n\n /* server shut down our connection */\n s += 3;\n SKIPWS(s);\n mutt_error(\"%s\", s);\n cmd_handle_fatal(idata);\n\n return -1;\n }\n else if (ImapServernoise && (mutt_str_strncasecmp(\"NO\", s, 2) == 0))\n {\n mutt_debug(2, \"Handling untagged NO\\n\");\n\n /* Display the warning message from the server */\n mutt_error(\"%s\", s + 2);\n }\n\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-14349", "cwe_id": "CWE-20" }, { "id": 1264, "func": "int oidc_handle_redirect_uri_request(request_rec *r, oidc_cfg *c,\n\t\toidc_session_t *session) {\n\n\tif (oidc_proto_is_redirect_authorization_response(r, c)) {\n\n\t\t/* this is an authorization response from the OP using the Basic Client profile or a Hybrid flow*/\n\t\treturn oidc_handle_redirect_authorization_response(r, c, session);\n\n\t} else if (oidc_proto_is_post_authorization_response(r, c)) {\n\n\t\t/* this is an authorization response using the fragment(+POST) response_mode with the Implicit Client profile */\n\t\treturn oidc_handle_post_authorization_response(r, c, session);\n\n\t} else if (oidc_is_discovery_response(r, c)) {\n\n\t\t/* this is response from the OP discovery page */\n\t\treturn oidc_handle_discovery_response(r, c);\n\n\t} else if (oidc_util_request_has_parameter(r, \"logout\")) {\n\n\t\t/* handle logout */\n\t\treturn oidc_handle_logout(r, c, session);\n\n\t} else if (oidc_util_request_has_parameter(r, \"jwks\")) {\n\n\t\t/* handle JWKs request */\n\t\treturn oidc_handle_jwks(r, c);\n\n\t} else if (oidc_util_request_has_parameter(r, \"session\")) {\n\n\t\t/* handle session management request */\n\t\treturn oidc_handle_session_management(r, c, session);\n\n\t} else if (oidc_util_request_has_parameter(r, \"refresh\")) {\n\n\t\t/* handle refresh token request */\n\t\treturn oidc_handle_refresh_token_request(r, c, session);\n\n\t} else if (oidc_util_request_has_parameter(r, \"request_uri\")) {\n\n\t\t/* handle request object by reference request */\n\t\treturn oidc_handle_request_uri(r, c);\n\n\t} else if (oidc_util_request_has_parameter(r, \"remove_at_cache\")) {\n\n\t\t/* handle request to invalidate access token cache */\n\t\treturn oidc_handle_remove_at_cache(r, c);\n\n\t} else if ((r->args == NULL) || (apr_strnatcmp(r->args, \"\") == 0)) {\n\n\t\t/* this is a \"bare\" request to the redirect URI, indicating implicit flow using the fragment response_mode */\n\t\treturn oidc_proto_javascript_implicit(r, c);\n\t}\n\n\t/* this is not an authorization response or logout request */\n\n\t/* check for \"error\" response */\n\tif (oidc_util_request_has_parameter(r, \"error\")) {\n\n//\t\tchar *error = NULL, *descr = NULL;\n//\t\toidc_util_get_request_parameter(r, \"error\", &error);\n//\t\toidc_util_get_request_parameter(r, \"error_description\", &descr);\n//\n//\t\t/* send user facing error to browser */\n//\t\treturn oidc_util_html_send_error(r, error, descr, DONE);\n\t\toidc_handle_redirect_authorization_response(r, c, session);\n\t}\n\n\t/* something went wrong */\n\treturn oidc_util_html_send_error(r, c->error_template, \"Invalid Request\",\n\t\t\tapr_psprintf(r->pool,\n\t\t\t\t\t\"The OpenID Connect callback URL received an invalid request: %s\",\n\t\t\t\t\tr->args), HTTP_INTERNAL_SERVER_ERROR);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-6059", "cwe_id": "CWE-20" }, { "id": 1264, "func": "int oidc_handle_redirect_uri_request(request_rec *r, oidc_cfg *c,\n\t\toidc_session_t *session) {\n\n\tif (oidc_proto_is_redirect_authorization_response(r, c)) {\n\n\t\t/* this is an authorization response from the OP using the Basic Client profile or a Hybrid flow*/\n\t\treturn oidc_handle_redirect_authorization_response(r, c, session);\n\n\t} else if (oidc_proto_is_post_authorization_response(r, c)) {\n\n\t\t/* this is an authorization response using the fragment(+POST) response_mode with the Implicit Client profile */\n\t\treturn oidc_handle_post_authorization_response(r, c, session);\n\n\t} else if (oidc_is_discovery_response(r, c)) {\n\n\t\t/* this is response from the OP discovery page */\n\t\treturn oidc_handle_discovery_response(r, c);\n\n\t} else if (oidc_util_request_has_parameter(r, \"logout\")) {\n\n\t\t/* handle logout */\n\t\treturn oidc_handle_logout(r, c, session);\n\n\t} else if (oidc_util_request_has_parameter(r, \"jwks\")) {\n\n\t\t/* handle JWKs request */\n\t\treturn oidc_handle_jwks(r, c);\n\n\t} else if (oidc_util_request_has_parameter(r, \"session\")) {\n\n\t\t/* handle session management request */\n\t\treturn oidc_handle_session_management(r, c, session);\n\n\t} else if (oidc_util_request_has_parameter(r, \"refresh\")) {\n\n\t\t/* handle refresh token request */\n\t\treturn oidc_handle_refresh_token_request(r, c, session);\n\n\t} else if (oidc_util_request_has_parameter(r, \"request_uri\")) {\n\n\t\t/* handle request object by reference request */\n\t\treturn oidc_handle_request_uri(r, c);\n\n\t} else if (oidc_util_request_has_parameter(r, \"remove_at_cache\")) {\n\n\t\t/* handle request to invalidate access token cache */\n\t\treturn oidc_handle_remove_at_cache(r, c);\n\n\t} else if ((r->args == NULL) || (apr_strnatcmp(r->args, \"\") == 0)) {\n\n\t\t/* this is a \"bare\" request to the redirect URI, indicating implicit flow using the fragment response_mode */\n\t\treturn oidc_proto_javascript_implicit(r, c);\n\t}\n\n\t/* this is not an authorization response or logout request */\n\n\t/* check for \"error\" response */\n\tif (oidc_util_request_has_parameter(r, \"error\")) {\n\n//\t\tchar *error = NULL, *descr = NULL;\n//\t\toidc_util_get_request_parameter(r, \"error\", &error);\n//\t\toidc_util_get_request_parameter(r, \"error_description\", &descr);\n//\n//\t\t/* send user facing error to browser */\n//\t\treturn oidc_util_html_send_error(r, error, descr, DONE);\n\t\toidc_handle_redirect_authorization_response(r, c, session);\n\t}\n\n\t/* something went wrong */\n\treturn oidc_util_html_send_error(r, c->error_template, \"Invalid Request\",\n\t\t\tapr_psprintf(r->pool,\n\t\t\t\t\t\"The OpenID Connect callback URL received an invalid request\"),\n\t\t\t\t\tHTTP_INTERNAL_SERVER_ERROR);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-6059", "cwe_id": "CWE-20" }, { "id": 3109, "func": "static punycode_uint decode_digit(punycode_uint cp)\n{\n return cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 :\n cp - 97 < 26 ? cp - 97 : base;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-14062", "cwe_id": "CWE-190" }, { "id": 3109, "func": "static unsigned decode_digit(int cp)\n{\n return (unsigned) (cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 :\n cp - 97 < 26 ? cp - 97 : base);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-14062", "cwe_id": "CWE-190" }, { "id": 2394, "func": "bool hex2carray(const char *_hex, uint64_t *_bin_len,\n uint8_t *_bin, uint64_t _max_length) {\n\n\n CHECK_STATE(_hex);\n CHECK_STATE(_bin);\n CHECK_STATE(_bin_len)\n\n\n int len = strnlen(_hex, 2 * _max_length + 1);\n\n CHECK_STATE(len != 2 * _max_length + 1);\n\n CHECK_STATE(len <= 2 * _max_length );\n\n\n if (len == 0 && len % 2 == 1)\n return false;\n\n *_bin_len = len / 2;\n\n for (int i = 0; i < len / 2; i++) {\n int high = char2int((char) _hex[i * 2]);\n int low = char2int((char) _hex[i * 2 + 1]);\n\n if (high < 0 || low < 0) {\n return false;\n }\n\n _bin[i] = (unsigned char) (high * 16 + low);\n }\n\n return true;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-36218", "cwe_id": "CWE-787" }, { "id": 2394, "func": "bool hex2carray(const char *_hex, uint64_t *_bin_len,\n uint8_t *_bin, uint64_t _max_length) {\n\n\n CHECK_STATE(_hex);\n CHECK_STATE(_bin);\n CHECK_STATE(_bin_len)\n\n\n uint64_t len = strnlen(_hex, 2 * _max_length + 1);\n\n CHECK_STATE(len != 2 * _max_length + 1);\n\n CHECK_STATE(len <= 2 * _max_length );\n\n\n if (len == 0 && len % 2 == 1)\n return false;\n\n *_bin_len = len / 2;\n\n for (uint64_t i = 0; i < len / 2; i++) {\n int high = char2int((char) _hex[i * 2]);\n int low = char2int((char) _hex[i * 2 + 1]);\n\n if (high < 0 || low < 0) {\n return false;\n }\n\n _bin[i] = (unsigned char) (high * 16 + low);\n }\n\n return true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-36218", "cwe_id": "CWE-787" }, { "id": 225, "func": "userauth_hostbased(struct ssh *ssh)\n{\n\tAuthctxt *authctxt = ssh->authctxt;\n\tstruct sshbuf *b;\n\tstruct sshkey *key = NULL;\n\tchar *pkalg, *cuser, *chost;\n\tu_char *pkblob, *sig;\n\tsize_t alen, blen, slen;\n\tint r, pktype, authenticated = 0;\n\n\tif (!authctxt->valid) {\n\t\tdebug2(\"%s: disabled because of invalid user\", __func__);\n\t\treturn 0;\n\t}\n\t/* XXX use sshkey_froms() */\n\tif ((r = sshpkt_get_cstring(ssh, &pkalg, &alen)) != 0 ||\n\t (r = sshpkt_get_string(ssh, &pkblob, &blen)) != 0 ||\n\t (r = sshpkt_get_cstring(ssh, &chost, NULL)) != 0 ||\n\t (r = sshpkt_get_cstring(ssh, &cuser, NULL)) != 0 ||\n\t (r = sshpkt_get_string(ssh, &sig, &slen)) != 0)\n\t\tfatal(\"%s: packet parsing: %s\", __func__, ssh_err(r));\n\n\tdebug(\"%s: cuser %s chost %s pkalg %s slen %zu\", __func__,\n\t cuser, chost, pkalg, slen);\n#ifdef DEBUG_PK\n\tdebug(\"signature:\");\n\tsshbuf_dump_data(sig, siglen, stderr);\n#endif\n\tpktype = sshkey_type_from_name(pkalg);\n\tif (pktype == KEY_UNSPEC) {\n\t\t/* this is perfectly legal */\n\t\tlogit(\"%s: unsupported public key algorithm: %s\",\n\t\t __func__, pkalg);\n\t\tgoto done;\n\t}\n\tif ((r = sshkey_from_blob(pkblob, blen, &key)) != 0) {\n\t\terror(\"%s: key_from_blob: %s\", __func__, ssh_err(r));\n\t\tgoto done;\n\t}\n\tif (key == NULL) {\n\t\terror(\"%s: cannot decode key: %s\", __func__, pkalg);\n\t\tgoto done;\n\t}\n\tif (key->type != pktype) {\n\t\terror(\"%s: type mismatch for decoded key \"\n\t\t \"(received %d, expected %d)\", __func__, key->type, pktype);\n\t\tgoto done;\n\t}\n\tif (sshkey_type_plain(key->type) == KEY_RSA &&\n\t (ssh->compat & SSH_BUG_RSASIGMD5) != 0) {\n\t\terror(\"Refusing RSA key because peer uses unsafe \"\n\t\t \"signature format\");\n\t\tgoto done;\n\t}\n\tif (match_pattern_list(pkalg, options.hostbased_key_types, 0) != 1) {\n\t\tlogit(\"%s: key type %s not in HostbasedAcceptedKeyTypes\",\n\t\t __func__, sshkey_type(key));\n\t\tgoto done;\n\t}\n\n\tif ((b = sshbuf_new()) == NULL)\n\t\tfatal(\"%s: sshbuf_new failed\", __func__);\n\t/* reconstruct packet */\n\tif ((r = sshbuf_put_string(b, session_id2, session_id2_len)) != 0 ||\n\t (r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||\n\t (r = sshbuf_put_cstring(b, authctxt->user)) != 0 ||\n\t (r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||\n\t (r = sshbuf_put_cstring(b, \"hostbased\")) != 0 ||\n\t (r = sshbuf_put_string(b, pkalg, alen)) != 0 ||\n\t (r = sshbuf_put_string(b, pkblob, blen)) != 0 ||\n\t (r = sshbuf_put_cstring(b, chost)) != 0 ||\n\t (r = sshbuf_put_cstring(b, cuser)) != 0)\n\t\tfatal(\"%s: buffer error: %s\", __func__, ssh_err(r));\n#ifdef DEBUG_PK\n\tsshbuf_dump(b, stderr);\n#endif\n\n\tauth2_record_info(authctxt,\n\t \"client user \\\"%.100s\\\", client host \\\"%.100s\\\"\", cuser, chost);\n\n\t/* test for allowed key and correct signature */\n\tauthenticated = 0;\n\tif (PRIVSEP(hostbased_key_allowed(authctxt->pw, cuser, chost, key)) &&\n\t PRIVSEP(sshkey_verify(key, sig, slen,\n\t sshbuf_ptr(b), sshbuf_len(b), pkalg, ssh->compat)) == 0)\n\t\tauthenticated = 1;\n\n\tauth2_record_key(authctxt, authenticated, key);\n\tsshbuf_free(b);\ndone:\n\tdebug2(\"%s: authenticated %d\", __func__, authenticated);\n\tsshkey_free(key);\n\tfree(pkalg);\n\tfree(pkblob);\n\tfree(cuser);\n\tfree(chost);\n\tfree(sig);\n\treturn authenticated;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-15473", "cwe_id": "CWE-362" }, { "id": 225, "func": "userauth_hostbased(struct ssh *ssh)\n{\n\tAuthctxt *authctxt = ssh->authctxt;\n\tstruct sshbuf *b;\n\tstruct sshkey *key = NULL;\n\tchar *pkalg, *cuser, *chost;\n\tu_char *pkblob, *sig;\n\tsize_t alen, blen, slen;\n\tint r, pktype, authenticated = 0;\n\n\t/* XXX use sshkey_froms() */\n\tif ((r = sshpkt_get_cstring(ssh, &pkalg, &alen)) != 0 ||\n\t (r = sshpkt_get_string(ssh, &pkblob, &blen)) != 0 ||\n\t (r = sshpkt_get_cstring(ssh, &chost, NULL)) != 0 ||\n\t (r = sshpkt_get_cstring(ssh, &cuser, NULL)) != 0 ||\n\t (r = sshpkt_get_string(ssh, &sig, &slen)) != 0)\n\t\tfatal(\"%s: packet parsing: %s\", __func__, ssh_err(r));\n\n\tdebug(\"%s: cuser %s chost %s pkalg %s slen %zu\", __func__,\n\t cuser, chost, pkalg, slen);\n#ifdef DEBUG_PK\n\tdebug(\"signature:\");\n\tsshbuf_dump_data(sig, siglen, stderr);\n#endif\n\tpktype = sshkey_type_from_name(pkalg);\n\tif (pktype == KEY_UNSPEC) {\n\t\t/* this is perfectly legal */\n\t\tlogit(\"%s: unsupported public key algorithm: %s\",\n\t\t __func__, pkalg);\n\t\tgoto done;\n\t}\n\tif ((r = sshkey_from_blob(pkblob, blen, &key)) != 0) {\n\t\terror(\"%s: key_from_blob: %s\", __func__, ssh_err(r));\n\t\tgoto done;\n\t}\n\tif (key == NULL) {\n\t\terror(\"%s: cannot decode key: %s\", __func__, pkalg);\n\t\tgoto done;\n\t}\n\tif (key->type != pktype) {\n\t\terror(\"%s: type mismatch for decoded key \"\n\t\t \"(received %d, expected %d)\", __func__, key->type, pktype);\n\t\tgoto done;\n\t}\n\tif (sshkey_type_plain(key->type) == KEY_RSA &&\n\t (ssh->compat & SSH_BUG_RSASIGMD5) != 0) {\n\t\terror(\"Refusing RSA key because peer uses unsafe \"\n\t\t \"signature format\");\n\t\tgoto done;\n\t}\n\tif (match_pattern_list(pkalg, options.hostbased_key_types, 0) != 1) {\n\t\tlogit(\"%s: key type %s not in HostbasedAcceptedKeyTypes\",\n\t\t __func__, sshkey_type(key));\n\t\tgoto done;\n\t}\n\n\tif (!authctxt->valid || authctxt->user == NULL) {\n\t\tdebug2(\"%s: disabled because of invalid user\", __func__);\n\t\tgoto done;\n\t}\n\n\tif ((b = sshbuf_new()) == NULL)\n\t\tfatal(\"%s: sshbuf_new failed\", __func__);\n\t/* reconstruct packet */\n\tif ((r = sshbuf_put_string(b, session_id2, session_id2_len)) != 0 ||\n\t (r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||\n\t (r = sshbuf_put_cstring(b, authctxt->user)) != 0 ||\n\t (r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||\n\t (r = sshbuf_put_cstring(b, \"hostbased\")) != 0 ||\n\t (r = sshbuf_put_string(b, pkalg, alen)) != 0 ||\n\t (r = sshbuf_put_string(b, pkblob, blen)) != 0 ||\n\t (r = sshbuf_put_cstring(b, chost)) != 0 ||\n\t (r = sshbuf_put_cstring(b, cuser)) != 0)\n\t\tfatal(\"%s: buffer error: %s\", __func__, ssh_err(r));\n#ifdef DEBUG_PK\n\tsshbuf_dump(b, stderr);\n#endif\n\n\tauth2_record_info(authctxt,\n\t \"client user \\\"%.100s\\\", client host \\\"%.100s\\\"\", cuser, chost);\n\n\t/* test for allowed key and correct signature */\n\tauthenticated = 0;\n\tif (PRIVSEP(hostbased_key_allowed(authctxt->pw, cuser, chost, key)) &&\n\t PRIVSEP(sshkey_verify(key, sig, slen,\n\t sshbuf_ptr(b), sshbuf_len(b), pkalg, ssh->compat)) == 0)\n\t\tauthenticated = 1;\n\n\tauth2_record_key(authctxt, authenticated, key);\n\tsshbuf_free(b);\ndone:\n\tdebug2(\"%s: authenticated %d\", __func__, authenticated);\n\tsshkey_free(key);\n\tfree(pkalg);\n\tfree(pkblob);\n\tfree(cuser);\n\tfree(chost);\n\tfree(sig);\n\treturn authenticated;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-15473", "cwe_id": "CWE-362" }, { "id": 1246, "func": "static int read_new_config_info (WavpackContext *wpc, WavpackMetadata *wpmd)\n{\n int bytecnt = wpmd->byte_length;\n unsigned char *byteptr = wpmd->data;\n\n wpc->version_five = 1; // just having this block signals version 5.0\n\n wpc->file_format = wpc->config.qmode = wpc->channel_layout = 0;\n\n if (wpc->channel_reordering) {\n free (wpc->channel_reordering);\n wpc->channel_reordering = NULL;\n }\n\n // if there's any data, the first two bytes are file_format and qmode flags\n\n if (bytecnt) {\n wpc->file_format = *byteptr++;\n wpc->config.qmode = (wpc->config.qmode & ~0xff) | *byteptr++;\n bytecnt -= 2;\n\n // another byte indicates a channel layout\n\n if (bytecnt) {\n int nchans, i;\n\n wpc->channel_layout = (int32_t) *byteptr++ << 16;\n bytecnt--;\n\n // another byte means we have a channel count for the layout and maybe a reordering\n\n if (bytecnt) {\n wpc->channel_layout += nchans = *byteptr++;\n bytecnt--;\n\n // any more means there's a reordering string\n\n if (bytecnt) {\n if (bytecnt > nchans)\n return FALSE;\n\n wpc->channel_reordering = malloc (nchans);\n\n // note that redundant reordering info is not stored, so we fill in the rest\n\n if (wpc->channel_reordering) {\n for (i = 0; i < nchans; ++i)\n if (bytecnt) {\n wpc->channel_reordering [i] = *byteptr++;\n bytecnt--;\n }\n else\n wpc->channel_reordering [i] = i;\n }\n }\n }\n else\n wpc->channel_layout += wpc->config.num_channels;\n }\n }\n\n return TRUE;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10169", "cwe_id": "CWE-125" }, { "id": 1246, "func": "static int read_new_config_info (WavpackContext *wpc, WavpackMetadata *wpmd)\n{\n int bytecnt = wpmd->byte_length;\n unsigned char *byteptr = wpmd->data;\n\n wpc->version_five = 1; // just having this block signals version 5.0\n\n wpc->file_format = wpc->config.qmode = wpc->channel_layout = 0;\n\n if (wpc->channel_reordering) {\n free (wpc->channel_reordering);\n wpc->channel_reordering = NULL;\n }\n\n // if there's any data, the first two bytes are file_format and qmode flags\n\n if (bytecnt >= 2) {\n wpc->file_format = *byteptr++;\n wpc->config.qmode = (wpc->config.qmode & ~0xff) | *byteptr++;\n bytecnt -= 2;\n\n // another byte indicates a channel layout\n\n if (bytecnt) {\n int nchans, i;\n\n wpc->channel_layout = (int32_t) *byteptr++ << 16;\n bytecnt--;\n\n // another byte means we have a channel count for the layout and maybe a reordering\n\n if (bytecnt) {\n wpc->channel_layout += nchans = *byteptr++;\n bytecnt--;\n\n // any more means there's a reordering string\n\n if (bytecnt) {\n if (bytecnt > nchans)\n return FALSE;\n\n wpc->channel_reordering = malloc (nchans);\n\n // note that redundant reordering info is not stored, so we fill in the rest\n\n if (wpc->channel_reordering) {\n for (i = 0; i < nchans; ++i)\n if (bytecnt) {\n wpc->channel_reordering [i] = *byteptr++;\n\n if (wpc->channel_reordering [i] >= nchans) // make sure index is in range\n wpc->channel_reordering [i] = 0;\n\n bytecnt--;\n }\n else\n wpc->channel_reordering [i] = i;\n }\n }\n }\n else\n wpc->channel_layout += wpc->config.num_channels;\n }\n }\n\n return TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10169", "cwe_id": "CWE-125" }, { "id": 1674, "func": "static uint32_t scsi_init_iovec(SCSIDiskReq *r)\n{\n r->iov.iov_len = MIN(r->sector_count * 512, SCSI_DMA_BUF_SIZE);\n qemu_iovec_init_external(&r->qiov, &r->iov, 1);\n return r->qiov.size / 512;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-3346", "cwe_id": "CWE-119" }, { "id": 1674, "func": "static uint32_t scsi_init_iovec(SCSIDiskReq *r)\n{\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n\n if (!r->iov.iov_base) {\n r->buflen = SCSI_DMA_BUF_SIZE;\n r->iov.iov_base = qemu_blockalign(s->bs, r->buflen);\n }\n r->iov.iov_len = MIN(r->sector_count * 512, r->buflen);\n qemu_iovec_init_external(&r->qiov, &r->iov, 1);\n return r->qiov.size / 512;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-3346", "cwe_id": "CWE-119" }, { "id": 74, "func": "TfLiteStatus EvalHashtableImport(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input_resource_id_tensor =\n GetInput(context, node, kInputResourceIdTensor);\n const int resource_id = input_resource_id_tensor->data.i32[0];\n\n const TfLiteTensor* key_tensor = GetInput(context, node, kKeyTensor);\n const TfLiteTensor* value_tensor = GetInput(context, node, kValueTensor);\n\n Subgraph* subgraph = reinterpret_cast(context->impl_);\n auto& resources = subgraph->resources();\n auto* lookup = resource::GetHashtableResource(&resources, resource_id);\n TF_LITE_ENSURE(context, lookup != nullptr);\n TF_LITE_ENSURE_STATUS(\n lookup->CheckKeyAndValueTypes(context, key_tensor, value_tensor));\n // The hashtable resource will only be initialized once, attempting to\n // initialize it multiple times will be a no-op.\n auto result = lookup->Import(context, key_tensor, value_tensor);\n return result;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 74, "func": "TfLiteStatus EvalHashtableImport(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input_resource_id_tensor;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputResourceIdTensor,\n &input_resource_id_tensor));\n const int resource_id = input_resource_id_tensor->data.i32[0];\n\n const TfLiteTensor* key_tensor;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kKeyTensor, &key_tensor));\n const TfLiteTensor* value_tensor;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kValueTensor, &value_tensor));\n\n Subgraph* subgraph = reinterpret_cast(context->impl_);\n auto& resources = subgraph->resources();\n auto* lookup = resource::GetHashtableResource(&resources, resource_id);\n TF_LITE_ENSURE(context, lookup != nullptr);\n TF_LITE_ENSURE_STATUS(\n lookup->CheckKeyAndValueTypes(context, key_tensor, value_tensor));\n // The hashtable resource will only be initialized once, attempting to\n // initialize it multiple times will be a no-op.\n auto result = lookup->Import(context, key_tensor, value_tensor);\n return result;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1989, "func": "njs_vm_start(njs_vm_t *vm)\n{\n njs_int_t ret;\n\n ret = njs_module_load(vm);\n if (njs_slow_path(ret != NJS_OK)) {\n return ret;\n }\n\n ret = njs_vmcode_interpreter(vm, vm->start);\n\n return (ret == NJS_ERROR) ? NJS_ERROR : NJS_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-25139", "cwe_id": "CWE-416" }, { "id": 1989, "func": "njs_vm_start(njs_vm_t *vm)\n{\n njs_int_t ret;\n\n ret = njs_module_load(vm);\n if (njs_slow_path(ret != NJS_OK)) {\n return ret;\n }\n\n ret = njs_vmcode_interpreter(vm, vm->start, NULL, NULL);\n\n return (ret == NJS_ERROR) ? NJS_ERROR : NJS_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-25139", "cwe_id": "CWE-416" }, { "id": 1703, "func": "jpc_ms_t *jpc_getms(jas_stream_t *in, jpc_cstate_t *cstate)\n{\n\tjpc_ms_t *ms;\n\tjpc_mstabent_t *mstabent;\n\tjas_stream_t *tmpstream;\n\n\tif (!(ms = jpc_ms_create(0))) {\n\t\treturn 0;\n\t}\n\n\t/* Get the marker type. */\n\tif (jpc_getuint16(in, &ms->id) || ms->id < JPC_MS_MIN ||\n\t ms->id > JPC_MS_MAX) {\n\t\tjpc_ms_destroy(ms);\n\t\treturn 0;\n\t}\n\n\tmstabent = jpc_mstab_lookup(ms->id);\n\tms->ops = &mstabent->ops;\n\n\t/* Get the marker segment length and parameters if present. */\n\t/* Note: It is tacitly assumed that a marker segment cannot have\n\t parameters unless it has a length field. That is, there cannot\n\t be a parameters field without a length field and vice versa. */\n\tif (JPC_MS_HASPARMS(ms->id)) {\n\t\t/* Get the length of the marker segment. */\n\t\tif (jpc_getuint16(in, &ms->len) || ms->len < 3) {\n\t\t\tjpc_ms_destroy(ms);\n\t\t\treturn 0;\n\t\t}\n\t\t/* Calculate the length of the marker segment parameters. */\n\t\tms->len -= 2;\n\t\t/* Create and prepare a temporary memory stream from which to\n\t\t read the marker segment parameters. */\n\t\t/* Note: This approach provides a simple way of ensuring that\n\t\t we never read beyond the end of the marker segment (even if\n\t\t the marker segment length is errantly set too small). */\n\t\tif (!(tmpstream = jas_stream_memopen(0, 0))) {\n\t\t\tjpc_ms_destroy(ms);\n\t\t\treturn 0;\n\t\t}\n\t\tif (jas_stream_copy(tmpstream, in, ms->len) ||\n\t\t jas_stream_seek(tmpstream, 0, SEEK_SET) < 0) {\n\t\t\tjas_stream_close(tmpstream);\n\t\t\tjpc_ms_destroy(ms);\n\t\t\treturn 0;\n\t\t}\n\t\t/* Get the marker segment parameters. */\n\t\tif ((*ms->ops->getparms)(ms, cstate, tmpstream)) {\n\t\t\tms->ops = 0;\n\t\t\tjpc_ms_destroy(ms);\n\t\t\tjas_stream_close(tmpstream);\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (jas_getdbglevel() > 0) {\n\t\t\tjpc_ms_dump(ms, stderr);\n\t\t}\n\n\t\tif (JAS_CAST(ulong, jas_stream_tell(tmpstream)) != ms->len) {\n\t\t\tjas_eprintf(\n\t\t\t \"warning: trailing garbage in marker segment (%ld bytes)\\n\",\n\t\t\t ms->len - jas_stream_tell(tmpstream));\n\t\t}\n\n\t\t/* Close the temporary stream. */\n\t\tjas_stream_close(tmpstream);\n\n\t} else {\n\t\t/* There are no marker segment parameters. */\n\t\tms->len = 0;\n\n\t\tif (jas_getdbglevel() > 0) {\n\t\t\tjpc_ms_dump(ms, stderr);\n\t\t}\n\t}\n\n\t/* Update the code stream state information based on the type of\n\t marker segment read. */\n\t/* Note: This is a bit of a hack, but I'm not going to define another\n\t type of virtual function for this one special case. */\n\tif (ms->id == JPC_MS_SIZ) {\n\t\tcstate->numcomps = ms->parms.siz.numcomps;\n\t}\n\n\treturn ms;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 1703, "func": "jpc_ms_t *jpc_getms(jas_stream_t *in, jpc_cstate_t *cstate)\n{\n\tjpc_ms_t *ms;\n\tjpc_mstabent_t *mstabent;\n\tjas_stream_t *tmpstream;\n\n\tif (!(ms = jpc_ms_create(0))) {\n\t\treturn 0;\n\t}\n\n\t/* Get the marker type. */\n\tif (jpc_getuint16(in, &ms->id) || ms->id < JPC_MS_MIN ||\n\t ms->id > JPC_MS_MAX) {\n\t\tjpc_ms_destroy(ms);\n\t\treturn 0;\n\t}\n\n\tmstabent = jpc_mstab_lookup(ms->id);\n\tms->ops = &mstabent->ops;\n\n\t/* Get the marker segment length and parameters if present. */\n\t/* Note: It is tacitly assumed that a marker segment cannot have\n\t parameters unless it has a length field. That is, there cannot\n\t be a parameters field without a length field and vice versa. */\n\tif (JPC_MS_HASPARMS(ms->id)) {\n\t\t/* Get the length of the marker segment. */\n\t\tif (jpc_getuint16(in, &ms->len) || ms->len < 3) {\n\t\t\tjpc_ms_destroy(ms);\n\t\t\treturn 0;\n\t\t}\n\t\t/* Calculate the length of the marker segment parameters. */\n\t\tms->len -= 2;\n\t\t/* Create and prepare a temporary memory stream from which to\n\t\t read the marker segment parameters. */\n\t\t/* Note: This approach provides a simple way of ensuring that\n\t\t we never read beyond the end of the marker segment (even if\n\t\t the marker segment length is errantly set too small). */\n\t\tif (!(tmpstream = jas_stream_memopen(0, 0))) {\n\t\t\tjpc_ms_destroy(ms);\n\t\t\treturn 0;\n\t\t}\n\t\tif (jas_stream_copy(tmpstream, in, ms->len) ||\n\t\t jas_stream_seek(tmpstream, 0, SEEK_SET) < 0) {\n\t\t\tjas_stream_close(tmpstream);\n\t\t\tjpc_ms_destroy(ms);\n\t\t\treturn 0;\n\t\t}\n\t\t/* Get the marker segment parameters. */\n\t\tif ((*ms->ops->getparms)(ms, cstate, tmpstream)) {\n\t\t\tms->ops = 0;\n\t\t\tjpc_ms_destroy(ms);\n\t\t\tjas_stream_close(tmpstream);\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (jas_getdbglevel() > 0) {\n\t\t\tjpc_ms_dump(ms, stderr);\n\t\t}\n\n\t\tif (JAS_CAST(jas_ulong, jas_stream_tell(tmpstream)) != ms->len) {\n\t\t\tjas_eprintf(\n\t\t\t \"warning: trailing garbage in marker segment (%ld bytes)\\n\",\n\t\t\t ms->len - jas_stream_tell(tmpstream));\n\t\t}\n\n\t\t/* Close the temporary stream. */\n\t\tjas_stream_close(tmpstream);\n\n\t} else {\n\t\t/* There are no marker segment parameters. */\n\t\tms->len = 0;\n\n\t\tif (jas_getdbglevel() > 0) {\n\t\t\tjpc_ms_dump(ms, stderr);\n\t\t}\n\t}\n\n\t/* Update the code stream state information based on the type of\n\t marker segment read. */\n\t/* Note: This is a bit of a hack, but I'm not going to define another\n\t type of virtual function for this one special case. */\n\tif (ms->id == JPC_MS_SIZ) {\n\t\tcstate->numcomps = ms->parms.siz.numcomps;\n\t}\n\n\treturn ms;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 456, "func": "int sock_setsockopt(struct socket *sock, int level, int optname,\n\t\t char __user *optval, unsigned int optlen)\n{\n\tstruct sock *sk = sock->sk;\n\tint val;\n\tint valbool;\n\tstruct linger ling;\n\tint ret = 0;\n\n\t/*\n\t *\tOptions without arguments\n\t */\n\n\tif (optname == SO_BINDTODEVICE)\n\t\treturn sock_bindtodevice(sk, optval, optlen);\n\n\tif (optlen < sizeof(int))\n\t\treturn -EINVAL;\n\n\tif (get_user(val, (int __user *)optval))\n\t\treturn -EFAULT;\n\n\tvalbool = val ? 1 : 0;\n\n\tlock_sock(sk);\n\n\tswitch (optname) {\n\tcase SO_DEBUG:\n\t\tif (val && !capable(CAP_NET_ADMIN))\n\t\t\tret = -EACCES;\n\t\telse\n\t\t\tsock_valbool_flag(sk, SOCK_DBG, valbool);\n\t\tbreak;\n\tcase SO_REUSEADDR:\n\t\tsk->sk_reuse = (valbool ? SK_CAN_REUSE : SK_NO_REUSE);\n\t\tbreak;\n\tcase SO_TYPE:\n\tcase SO_PROTOCOL:\n\tcase SO_DOMAIN:\n\tcase SO_ERROR:\n\t\tret = -ENOPROTOOPT;\n\t\tbreak;\n\tcase SO_DONTROUTE:\n\t\tsock_valbool_flag(sk, SOCK_LOCALROUTE, valbool);\n\t\tbreak;\n\tcase SO_BROADCAST:\n\t\tsock_valbool_flag(sk, SOCK_BROADCAST, valbool);\n\t\tbreak;\n\tcase SO_SNDBUF:\n\t\t/* Don't error on this BSD doesn't and if you think\n\t\t about it this is right. Otherwise apps have to\n\t\t play 'guess the biggest size' games. RCVBUF/SNDBUF\n\t\t are treated in BSD as hints */\n\n\t\tif (val > sysctl_wmem_max)\n\t\t\tval = sysctl_wmem_max;\nset_sndbuf:\n\t\tsk->sk_userlocks |= SOCK_SNDBUF_LOCK;\n\t\tif ((val * 2) < SOCK_MIN_SNDBUF)\n\t\t\tsk->sk_sndbuf = SOCK_MIN_SNDBUF;\n\t\telse\n\t\t\tsk->sk_sndbuf = val * 2;\n\n\t\t/*\n\t\t *\tWake up sending tasks if we\n\t\t *\tupped the value.\n\t\t */\n\t\tsk->sk_write_space(sk);\n\t\tbreak;\n\n\tcase SO_SNDBUFFORCE:\n\t\tif (!capable(CAP_NET_ADMIN)) {\n\t\t\tret = -EPERM;\n\t\t\tbreak;\n\t\t}\n\t\tgoto set_sndbuf;\n\n\tcase SO_RCVBUF:\n\t\t/* Don't error on this BSD doesn't and if you think\n\t\t about it this is right. Otherwise apps have to\n\t\t play 'guess the biggest size' games. RCVBUF/SNDBUF\n\t\t are treated in BSD as hints */\n\n\t\tif (val > sysctl_rmem_max)\n\t\t\tval = sysctl_rmem_max;\nset_rcvbuf:\n\t\tsk->sk_userlocks |= SOCK_RCVBUF_LOCK;\n\t\t/*\n\t\t * We double it on the way in to account for\n\t\t * \"struct sk_buff\" etc. overhead. Applications\n\t\t * assume that the SO_RCVBUF setting they make will\n\t\t * allow that much actual data to be received on that\n\t\t * socket.\n\t\t *\n\t\t * Applications are unaware that \"struct sk_buff\" and\n\t\t * other overheads allocate from the receive buffer\n\t\t * during socket buffer allocation.\n\t\t *\n\t\t * And after considering the possible alternatives,\n\t\t * returning the value we actually used in getsockopt\n\t\t * is the most desirable behavior.\n\t\t */\n\t\tif ((val * 2) < SOCK_MIN_RCVBUF)\n\t\t\tsk->sk_rcvbuf = SOCK_MIN_RCVBUF;\n\t\telse\n\t\t\tsk->sk_rcvbuf = val * 2;\n\t\tbreak;\n\n\tcase SO_RCVBUFFORCE:\n\t\tif (!capable(CAP_NET_ADMIN)) {\n\t\t\tret = -EPERM;\n\t\t\tbreak;\n\t\t}\n\t\tgoto set_rcvbuf;\n\n\tcase SO_KEEPALIVE:\n#ifdef CONFIG_INET\n\t\tif (sk->sk_protocol == IPPROTO_TCP)\n\t\t\ttcp_set_keepalive(sk, valbool);\n#endif\n\t\tsock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);\n\t\tbreak;\n\n\tcase SO_OOBINLINE:\n\t\tsock_valbool_flag(sk, SOCK_URGINLINE, valbool);\n\t\tbreak;\n\n\tcase SO_NO_CHECK:\n\t\tsk->sk_no_check = valbool;\n\t\tbreak;\n\n\tcase SO_PRIORITY:\n\t\tif ((val >= 0 && val <= 6) || capable(CAP_NET_ADMIN))\n\t\t\tsk->sk_priority = val;\n\t\telse\n\t\t\tret = -EPERM;\n\t\tbreak;\n\n\tcase SO_LINGER:\n\t\tif (optlen < sizeof(ling)) {\n\t\t\tret = -EINVAL;\t/* 1003.1g */\n\t\t\tbreak;\n\t\t}\n\t\tif (copy_from_user(&ling, optval, sizeof(ling))) {\n\t\t\tret = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\t\tif (!ling.l_onoff)\n\t\t\tsock_reset_flag(sk, SOCK_LINGER);\n\t\telse {\n#if (BITS_PER_LONG == 32)\n\t\t\tif ((unsigned int)ling.l_linger >= MAX_SCHEDULE_TIMEOUT/HZ)\n\t\t\t\tsk->sk_lingertime = MAX_SCHEDULE_TIMEOUT;\n\t\t\telse\n#endif\n\t\t\t\tsk->sk_lingertime = (unsigned int)ling.l_linger * HZ;\n\t\t\tsock_set_flag(sk, SOCK_LINGER);\n\t\t}\n\t\tbreak;\n\n\tcase SO_BSDCOMPAT:\n\t\tsock_warn_obsolete_bsdism(\"setsockopt\");\n\t\tbreak;\n\n\tcase SO_PASSCRED:\n\t\tif (valbool)\n\t\t\tset_bit(SOCK_PASSCRED, &sock->flags);\n\t\telse\n\t\t\tclear_bit(SOCK_PASSCRED, &sock->flags);\n\t\tbreak;\n\n\tcase SO_TIMESTAMP:\n\tcase SO_TIMESTAMPNS:\n\t\tif (valbool) {\n\t\t\tif (optname == SO_TIMESTAMP)\n\t\t\t\tsock_reset_flag(sk, SOCK_RCVTSTAMPNS);\n\t\t\telse\n\t\t\t\tsock_set_flag(sk, SOCK_RCVTSTAMPNS);\n\t\t\tsock_set_flag(sk, SOCK_RCVTSTAMP);\n\t\t\tsock_enable_timestamp(sk, SOCK_TIMESTAMP);\n\t\t} else {\n\t\t\tsock_reset_flag(sk, SOCK_RCVTSTAMP);\n\t\t\tsock_reset_flag(sk, SOCK_RCVTSTAMPNS);\n\t\t}\n\t\tbreak;\n\n\tcase SO_TIMESTAMPING:\n\t\tif (val & ~SOF_TIMESTAMPING_MASK) {\n\t\t\tret = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_TX_HARDWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_TX_HARDWARE);\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_TX_SOFTWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_TX_SOFTWARE);\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_RX_HARDWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_RX_HARDWARE);\n\t\tif (val & SOF_TIMESTAMPING_RX_SOFTWARE)\n\t\t\tsock_enable_timestamp(sk,\n\t\t\t\t\t SOCK_TIMESTAMPING_RX_SOFTWARE);\n\t\telse\n\t\t\tsock_disable_timestamp(sk,\n\t\t\t\t\t (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE));\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_SOFTWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_SOFTWARE);\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_SYS_HARDWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_SYS_HARDWARE);\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_RAW_HARDWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_RAW_HARDWARE);\n\t\tbreak;\n\n\tcase SO_RCVLOWAT:\n\t\tif (val < 0)\n\t\t\tval = INT_MAX;\n\t\tsk->sk_rcvlowat = val ? : 1;\n\t\tbreak;\n\n\tcase SO_RCVTIMEO:\n\t\tret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen);\n\t\tbreak;\n\n\tcase SO_SNDTIMEO:\n\t\tret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen);\n\t\tbreak;\n\n\tcase SO_ATTACH_FILTER:\n\t\tret = -EINVAL;\n\t\tif (optlen == sizeof(struct sock_fprog)) {\n\t\t\tstruct sock_fprog fprog;\n\n\t\t\tret = -EFAULT;\n\t\t\tif (copy_from_user(&fprog, optval, sizeof(fprog)))\n\t\t\t\tbreak;\n\n\t\t\tret = sk_attach_filter(&fprog, sk);\n\t\t}\n\t\tbreak;\n\n\tcase SO_DETACH_FILTER:\n\t\tret = sk_detach_filter(sk);\n\t\tbreak;\n\n\tcase SO_PASSSEC:\n\t\tif (valbool)\n\t\t\tset_bit(SOCK_PASSSEC, &sock->flags);\n\t\telse\n\t\t\tclear_bit(SOCK_PASSSEC, &sock->flags);\n\t\tbreak;\n\tcase SO_MARK:\n\t\tif (!capable(CAP_NET_ADMIN))\n\t\t\tret = -EPERM;\n\t\telse\n\t\t\tsk->sk_mark = val;\n\t\tbreak;\n\n\t\t/* We implement the SO_SNDLOWAT etc to\n\t\t not be settable (1003.1g 5.3) */\n\tcase SO_RXQ_OVFL:\n\t\tsock_valbool_flag(sk, SOCK_RXQ_OVFL, valbool);\n\t\tbreak;\n\n\tcase SO_WIFI_STATUS:\n\t\tsock_valbool_flag(sk, SOCK_WIFI_STATUS, valbool);\n\t\tbreak;\n\n\tcase SO_PEEK_OFF:\n\t\tif (sock->ops->set_peek_off)\n\t\t\tsock->ops->set_peek_off(sk, val);\n\t\telse\n\t\t\tret = -EOPNOTSUPP;\n\t\tbreak;\n\n\tcase SO_NOFCS:\n\t\tsock_valbool_flag(sk, SOCK_NOFCS, valbool);\n\t\tbreak;\n\n\tdefault:\n\t\tret = -ENOPROTOOPT;\n\t\tbreak;\n\t}\n\trelease_sock(sk);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-6704", "cwe_id": "CWE-119" }, { "id": 456, "func": "int sock_setsockopt(struct socket *sock, int level, int optname,\n\t\t char __user *optval, unsigned int optlen)\n{\n\tstruct sock *sk = sock->sk;\n\tint val;\n\tint valbool;\n\tstruct linger ling;\n\tint ret = 0;\n\n\t/*\n\t *\tOptions without arguments\n\t */\n\n\tif (optname == SO_BINDTODEVICE)\n\t\treturn sock_bindtodevice(sk, optval, optlen);\n\n\tif (optlen < sizeof(int))\n\t\treturn -EINVAL;\n\n\tif (get_user(val, (int __user *)optval))\n\t\treturn -EFAULT;\n\n\tvalbool = val ? 1 : 0;\n\n\tlock_sock(sk);\n\n\tswitch (optname) {\n\tcase SO_DEBUG:\n\t\tif (val && !capable(CAP_NET_ADMIN))\n\t\t\tret = -EACCES;\n\t\telse\n\t\t\tsock_valbool_flag(sk, SOCK_DBG, valbool);\n\t\tbreak;\n\tcase SO_REUSEADDR:\n\t\tsk->sk_reuse = (valbool ? SK_CAN_REUSE : SK_NO_REUSE);\n\t\tbreak;\n\tcase SO_TYPE:\n\tcase SO_PROTOCOL:\n\tcase SO_DOMAIN:\n\tcase SO_ERROR:\n\t\tret = -ENOPROTOOPT;\n\t\tbreak;\n\tcase SO_DONTROUTE:\n\t\tsock_valbool_flag(sk, SOCK_LOCALROUTE, valbool);\n\t\tbreak;\n\tcase SO_BROADCAST:\n\t\tsock_valbool_flag(sk, SOCK_BROADCAST, valbool);\n\t\tbreak;\n\tcase SO_SNDBUF:\n\t\t/* Don't error on this BSD doesn't and if you think\n\t\t * about it this is right. Otherwise apps have to\n\t\t * play 'guess the biggest size' games. RCVBUF/SNDBUF\n\t\t * are treated in BSD as hints\n\t\t */\n\t\tval = min_t(u32, val, sysctl_wmem_max);\nset_sndbuf:\n\t\tsk->sk_userlocks |= SOCK_SNDBUF_LOCK;\n\t\tsk->sk_sndbuf = max_t(u32, val * 2, SOCK_MIN_SNDBUF);\n\t\t/* Wake up sending tasks if we upped the value. */\n\t\tsk->sk_write_space(sk);\n\t\tbreak;\n\n\tcase SO_SNDBUFFORCE:\n\t\tif (!capable(CAP_NET_ADMIN)) {\n\t\t\tret = -EPERM;\n\t\t\tbreak;\n\t\t}\n\t\tgoto set_sndbuf;\n\n\tcase SO_RCVBUF:\n\t\t/* Don't error on this BSD doesn't and if you think\n\t\t * about it this is right. Otherwise apps have to\n\t\t * play 'guess the biggest size' games. RCVBUF/SNDBUF\n\t\t * are treated in BSD as hints\n\t\t */\n\t\tval = min_t(u32, val, sysctl_rmem_max);\nset_rcvbuf:\n\t\tsk->sk_userlocks |= SOCK_RCVBUF_LOCK;\n\t\t/*\n\t\t * We double it on the way in to account for\n\t\t * \"struct sk_buff\" etc. overhead. Applications\n\t\t * assume that the SO_RCVBUF setting they make will\n\t\t * allow that much actual data to be received on that\n\t\t * socket.\n\t\t *\n\t\t * Applications are unaware that \"struct sk_buff\" and\n\t\t * other overheads allocate from the receive buffer\n\t\t * during socket buffer allocation.\n\t\t *\n\t\t * And after considering the possible alternatives,\n\t\t * returning the value we actually used in getsockopt\n\t\t * is the most desirable behavior.\n\t\t */\n\t\tsk->sk_rcvbuf = max_t(u32, val * 2, SOCK_MIN_RCVBUF);\n\t\tbreak;\n\n\tcase SO_RCVBUFFORCE:\n\t\tif (!capable(CAP_NET_ADMIN)) {\n\t\t\tret = -EPERM;\n\t\t\tbreak;\n\t\t}\n\t\tgoto set_rcvbuf;\n\n\tcase SO_KEEPALIVE:\n#ifdef CONFIG_INET\n\t\tif (sk->sk_protocol == IPPROTO_TCP)\n\t\t\ttcp_set_keepalive(sk, valbool);\n#endif\n\t\tsock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);\n\t\tbreak;\n\n\tcase SO_OOBINLINE:\n\t\tsock_valbool_flag(sk, SOCK_URGINLINE, valbool);\n\t\tbreak;\n\n\tcase SO_NO_CHECK:\n\t\tsk->sk_no_check = valbool;\n\t\tbreak;\n\n\tcase SO_PRIORITY:\n\t\tif ((val >= 0 && val <= 6) || capable(CAP_NET_ADMIN))\n\t\t\tsk->sk_priority = val;\n\t\telse\n\t\t\tret = -EPERM;\n\t\tbreak;\n\n\tcase SO_LINGER:\n\t\tif (optlen < sizeof(ling)) {\n\t\t\tret = -EINVAL;\t/* 1003.1g */\n\t\t\tbreak;\n\t\t}\n\t\tif (copy_from_user(&ling, optval, sizeof(ling))) {\n\t\t\tret = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\t\tif (!ling.l_onoff)\n\t\t\tsock_reset_flag(sk, SOCK_LINGER);\n\t\telse {\n#if (BITS_PER_LONG == 32)\n\t\t\tif ((unsigned int)ling.l_linger >= MAX_SCHEDULE_TIMEOUT/HZ)\n\t\t\t\tsk->sk_lingertime = MAX_SCHEDULE_TIMEOUT;\n\t\t\telse\n#endif\n\t\t\t\tsk->sk_lingertime = (unsigned int)ling.l_linger * HZ;\n\t\t\tsock_set_flag(sk, SOCK_LINGER);\n\t\t}\n\t\tbreak;\n\n\tcase SO_BSDCOMPAT:\n\t\tsock_warn_obsolete_bsdism(\"setsockopt\");\n\t\tbreak;\n\n\tcase SO_PASSCRED:\n\t\tif (valbool)\n\t\t\tset_bit(SOCK_PASSCRED, &sock->flags);\n\t\telse\n\t\t\tclear_bit(SOCK_PASSCRED, &sock->flags);\n\t\tbreak;\n\n\tcase SO_TIMESTAMP:\n\tcase SO_TIMESTAMPNS:\n\t\tif (valbool) {\n\t\t\tif (optname == SO_TIMESTAMP)\n\t\t\t\tsock_reset_flag(sk, SOCK_RCVTSTAMPNS);\n\t\t\telse\n\t\t\t\tsock_set_flag(sk, SOCK_RCVTSTAMPNS);\n\t\t\tsock_set_flag(sk, SOCK_RCVTSTAMP);\n\t\t\tsock_enable_timestamp(sk, SOCK_TIMESTAMP);\n\t\t} else {\n\t\t\tsock_reset_flag(sk, SOCK_RCVTSTAMP);\n\t\t\tsock_reset_flag(sk, SOCK_RCVTSTAMPNS);\n\t\t}\n\t\tbreak;\n\n\tcase SO_TIMESTAMPING:\n\t\tif (val & ~SOF_TIMESTAMPING_MASK) {\n\t\t\tret = -EINVAL;\n\t\t\tbreak;\n\t\t}\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_TX_HARDWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_TX_HARDWARE);\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_TX_SOFTWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_TX_SOFTWARE);\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_RX_HARDWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_RX_HARDWARE);\n\t\tif (val & SOF_TIMESTAMPING_RX_SOFTWARE)\n\t\t\tsock_enable_timestamp(sk,\n\t\t\t\t\t SOCK_TIMESTAMPING_RX_SOFTWARE);\n\t\telse\n\t\t\tsock_disable_timestamp(sk,\n\t\t\t\t\t (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE));\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_SOFTWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_SOFTWARE);\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_SYS_HARDWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_SYS_HARDWARE);\n\t\tsock_valbool_flag(sk, SOCK_TIMESTAMPING_RAW_HARDWARE,\n\t\t\t\t val & SOF_TIMESTAMPING_RAW_HARDWARE);\n\t\tbreak;\n\n\tcase SO_RCVLOWAT:\n\t\tif (val < 0)\n\t\t\tval = INT_MAX;\n\t\tsk->sk_rcvlowat = val ? : 1;\n\t\tbreak;\n\n\tcase SO_RCVTIMEO:\n\t\tret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen);\n\t\tbreak;\n\n\tcase SO_SNDTIMEO:\n\t\tret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen);\n\t\tbreak;\n\n\tcase SO_ATTACH_FILTER:\n\t\tret = -EINVAL;\n\t\tif (optlen == sizeof(struct sock_fprog)) {\n\t\t\tstruct sock_fprog fprog;\n\n\t\t\tret = -EFAULT;\n\t\t\tif (copy_from_user(&fprog, optval, sizeof(fprog)))\n\t\t\t\tbreak;\n\n\t\t\tret = sk_attach_filter(&fprog, sk);\n\t\t}\n\t\tbreak;\n\n\tcase SO_DETACH_FILTER:\n\t\tret = sk_detach_filter(sk);\n\t\tbreak;\n\n\tcase SO_PASSSEC:\n\t\tif (valbool)\n\t\t\tset_bit(SOCK_PASSSEC, &sock->flags);\n\t\telse\n\t\t\tclear_bit(SOCK_PASSSEC, &sock->flags);\n\t\tbreak;\n\tcase SO_MARK:\n\t\tif (!capable(CAP_NET_ADMIN))\n\t\t\tret = -EPERM;\n\t\telse\n\t\t\tsk->sk_mark = val;\n\t\tbreak;\n\n\t\t/* We implement the SO_SNDLOWAT etc to\n\t\t not be settable (1003.1g 5.3) */\n\tcase SO_RXQ_OVFL:\n\t\tsock_valbool_flag(sk, SOCK_RXQ_OVFL, valbool);\n\t\tbreak;\n\n\tcase SO_WIFI_STATUS:\n\t\tsock_valbool_flag(sk, SOCK_WIFI_STATUS, valbool);\n\t\tbreak;\n\n\tcase SO_PEEK_OFF:\n\t\tif (sock->ops->set_peek_off)\n\t\t\tsock->ops->set_peek_off(sk, val);\n\t\telse\n\t\t\tret = -EOPNOTSUPP;\n\t\tbreak;\n\n\tcase SO_NOFCS:\n\t\tsock_valbool_flag(sk, SOCK_NOFCS, valbool);\n\t\tbreak;\n\n\tdefault:\n\t\tret = -ENOPROTOOPT;\n\t\tbreak;\n\t}\n\trelease_sock(sk);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-6704", "cwe_id": "CWE-119" }, { "id": 137, "func": "static int ssl_parse_server_psk_hint( mbedtls_ssl_context *ssl,\n unsigned char **p,\n unsigned char *end )\n{\n int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;\n size_t len;\n ((void) ssl);\n\n /*\n * PSK parameters:\n *\n * opaque psk_identity_hint<0..2^16-1>;\n */\n if( (*p) > end - 2 )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad server key exchange message \"\n \"(psk_identity_hint length)\" ) );\n return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );\n }\n len = (*p)[0] << 8 | (*p)[1];\n *p += 2;\n\n if( (*p) + len > end )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad server key exchange message \"\n \"(psk_identity_hint length)\" ) );\n return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );\n }\n\n /*\n * Note: we currently ignore the PKS identity hint, as we only allow one\n * PSK to be provisionned on the client. This could be changed later if\n * someone needs that feature.\n */\n *p += len;\n ret = 0;\n\n return( ret );\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-9989", "cwe_id": "CWE-125" }, { "id": 137, "func": "static int ssl_parse_server_psk_hint( mbedtls_ssl_context *ssl,\n unsigned char **p,\n unsigned char *end )\n{\n int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;\n size_t len;\n ((void) ssl);\n\n /*\n * PSK parameters:\n *\n * opaque psk_identity_hint<0..2^16-1>;\n */\n if( (*p) > end - 2 )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad server key exchange message \"\n \"(psk_identity_hint length)\" ) );\n return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );\n }\n len = (*p)[0] << 8 | (*p)[1];\n *p += 2;\n\n if( (*p) > end - len )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad server key exchange message \"\n \"(psk_identity_hint length)\" ) );\n return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );\n }\n\n /*\n * Note: we currently ignore the PKS identity hint, as we only allow one\n * PSK to be provisionned on the client. This could be changed later if\n * someone needs that feature.\n */\n *p += len;\n ret = 0;\n\n return( ret );\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-9989", "cwe_id": "CWE-125" }, { "id": 2051, "func": "static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)\n{\n\tstruct bpf_reg_state *regs = cur_regs(env);\n\tu8 opcode = BPF_OP(insn->code);\n\tint err;\n\n\tif (opcode == BPF_END || opcode == BPF_NEG) {\n\t\tif (opcode == BPF_NEG) {\n\t\t\tif (BPF_SRC(insn->code) != 0 ||\n\t\t\t insn->src_reg != BPF_REG_0 ||\n\t\t\t insn->off != 0 || insn->imm != 0) {\n\t\t\t\tverbose(env, \"BPF_NEG uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t} else {\n\t\t\tif (insn->src_reg != BPF_REG_0 || insn->off != 0 ||\n\t\t\t (insn->imm != 16 && insn->imm != 32 && insn->imm != 64) ||\n\t\t\t BPF_CLASS(insn->code) == BPF_ALU64) {\n\t\t\t\tverbose(env, \"BPF_END uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\n\t\t/* check src operand */\n\t\terr = check_reg_arg(env, insn->dst_reg, SRC_OP);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tif (is_pointer_value(env, insn->dst_reg)) {\n\t\t\tverbose(env, \"R%d pointer arithmetic prohibited\\n\",\n\t\t\t\tinsn->dst_reg);\n\t\t\treturn -EACCES;\n\t\t}\n\n\t\t/* check dest operand */\n\t\terr = check_reg_arg(env, insn->dst_reg, DST_OP);\n\t\tif (err)\n\t\t\treturn err;\n\n\t} else if (opcode == BPF_MOV) {\n\n\t\tif (BPF_SRC(insn->code) == BPF_X) {\n\t\t\tif (insn->imm != 0 || insn->off != 0) {\n\t\t\t\tverbose(env, \"BPF_MOV uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\t/* check src operand */\n\t\t\terr = check_reg_arg(env, insn->src_reg, SRC_OP);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t} else {\n\t\t\tif (insn->src_reg != BPF_REG_0 || insn->off != 0) {\n\t\t\t\tverbose(env, \"BPF_MOV uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\n\t\t/* check dest operand */\n\t\terr = check_reg_arg(env, insn->dst_reg, DST_OP);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tif (BPF_SRC(insn->code) == BPF_X) {\n\t\t\tif (BPF_CLASS(insn->code) == BPF_ALU64) {\n\t\t\t\t/* case: R1 = R2\n\t\t\t\t * copy register state to dest reg\n\t\t\t\t */\n\t\t\t\tregs[insn->dst_reg] = regs[insn->src_reg];\n\t\t\t\tregs[insn->dst_reg].live |= REG_LIVE_WRITTEN;\n\t\t\t} else {\n\t\t\t\t/* R1 = (u32) R2 */\n\t\t\t\tif (is_pointer_value(env, insn->src_reg)) {\n\t\t\t\t\tverbose(env,\n\t\t\t\t\t\t\"R%d partial copy of pointer\\n\",\n\t\t\t\t\t\tinsn->src_reg);\n\t\t\t\t\treturn -EACCES;\n\t\t\t\t}\n\t\t\t\tmark_reg_unknown(env, regs, insn->dst_reg);\n\t\t\t\t/* high 32 bits are known zero. */\n\t\t\t\tregs[insn->dst_reg].var_off = tnum_cast(\n\t\t\t\t\t\tregs[insn->dst_reg].var_off, 4);\n\t\t\t\t__update_reg_bounds(®s[insn->dst_reg]);\n\t\t\t}\n\t\t} else {\n\t\t\t/* case: R = imm\n\t\t\t * remember the value we stored into this reg\n\t\t\t */\n\t\t\tregs[insn->dst_reg].type = SCALAR_VALUE;\n\t\t\t__mark_reg_known(regs + insn->dst_reg, insn->imm);\n\t\t}\n\n\t} else if (opcode > BPF_END) {\n\t\tverbose(env, \"invalid BPF_ALU opcode %x\\n\", opcode);\n\t\treturn -EINVAL;\n\n\t} else {\t/* all other ALU ops: and, sub, xor, add, ... */\n\n\t\tif (BPF_SRC(insn->code) == BPF_X) {\n\t\t\tif (insn->imm != 0 || insn->off != 0) {\n\t\t\t\tverbose(env, \"BPF_ALU uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\t/* check src1 operand */\n\t\t\terr = check_reg_arg(env, insn->src_reg, SRC_OP);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t} else {\n\t\t\tif (insn->src_reg != BPF_REG_0 || insn->off != 0) {\n\t\t\t\tverbose(env, \"BPF_ALU uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\n\t\t/* check src2 operand */\n\t\terr = check_reg_arg(env, insn->dst_reg, SRC_OP);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tif ((opcode == BPF_MOD || opcode == BPF_DIV) &&\n\t\t BPF_SRC(insn->code) == BPF_K && insn->imm == 0) {\n\t\t\tverbose(env, \"div by zero\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif ((opcode == BPF_LSH || opcode == BPF_RSH ||\n\t\t opcode == BPF_ARSH) && BPF_SRC(insn->code) == BPF_K) {\n\t\t\tint size = BPF_CLASS(insn->code) == BPF_ALU64 ? 64 : 32;\n\n\t\t\tif (insn->imm < 0 || insn->imm >= size) {\n\t\t\t\tverbose(env, \"invalid shift %d\\n\", insn->imm);\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\n\t\t/* check dest operand */\n\t\terr = check_reg_arg(env, insn->dst_reg, DST_OP_NO_MARK);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\treturn adjust_reg_min_max_vals(env, insn);\n\t}\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-16995", "cwe_id": "CWE-119" }, { "id": 2051, "func": "static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)\n{\n\tstruct bpf_reg_state *regs = cur_regs(env);\n\tu8 opcode = BPF_OP(insn->code);\n\tint err;\n\n\tif (opcode == BPF_END || opcode == BPF_NEG) {\n\t\tif (opcode == BPF_NEG) {\n\t\t\tif (BPF_SRC(insn->code) != 0 ||\n\t\t\t insn->src_reg != BPF_REG_0 ||\n\t\t\t insn->off != 0 || insn->imm != 0) {\n\t\t\t\tverbose(env, \"BPF_NEG uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t} else {\n\t\t\tif (insn->src_reg != BPF_REG_0 || insn->off != 0 ||\n\t\t\t (insn->imm != 16 && insn->imm != 32 && insn->imm != 64) ||\n\t\t\t BPF_CLASS(insn->code) == BPF_ALU64) {\n\t\t\t\tverbose(env, \"BPF_END uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\n\t\t/* check src operand */\n\t\terr = check_reg_arg(env, insn->dst_reg, SRC_OP);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tif (is_pointer_value(env, insn->dst_reg)) {\n\t\t\tverbose(env, \"R%d pointer arithmetic prohibited\\n\",\n\t\t\t\tinsn->dst_reg);\n\t\t\treturn -EACCES;\n\t\t}\n\n\t\t/* check dest operand */\n\t\terr = check_reg_arg(env, insn->dst_reg, DST_OP);\n\t\tif (err)\n\t\t\treturn err;\n\n\t} else if (opcode == BPF_MOV) {\n\n\t\tif (BPF_SRC(insn->code) == BPF_X) {\n\t\t\tif (insn->imm != 0 || insn->off != 0) {\n\t\t\t\tverbose(env, \"BPF_MOV uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\n\t\t\t/* check src operand */\n\t\t\terr = check_reg_arg(env, insn->src_reg, SRC_OP);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t} else {\n\t\t\tif (insn->src_reg != BPF_REG_0 || insn->off != 0) {\n\t\t\t\tverbose(env, \"BPF_MOV uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\n\t\t/* check dest operand */\n\t\terr = check_reg_arg(env, insn->dst_reg, DST_OP);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tif (BPF_SRC(insn->code) == BPF_X) {\n\t\t\tif (BPF_CLASS(insn->code) == BPF_ALU64) {\n\t\t\t\t/* case: R1 = R2\n\t\t\t\t * copy register state to dest reg\n\t\t\t\t */\n\t\t\t\tregs[insn->dst_reg] = regs[insn->src_reg];\n\t\t\t\tregs[insn->dst_reg].live |= REG_LIVE_WRITTEN;\n\t\t\t} else {\n\t\t\t\t/* R1 = (u32) R2 */\n\t\t\t\tif (is_pointer_value(env, insn->src_reg)) {\n\t\t\t\t\tverbose(env,\n\t\t\t\t\t\t\"R%d partial copy of pointer\\n\",\n\t\t\t\t\t\tinsn->src_reg);\n\t\t\t\t\treturn -EACCES;\n\t\t\t\t}\n\t\t\t\tmark_reg_unknown(env, regs, insn->dst_reg);\n\t\t\t\t/* high 32 bits are known zero. */\n\t\t\t\tregs[insn->dst_reg].var_off = tnum_cast(\n\t\t\t\t\t\tregs[insn->dst_reg].var_off, 4);\n\t\t\t\t__update_reg_bounds(®s[insn->dst_reg]);\n\t\t\t}\n\t\t} else {\n\t\t\t/* case: R = imm\n\t\t\t * remember the value we stored into this reg\n\t\t\t */\n\t\t\tregs[insn->dst_reg].type = SCALAR_VALUE;\n\t\t\tif (BPF_CLASS(insn->code) == BPF_ALU64) {\n\t\t\t\t__mark_reg_known(regs + insn->dst_reg,\n\t\t\t\t\t\t insn->imm);\n\t\t\t} else {\n\t\t\t\t__mark_reg_known(regs + insn->dst_reg,\n\t\t\t\t\t\t (u32)insn->imm);\n\t\t\t}\n\t\t}\n\n\t} else if (opcode > BPF_END) {\n\t\tverbose(env, \"invalid BPF_ALU opcode %x\\n\", opcode);\n\t\treturn -EINVAL;\n\n\t} else {\t/* all other ALU ops: and, sub, xor, add, ... */\n\n\t\tif (BPF_SRC(insn->code) == BPF_X) {\n\t\t\tif (insn->imm != 0 || insn->off != 0) {\n\t\t\t\tverbose(env, \"BPF_ALU uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\t/* check src1 operand */\n\t\t\terr = check_reg_arg(env, insn->src_reg, SRC_OP);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t} else {\n\t\t\tif (insn->src_reg != BPF_REG_0 || insn->off != 0) {\n\t\t\t\tverbose(env, \"BPF_ALU uses reserved fields\\n\");\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\n\t\t/* check src2 operand */\n\t\terr = check_reg_arg(env, insn->dst_reg, SRC_OP);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tif ((opcode == BPF_MOD || opcode == BPF_DIV) &&\n\t\t BPF_SRC(insn->code) == BPF_K && insn->imm == 0) {\n\t\t\tverbose(env, \"div by zero\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tif ((opcode == BPF_LSH || opcode == BPF_RSH ||\n\t\t opcode == BPF_ARSH) && BPF_SRC(insn->code) == BPF_K) {\n\t\t\tint size = BPF_CLASS(insn->code) == BPF_ALU64 ? 64 : 32;\n\n\t\t\tif (insn->imm < 0 || insn->imm >= size) {\n\t\t\t\tverbose(env, \"invalid shift %d\\n\", insn->imm);\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t}\n\n\t\t/* check dest operand */\n\t\terr = check_reg_arg(env, insn->dst_reg, DST_OP_NO_MARK);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\treturn adjust_reg_min_max_vals(env, insn);\n\t}\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-16995", "cwe_id": "CWE-119" }, { "id": 1926, "func": "int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool do_optimize)\n{\n int error=0;\n uint local_testflag=param.testflag;\n bool optimize_done= !do_optimize, statistics_done=0;\n const char *old_proc_info=thd->proc_info;\n char fixed_name[FN_REFLEN];\n MYISAM_SHARE* share = file->s;\n ha_rows rows= file->state->records;\n DBUG_ENTER(\"ha_myisam::repair\");\n\n param.db_name= table->s->db.str;\n param.table_name= table->alias;\n param.using_global_keycache = 1;\n param.thd= thd;\n param.tmpdir= &mysql_tmpdir_list;\n param.out_flag= 0;\n strmov(fixed_name,file->filename);\n\n // Release latches since this can take a long time\n ha_release_temporary_latches(thd);\n\n // Don't lock tables if we have used LOCK TABLE\n if (! thd->locked_tables_mode &&\n mi_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK))\n {\n mi_check_print_error(¶m,ER(ER_CANT_LOCK),my_errno);\n DBUG_RETURN(HA_ADMIN_FAILED);\n }\n\n if (!do_optimize ||\n ((file->state->del || share->state.split != file->state->records) &&\n (!(param.testflag & T_QUICK) ||\n\t!(share->state.changed & STATE_NOT_OPTIMIZED_KEYS))))\n {\n ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ?\n\t\t\tmi_get_mask_all_keys_active(share->base.keys) :\n\t\t\tshare->state.key_map);\n uint testflag=param.testflag;\n#ifdef HAVE_MMAP\n bool remap= test(share->file_map);\n /*\n mi_repair*() functions family use file I/O even if memory\n mapping is available.\n\n Since mixing mmap I/O and file I/O may cause various artifacts,\n memory mapping must be disabled.\n */\n if (remap)\n mi_munmap_file(file);\n#endif\n if (mi_test_if_sort_rep(file,file->state->records,key_map,0) &&\n\t(local_testflag & T_REP_BY_SORT))\n {\n local_testflag|= T_STATISTICS;\n param.testflag|= T_STATISTICS;\t\t// We get this for free\n statistics_done=1;\n if (THDVAR(thd, repair_threads)>1)\n {\n char buf[40];\n /* TODO: respect myisam_repair_threads variable */\n my_snprintf(buf, 40, \"Repair with %d threads\", my_count_bits(key_map));\n thd_proc_info(thd, buf);\n error = mi_repair_parallel(¶m, file, fixed_name,\n param.testflag & T_QUICK);\n thd_proc_info(thd, \"Repair done\"); // to reset proc_info, as\n // it was pointing to local buffer\n }\n else\n {\n thd_proc_info(thd, \"Repair by sorting\");\n error = mi_repair_by_sort(¶m, file, fixed_name,\n param.testflag & T_QUICK);\n }\n }\n else\n {\n thd_proc_info(thd, \"Repair with keycache\");\n param.testflag &= ~T_REP_BY_SORT;\n error= mi_repair(¶m, file, fixed_name,\n\t\t\tparam.testflag & T_QUICK);\n }\n#ifdef HAVE_MMAP\n if (remap)\n mi_dynmap_file(file, file->state->data_file_length);\n#endif\n param.testflag=testflag;\n optimize_done=1;\n }\n if (!error)\n {\n if ((local_testflag & T_SORT_INDEX) &&\n\t(share->state.changed & STATE_NOT_SORTED_PAGES))\n {\n optimize_done=1;\n thd_proc_info(thd, \"Sorting index\");\n error=mi_sort_index(¶m,file,fixed_name);\n }\n if (!statistics_done && (local_testflag & T_STATISTICS))\n {\n if (share->state.changed & STATE_NOT_ANALYZED)\n {\n\toptimize_done=1;\n\tthd_proc_info(thd, \"Analyzing\");\n\terror = chk_key(¶m, file);\n }\n else\n\tlocal_testflag&= ~T_STATISTICS;\t\t// Don't update statistics\n }\n }\n thd_proc_info(thd, \"Saving state\");\n if (!error)\n {\n if ((share->state.changed & STATE_CHANGED) || mi_is_crashed(file))\n {\n share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |\n\t\t\t STATE_CRASHED_ON_REPAIR);\n file->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;\n }\n /*\n the following 'if', thought conceptually wrong,\n is a useful optimization nevertheless.\n */\n if (file->state != &file->s->state.state)\n file->s->state.state = *file->state;\n if (file->s->base.auto_key)\n update_auto_increment_key(¶m, file, 1);\n if (optimize_done)\n error = update_state_info(¶m, file,\n\t\t\t\tUPDATE_TIME | UPDATE_OPEN_COUNT |\n\t\t\t\t(local_testflag &\n\t\t\t\t T_STATISTICS ? UPDATE_STAT : 0));\n info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |\n\t HA_STATUS_CONST);\n if (rows != file->state->records && ! (param.testflag & T_VERY_SILENT))\n {\n char llbuff[22],llbuff2[22];\n mi_check_print_warning(¶m,\"Number of rows changed from %s to %s\",\n\t\t\t llstr(rows,llbuff),\n\t\t\t llstr(file->state->records,llbuff2));\n }\n }\n else\n {\n mi_mark_crashed_on_repair(file);\n file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;\n update_state_info(¶m, file, 0);\n }\n thd_proc_info(thd, old_proc_info);\n if (! thd->locked_tables_mode)\n mi_lock_database(file,F_UNLCK);\n DBUG_RETURN(error ? HA_ADMIN_FAILED :\n\t !optimize_done ? HA_ADMIN_ALREADY_DONE : HA_ADMIN_OK);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-6663", "cwe_id": "CWE-362" }, { "id": 1926, "func": "int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool do_optimize)\n{\n int error=0;\n uint local_testflag=param.testflag;\n bool optimize_done= !do_optimize, statistics_done=0;\n const char *old_proc_info=thd->proc_info;\n char fixed_name[FN_REFLEN];\n MYISAM_SHARE* share = file->s;\n ha_rows rows= file->state->records;\n DBUG_ENTER(\"ha_myisam::repair\");\n\n param.db_name= table->s->db.str;\n param.table_name= table->alias;\n param.using_global_keycache = 1;\n param.thd= thd;\n param.tmpdir= &mysql_tmpdir_list;\n param.out_flag= 0;\n strmov(fixed_name,file->filename);\n\n // Release latches since this can take a long time\n ha_release_temporary_latches(thd);\n\n // Don't lock tables if we have used LOCK TABLE\n if (! thd->locked_tables_mode &&\n mi_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK))\n {\n mi_check_print_error(¶m,ER(ER_CANT_LOCK),my_errno);\n DBUG_RETURN(HA_ADMIN_FAILED);\n }\n\n if (!do_optimize ||\n ((file->state->del || share->state.split != file->state->records) &&\n (!(param.testflag & T_QUICK) ||\n\t!(share->state.changed & STATE_NOT_OPTIMIZED_KEYS))))\n {\n ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ?\n\t\t\tmi_get_mask_all_keys_active(share->base.keys) :\n\t\t\tshare->state.key_map);\n uint testflag=param.testflag;\n#ifdef HAVE_MMAP\n bool remap= test(share->file_map);\n /*\n mi_repair*() functions family use file I/O even if memory\n mapping is available.\n\n Since mixing mmap I/O and file I/O may cause various artifacts,\n memory mapping must be disabled.\n */\n if (remap)\n mi_munmap_file(file);\n#endif\n if (mi_test_if_sort_rep(file,file->state->records,key_map,0) &&\n\t(local_testflag & T_REP_BY_SORT))\n {\n local_testflag|= T_STATISTICS;\n param.testflag|= T_STATISTICS;\t\t// We get this for free\n statistics_done=1;\n if (THDVAR(thd, repair_threads)>1)\n {\n char buf[40];\n /* TODO: respect myisam_repair_threads variable */\n my_snprintf(buf, 40, \"Repair with %d threads\", my_count_bits(key_map));\n thd_proc_info(thd, buf);\n /*\n The new file is created with the right stats, so we can skip\n copying file stats from old to new.\n */\n error = mi_repair_parallel(¶m, file, fixed_name,\n param.testflag & T_QUICK, TRUE);\n thd_proc_info(thd, \"Repair done\"); // to reset proc_info, as\n // it was pointing to local buffer\n }\n else\n {\n thd_proc_info(thd, \"Repair by sorting\");\n /*\n The new file is created with the right stats, so we can skip\n copying file stats from old to new.\n */\n error = mi_repair_by_sort(¶m, file, fixed_name,\n param.testflag & T_QUICK, TRUE);\n }\n }\n else\n {\n thd_proc_info(thd, \"Repair with keycache\");\n param.testflag &= ~T_REP_BY_SORT;\n /*\n The new file is created with the right stats, so we can skip\n copying file stats from old to new.\n */\n error= mi_repair(¶m, file, fixed_name,\n\t\t\tparam.testflag & T_QUICK, TRUE);\n }\n#ifdef HAVE_MMAP\n if (remap)\n mi_dynmap_file(file, file->state->data_file_length);\n#endif\n param.testflag=testflag;\n optimize_done=1;\n }\n if (!error)\n {\n if ((local_testflag & T_SORT_INDEX) &&\n\t(share->state.changed & STATE_NOT_SORTED_PAGES))\n {\n optimize_done=1;\n thd_proc_info(thd, \"Sorting index\");\n /*\n The new file is created with the right stats, so we can skip\n copying file stats from old to new.\n */\n error=mi_sort_index(¶m,file,fixed_name, TRUE);\n }\n if (!statistics_done && (local_testflag & T_STATISTICS))\n {\n if (share->state.changed & STATE_NOT_ANALYZED)\n {\n\toptimize_done=1;\n\tthd_proc_info(thd, \"Analyzing\");\n\terror = chk_key(¶m, file);\n }\n else\n\tlocal_testflag&= ~T_STATISTICS;\t\t// Don't update statistics\n }\n }\n thd_proc_info(thd, \"Saving state\");\n if (!error)\n {\n if ((share->state.changed & STATE_CHANGED) || mi_is_crashed(file))\n {\n share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |\n\t\t\t STATE_CRASHED_ON_REPAIR);\n file->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;\n }\n /*\n the following 'if', thought conceptually wrong,\n is a useful optimization nevertheless.\n */\n if (file->state != &file->s->state.state)\n file->s->state.state = *file->state;\n if (file->s->base.auto_key)\n update_auto_increment_key(¶m, file, 1);\n if (optimize_done)\n error = update_state_info(¶m, file,\n\t\t\t\tUPDATE_TIME | UPDATE_OPEN_COUNT |\n\t\t\t\t(local_testflag &\n\t\t\t\t T_STATISTICS ? UPDATE_STAT : 0));\n info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |\n\t HA_STATUS_CONST);\n if (rows != file->state->records && ! (param.testflag & T_VERY_SILENT))\n {\n char llbuff[22],llbuff2[22];\n mi_check_print_warning(¶m,\"Number of rows changed from %s to %s\",\n\t\t\t llstr(rows,llbuff),\n\t\t\t llstr(file->state->records,llbuff2));\n }\n }\n else\n {\n mi_mark_crashed_on_repair(file);\n file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;\n update_state_info(¶m, file, 0);\n }\n thd_proc_info(thd, old_proc_info);\n if (! thd->locked_tables_mode)\n mi_lock_database(file,F_UNLCK);\n DBUG_RETURN(error ? HA_ADMIN_FAILED :\n\t !optimize_done ? HA_ADMIN_ALREADY_DONE : HA_ADMIN_OK);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-6663", "cwe_id": "CWE-362" }, { "id": 2634, "func": "nv_replace(cmdarg_T *cap)\n{\n char_u\t*ptr;\n int\t\thad_ctrl_v;\n long\tn;\n\n if (checkclearop(cap->oap))\n\treturn;\n#ifdef FEAT_JOB_CHANNEL\n if (bt_prompt(curbuf) && !prompt_curpos_editable())\n {\n\tclearopbeep(cap->oap);\n\treturn;\n }\n#endif\n\n // get another character\n if (cap->nchar == Ctrl_V)\n {\n\thad_ctrl_v = Ctrl_V;\n\tcap->nchar = get_literal(FALSE);\n\t// Don't redo a multibyte character with CTRL-V.\n\tif (cap->nchar > DEL)\n\t had_ctrl_v = NUL;\n }\n else\n\thad_ctrl_v = NUL;\n\n // Abort if the character is a special key.\n if (IS_SPECIAL(cap->nchar))\n {\n\tclearopbeep(cap->oap);\n\treturn;\n }\n\n // Visual mode \"r\"\n if (VIsual_active)\n {\n\tif (got_int)\n\t reset_VIsual();\n\tif (had_ctrl_v)\n\t{\n\t // Use a special (negative) number to make a difference between a\n\t // literal CR or NL and a line break.\n\t if (cap->nchar == CAR)\n\t\tcap->nchar = REPLACE_CR_NCHAR;\n\t else if (cap->nchar == NL)\n\t\tcap->nchar = REPLACE_NL_NCHAR;\n\t}\n\tnv_operator(cap);\n\treturn;\n }\n\n // Break tabs, etc.\n if (virtual_active())\n {\n\tif (u_save_cursor() == FAIL)\n\t return;\n\tif (gchar_cursor() == NUL)\n\t{\n\t // Add extra space and put the cursor on the first one.\n\t coladvance_force((colnr_T)(getviscol() + cap->count1));\n\t curwin->w_cursor.col -= cap->count1;\n\t}\n\telse if (gchar_cursor() == TAB)\n\t coladvance_force(getviscol());\n }\n\n // Abort if not enough characters to replace.\n ptr = ml_get_cursor();\n if (STRLEN(ptr) < (unsigned)cap->count1\n\t || (has_mbyte && mb_charlen(ptr) < cap->count1))\n {\n\tclearopbeep(cap->oap);\n\treturn;\n }\n\n /*\n * Replacing with a TAB is done by edit() when it is complicated because\n * 'expandtab' or 'smarttab' is set. CTRL-V TAB inserts a literal TAB.\n * Other characters are done below to avoid problems with things like\n * CTRL-V 048 (for edit() this would be R CTRL-V 0 ESC).\n */\n if (had_ctrl_v != Ctrl_V && cap->nchar == '\\t' && (curbuf->b_p_et || p_sta))\n {\n\tstuffnumReadbuff(cap->count1);\n\tstuffcharReadbuff('R');\n\tstuffcharReadbuff('\\t');\n\tstuffcharReadbuff(ESC);\n\treturn;\n }\n\n // save line for undo\n if (u_save_cursor() == FAIL)\n\treturn;\n\n if (had_ctrl_v != Ctrl_V && (cap->nchar == '\\r' || cap->nchar == '\\n'))\n {\n\t/*\n\t * Replace character(s) by a single newline.\n\t * Strange vi behaviour: Only one newline is inserted.\n\t * Delete the characters here.\n\t * Insert the newline with an insert command, takes care of\n\t * autoindent.\tThe insert command depends on being on the last\n\t * character of a line or not.\n\t */\n\t(void)del_chars(cap->count1, FALSE);\t// delete the characters\n\tstuffcharReadbuff('\\r');\n\tstuffcharReadbuff(ESC);\n\n\t// Give 'r' to edit(), to get the redo command right.\n\tinvoke_edit(cap, TRUE, 'r', FALSE);\n }\n else\n {\n\tprep_redo(cap->oap->regname, cap->count1,\n\t\t\t\t NUL, 'r', NUL, had_ctrl_v, cap->nchar);\n\n\tcurbuf->b_op_start = curwin->w_cursor;\n\tif (has_mbyte)\n\t{\n\t int\t\told_State = State;\n\n\t if (cap->ncharC1 != 0)\n\t\tAppendCharToRedobuff(cap->ncharC1);\n\t if (cap->ncharC2 != 0)\n\t\tAppendCharToRedobuff(cap->ncharC2);\n\n\t // This is slow, but it handles replacing a single-byte with a\n\t // multi-byte and the other way around. Also handles adding\n\t // composing characters for utf-8.\n\t for (n = cap->count1; n > 0; --n)\n\t {\n\t\tState = REPLACE;\n\t\tif (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)\n\t\t{\n\t\t int c = ins_copychar(curwin->w_cursor.lnum\n\t\t\t\t\t + (cap->nchar == Ctrl_Y ? -1 : 1));\n\t\t if (c != NUL)\n\t\t\tins_char(c);\n\t\t else\n\t\t\t// will be decremented further down\n\t\t\t++curwin->w_cursor.col;\n\t\t}\n\t\telse\n\t\t ins_char(cap->nchar);\n\t\tState = old_State;\n\t\tif (cap->ncharC1 != 0)\n\t\t ins_char(cap->ncharC1);\n\t\tif (cap->ncharC2 != 0)\n\t\t ins_char(cap->ncharC2);\n\t }\n\t}\n\telse\n\t{\n\t /*\n\t * Replace the characters within one line.\n\t */\n\t for (n = cap->count1; n > 0; --n)\n\t {\n\t\t/*\n\t\t * Get ptr again, because u_save and/or showmatch() will have\n\t\t * released the line. At the same time we let know that the\n\t\t * line will be changed.\n\t\t */\n\t\tptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);\n\t\tif (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)\n\t\t{\n\t\t int c = ins_copychar(curwin->w_cursor.lnum\n\t\t\t\t\t + (cap->nchar == Ctrl_Y ? -1 : 1));\n\t\t if (c != NUL)\n\t\t ptr[curwin->w_cursor.col] = c;\n\t\t}\n\t\telse\n\t\t ptr[curwin->w_cursor.col] = cap->nchar;\n\t\tif (p_sm && msg_silent == 0)\n\t\t showmatch(cap->nchar);\n\t\t++curwin->w_cursor.col;\n\t }\n#ifdef FEAT_NETBEANS_INTG\n\t if (netbeans_active())\n\t {\n\t\tcolnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1);\n\n\t\tnetbeans_removed(curbuf, curwin->w_cursor.lnum, start,\n\t\t\t\t\t\t\t (long)cap->count1);\n\t\tnetbeans_inserted(curbuf, curwin->w_cursor.lnum, start,\n\t\t\t\t\t &ptr[start], (int)cap->count1);\n\t }\n#endif\n\n\t // mark the buffer as changed and prepare for displaying\n\t changed_bytes(curwin->w_cursor.lnum,\n\t\t\t (colnr_T)(curwin->w_cursor.col - cap->count1));\n\t}\n\t--curwin->w_cursor.col;\t // cursor on the last replaced char\n\t// if the character on the left of the current cursor is a multi-byte\n\t// character, move two characters left\n\tif (has_mbyte)\n\t mb_adjust_cursor();\n\tcurbuf->b_op_end = curwin->w_cursor;\n\tcurwin->w_set_curswant = TRUE;\n\tset_last_insert(cap->nchar);\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-3796", "cwe_id": "CWE-416" }, { "id": 2634, "func": "nv_replace(cmdarg_T *cap)\n{\n char_u\t*ptr;\n int\t\thad_ctrl_v;\n long\tn;\n\n if (checkclearop(cap->oap))\n\treturn;\n#ifdef FEAT_JOB_CHANNEL\n if (bt_prompt(curbuf) && !prompt_curpos_editable())\n {\n\tclearopbeep(cap->oap);\n\treturn;\n }\n#endif\n\n // get another character\n if (cap->nchar == Ctrl_V)\n {\n\thad_ctrl_v = Ctrl_V;\n\tcap->nchar = get_literal(FALSE);\n\t// Don't redo a multibyte character with CTRL-V.\n\tif (cap->nchar > DEL)\n\t had_ctrl_v = NUL;\n }\n else\n\thad_ctrl_v = NUL;\n\n // Abort if the character is a special key.\n if (IS_SPECIAL(cap->nchar))\n {\n\tclearopbeep(cap->oap);\n\treturn;\n }\n\n // Visual mode \"r\"\n if (VIsual_active)\n {\n\tif (got_int)\n\t reset_VIsual();\n\tif (had_ctrl_v)\n\t{\n\t // Use a special (negative) number to make a difference between a\n\t // literal CR or NL and a line break.\n\t if (cap->nchar == CAR)\n\t\tcap->nchar = REPLACE_CR_NCHAR;\n\t else if (cap->nchar == NL)\n\t\tcap->nchar = REPLACE_NL_NCHAR;\n\t}\n\tnv_operator(cap);\n\treturn;\n }\n\n // Break tabs, etc.\n if (virtual_active())\n {\n\tif (u_save_cursor() == FAIL)\n\t return;\n\tif (gchar_cursor() == NUL)\n\t{\n\t // Add extra space and put the cursor on the first one.\n\t coladvance_force((colnr_T)(getviscol() + cap->count1));\n\t curwin->w_cursor.col -= cap->count1;\n\t}\n\telse if (gchar_cursor() == TAB)\n\t coladvance_force(getviscol());\n }\n\n // Abort if not enough characters to replace.\n ptr = ml_get_cursor();\n if (STRLEN(ptr) < (unsigned)cap->count1\n\t || (has_mbyte && mb_charlen(ptr) < cap->count1))\n {\n\tclearopbeep(cap->oap);\n\treturn;\n }\n\n /*\n * Replacing with a TAB is done by edit() when it is complicated because\n * 'expandtab' or 'smarttab' is set. CTRL-V TAB inserts a literal TAB.\n * Other characters are done below to avoid problems with things like\n * CTRL-V 048 (for edit() this would be R CTRL-V 0 ESC).\n */\n if (had_ctrl_v != Ctrl_V && cap->nchar == '\\t' && (curbuf->b_p_et || p_sta))\n {\n\tstuffnumReadbuff(cap->count1);\n\tstuffcharReadbuff('R');\n\tstuffcharReadbuff('\\t');\n\tstuffcharReadbuff(ESC);\n\treturn;\n }\n\n // save line for undo\n if (u_save_cursor() == FAIL)\n\treturn;\n\n if (had_ctrl_v != Ctrl_V && (cap->nchar == '\\r' || cap->nchar == '\\n'))\n {\n\t/*\n\t * Replace character(s) by a single newline.\n\t * Strange vi behaviour: Only one newline is inserted.\n\t * Delete the characters here.\n\t * Insert the newline with an insert command, takes care of\n\t * autoindent.\tThe insert command depends on being on the last\n\t * character of a line or not.\n\t */\n\t(void)del_chars(cap->count1, FALSE);\t// delete the characters\n\tstuffcharReadbuff('\\r');\n\tstuffcharReadbuff(ESC);\n\n\t// Give 'r' to edit(), to get the redo command right.\n\tinvoke_edit(cap, TRUE, 'r', FALSE);\n }\n else\n {\n\tprep_redo(cap->oap->regname, cap->count1,\n\t\t\t\t NUL, 'r', NUL, had_ctrl_v, cap->nchar);\n\n\tcurbuf->b_op_start = curwin->w_cursor;\n\tif (has_mbyte)\n\t{\n\t int\t\told_State = State;\n\n\t if (cap->ncharC1 != 0)\n\t\tAppendCharToRedobuff(cap->ncharC1);\n\t if (cap->ncharC2 != 0)\n\t\tAppendCharToRedobuff(cap->ncharC2);\n\n\t // This is slow, but it handles replacing a single-byte with a\n\t // multi-byte and the other way around. Also handles adding\n\t // composing characters for utf-8.\n\t for (n = cap->count1; n > 0; --n)\n\t {\n\t\tState = REPLACE;\n\t\tif (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)\n\t\t{\n\t\t int c = ins_copychar(curwin->w_cursor.lnum\n\t\t\t\t\t + (cap->nchar == Ctrl_Y ? -1 : 1));\n\t\t if (c != NUL)\n\t\t\tins_char(c);\n\t\t else\n\t\t\t// will be decremented further down\n\t\t\t++curwin->w_cursor.col;\n\t\t}\n\t\telse\n\t\t ins_char(cap->nchar);\n\t\tState = old_State;\n\t\tif (cap->ncharC1 != 0)\n\t\t ins_char(cap->ncharC1);\n\t\tif (cap->ncharC2 != 0)\n\t\t ins_char(cap->ncharC2);\n\t }\n\t}\n\telse\n\t{\n\t /*\n\t * Replace the characters within one line.\n\t */\n\t for (n = cap->count1; n > 0; --n)\n\t {\n\t\t/*\n\t\t * Get ptr again, because u_save and/or showmatch() will have\n\t\t * released the line. This may also happen in ins_copychar().\n\t\t * At the same time we let know that the line will be changed.\n\t\t */\n\t\tif (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)\n\t\t{\n\t\t int c = ins_copychar(curwin->w_cursor.lnum\n\t\t\t\t\t + (cap->nchar == Ctrl_Y ? -1 : 1));\n\n\t\t ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);\n\t\t if (c != NUL)\n\t\t ptr[curwin->w_cursor.col] = c;\n\t\t}\n\t\telse\n\t\t{\n\t\t ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);\n\t\t ptr[curwin->w_cursor.col] = cap->nchar;\n\t\t}\n\t\tif (p_sm && msg_silent == 0)\n\t\t showmatch(cap->nchar);\n\t\t++curwin->w_cursor.col;\n\t }\n#ifdef FEAT_NETBEANS_INTG\n\t if (netbeans_active())\n\t {\n\t\tcolnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1);\n\n\t\tnetbeans_removed(curbuf, curwin->w_cursor.lnum, start,\n\t\t\t\t\t\t\t (long)cap->count1);\n\t\tnetbeans_inserted(curbuf, curwin->w_cursor.lnum, start,\n\t\t\t\t\t &ptr[start], (int)cap->count1);\n\t }\n#endif\n\n\t // mark the buffer as changed and prepare for displaying\n\t changed_bytes(curwin->w_cursor.lnum,\n\t\t\t (colnr_T)(curwin->w_cursor.col - cap->count1));\n\t}\n\t--curwin->w_cursor.col;\t // cursor on the last replaced char\n\t// if the character on the left of the current cursor is a multi-byte\n\t// character, move two characters left\n\tif (has_mbyte)\n\t mb_adjust_cursor();\n\tcurbuf->b_op_end = curwin->w_cursor;\n\tcurwin->w_set_curswant = TRUE;\n\tset_last_insert(cap->nchar);\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-3796", "cwe_id": "CWE-416" }, { "id": 1450, "func": "static int proc_sys_readdir(struct file *file, struct dir_context *ctx)\n{\n\tstruct ctl_table_header *head = grab_header(file_inode(file));\n\tstruct ctl_table_header *h = NULL;\n\tstruct ctl_table *entry;\n\tstruct ctl_dir *ctl_dir;\n\tunsigned long pos;\n\n\tif (IS_ERR(head))\n\t\treturn PTR_ERR(head);\n\n\tctl_dir = container_of(head, struct ctl_dir, header);\n\n\tif (!dir_emit_dots(file, ctx))\n\t\treturn 0;\n\n\tpos = 2;\n\n\tfor (first_entry(ctl_dir, &h, &entry); h; next_entry(&h, &entry)) {\n\t\tif (!scan(h, entry, &pos, file, ctx)) {\n\t\t\tsysctl_head_finish(h);\n\t\t\tbreak;\n\t\t}\n\t}\n\tsysctl_head_finish(head);\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9191", "cwe_id": "CWE-20" }, { "id": 1450, "func": "static int proc_sys_readdir(struct file *file, struct dir_context *ctx)\n{\n\tstruct ctl_table_header *head = grab_header(file_inode(file));\n\tstruct ctl_table_header *h = NULL;\n\tstruct ctl_table *entry;\n\tstruct ctl_dir *ctl_dir;\n\tunsigned long pos;\n\n\tif (IS_ERR(head))\n\t\treturn PTR_ERR(head);\n\n\tctl_dir = container_of(head, struct ctl_dir, header);\n\n\tif (!dir_emit_dots(file, ctx))\n\t\tgoto out;\n\n\tpos = 2;\n\n\tfor (first_entry(ctl_dir, &h, &entry); h; next_entry(&h, &entry)) {\n\t\tif (!scan(h, entry, &pos, file, ctx)) {\n\t\t\tsysctl_head_finish(h);\n\t\t\tbreak;\n\t\t}\n\t}\nout:\n\tsysctl_head_finish(head);\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9191", "cwe_id": "CWE-20" }, { "id": 3238, "func": "error_t icecastClientConnect(IcecastClientContext *context)\n{\n error_t error;\n size_t length;\n uint16_t serverPort;\n IpAddr serverIpAddr;\n NetInterface *interface;\n\n //Underlying network interface\n interface = context->settings.interface;\n\n //Force traffic to go through a proxy server?\n if(osStrcmp(interface->proxyName, \"\"))\n {\n //Icecast request template\n const char_t requestTemplate[] =\n \"GET http://%s:%\" PRIu16 \"%s HTTP/1.1\\r\\n\"\n \"Host: %s:%\" PRIu16 \"\\r\\n\"\n \"User-agent: UserAgent\\r\\n\"\n \"Icy-MetaData: 1\\r\\n\"\n \"Connection: close\\r\\n\"\n \"\\r\\n\";\n\n //Format Icecast request\n length = osSprintf(context->buffer, requestTemplate,\n context->settings.serverName, context->settings.serverPort,\n context->settings.resource, context->settings.serverName,\n context->settings.serverPort);\n\n //The specified proxy server can be either an IP or a host name\n error = getHostByName(interface, interface->proxyName, &serverIpAddr, 0);\n //Unable to resolve server name?\n if(error)\n return error;\n\n //Proxy server port\n serverPort = interface->proxyPort;\n }\n else\n {\n //Icecast request template\n const char_t requestTemplate[] =\n \"GET %s HTTP/1.1\\r\\n\"\n \"Host: %s\\r\\n\"\n \"User-agent: UserAgent\\r\\n\"\n \"Icy-MetaData: 1\\r\\n\"\n \"Connection: close\\r\\n\"\n \"\\r\\n\";\n\n //Format Icecast request\n length = osSprintf(context->buffer, requestTemplate,\n context->settings.resource, context->settings.serverName);\n\n //The specified Icecast server can be either an IP or a host name\n error = getHostByName(interface, context->settings.serverName, &serverIpAddr, 0);\n //Unable to resolve server name?\n if(error)\n return error;\n\n //Icecast server port\n serverPort = context->settings.serverPort;\n }\n\n //Open a TCP socket\n context->socket = socketOpen(SOCKET_TYPE_STREAM, SOCKET_IP_PROTO_TCP);\n //Failed to open socket?\n if(context->socket == NULL)\n return ERROR_OUT_OF_RESOURCES;\n\n //Start of exception handling block\n do\n {\n //Associate the socket with the relevant interface\n error = socketBindToInterface(context->socket, interface);\n //Unable to bind the socket to the desired interface?\n if(error)\n break;\n\n //Adjust receive timeout\n error = socketSetTimeout(context->socket, ICECAST_CLIENT_TIMEOUT);\n //Any error to report?\n if(error)\n break;\n\n //Connect to the server\n error = socketConnect(context->socket, &serverIpAddr, serverPort);\n //Connection with server failed?\n if(error)\n break;\n\n //Display Icecast request for debugging purpose\n TRACE_DEBUG(context->buffer);\n\n //Send request to the server\n error = socketSend(context->socket, context->buffer,\n length, NULL, SOCKET_FLAG_WAIT_ACK);\n //Failed to send the request?\n if(error)\n break;\n\n //Parse response header\n while(1)\n {\n char_t *separator;\n char_t *property;\n char_t *value;\n\n //Read a line from the response header\n error = socketReceive(context->socket, context->buffer,\n ICECAST_CLIENT_METADATA_MAX_SIZE, &length, SOCKET_FLAG_BREAK_CRLF);\n //Failed to read data?\n if(error)\n break;\n\n //Properly terminate the string with a NULL character\n context->buffer[length] = '\\0';\n\n //The end of the header has been reached?\n if(!osStrcmp(context->buffer, \"\\r\\n\"))\n break;\n\n //Check whether a separator is present\n separator = strchr(context->buffer, ':');\n\n //Separator found?\n if(separator)\n {\n //Split the line\n *separator = '\\0';\n\n //Get property name and value\n property = strTrimWhitespace(context->buffer);\n value = strTrimWhitespace(separator + 1);\n\n //Debug message\n TRACE_INFO(\"<%s>=<%s>\\r\\n\", property, value);\n\n //Icy-Metaint property found?\n if(!osStrcasecmp(property, \"Icy-Metaint\"))\n {\n //Retrieve the block size used by the Icecast server\n context->blockSize = atoi(value);\n }\n }\n }\n\n //End of exception handling block\n } while(0);\n\n //Check whether an error occurred\n if(error)\n {\n //Clean up side effects\n socketClose(context->socket);\n }\n\n //Return status code\n return error;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 3238, "func": "error_t icecastClientConnect(IcecastClientContext *context)\n{\n error_t error;\n size_t length;\n uint16_t serverPort;\n IpAddr serverIpAddr;\n NetInterface *interface;\n\n //Underlying network interface\n interface = context->settings.interface;\n\n //Force traffic to go through a proxy server?\n if(osStrcmp(interface->proxyName, \"\"))\n {\n //Icecast request template\n const char_t requestTemplate[] =\n \"GET http://%s:%\" PRIu16 \"%s HTTP/1.1\\r\\n\"\n \"Host: %s:%\" PRIu16 \"\\r\\n\"\n \"User-agent: UserAgent\\r\\n\"\n \"Icy-MetaData: 1\\r\\n\"\n \"Connection: close\\r\\n\"\n \"\\r\\n\";\n\n //Format Icecast request\n length = osSprintf(context->buffer, requestTemplate,\n context->settings.serverName, context->settings.serverPort,\n context->settings.resource, context->settings.serverName,\n context->settings.serverPort);\n\n //The specified proxy server can be either an IP or a host name\n error = getHostByName(interface, interface->proxyName, &serverIpAddr, 0);\n //Unable to resolve server name?\n if(error)\n return error;\n\n //Proxy server port\n serverPort = interface->proxyPort;\n }\n else\n {\n //Icecast request template\n const char_t requestTemplate[] =\n \"GET %s HTTP/1.1\\r\\n\"\n \"Host: %s\\r\\n\"\n \"User-agent: UserAgent\\r\\n\"\n \"Icy-MetaData: 1\\r\\n\"\n \"Connection: close\\r\\n\"\n \"\\r\\n\";\n\n //Format Icecast request\n length = osSprintf(context->buffer, requestTemplate,\n context->settings.resource, context->settings.serverName);\n\n //The specified Icecast server can be either an IP or a host name\n error = getHostByName(interface, context->settings.serverName, &serverIpAddr, 0);\n //Unable to resolve server name?\n if(error)\n return error;\n\n //Icecast server port\n serverPort = context->settings.serverPort;\n }\n\n //Open a TCP socket\n context->socket = socketOpen(SOCKET_TYPE_STREAM, SOCKET_IP_PROTO_TCP);\n //Failed to open socket?\n if(context->socket == NULL)\n return ERROR_OUT_OF_RESOURCES;\n\n //Start of exception handling block\n do\n {\n //Associate the socket with the relevant interface\n error = socketBindToInterface(context->socket, interface);\n //Unable to bind the socket to the desired interface?\n if(error)\n break;\n\n //Adjust receive timeout\n error = socketSetTimeout(context->socket, ICECAST_CLIENT_TIMEOUT);\n //Any error to report?\n if(error)\n break;\n\n //Connect to the server\n error = socketConnect(context->socket, &serverIpAddr, serverPort);\n //Connection with server failed?\n if(error)\n break;\n\n //Display Icecast request for debugging purpose\n TRACE_DEBUG(context->buffer);\n\n //Send request to the server\n error = socketSend(context->socket, context->buffer,\n length, NULL, SOCKET_FLAG_WAIT_ACK);\n //Failed to send the request?\n if(error)\n break;\n\n //Parse response header\n while(1)\n {\n char_t *separator;\n char_t *property;\n char_t *value;\n\n //Read a line from the response header\n error = socketReceive(context->socket, context->buffer,\n ICECAST_CLIENT_METADATA_MAX_SIZE, &length, SOCKET_FLAG_BREAK_CRLF);\n //Failed to read data?\n if(error)\n break;\n\n //Properly terminate the string with a NULL character\n context->buffer[length] = '\\0';\n\n //The end of the header has been reached?\n if(!osStrcmp(context->buffer, \"\\r\\n\"))\n break;\n\n //Check whether a separator is present\n separator = osStrchr(context->buffer, ':');\n\n //Separator found?\n if(separator)\n {\n //Split the line\n *separator = '\\0';\n\n //Get property name and value\n property = strTrimWhitespace(context->buffer);\n value = strTrimWhitespace(separator + 1);\n\n //Debug message\n TRACE_INFO(\"<%s>=<%s>\\r\\n\", property, value);\n\n //Icy-Metaint property found?\n if(!osStrcasecmp(property, \"Icy-Metaint\"))\n {\n //Retrieve the block size used by the Icecast server\n context->blockSize = atoi(value);\n }\n }\n }\n\n //End of exception handling block\n } while(0);\n\n //Check whether an error occurred\n if(error)\n {\n //Clean up side effects\n socketClose(context->socket);\n }\n\n //Return status code\n return error;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1678, "func": "flac_read_loop (SF_PRIVATE *psf, unsigned len)\n{\tFLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;\n\n\tpflac->pos = 0 ;\n\tpflac->len = len ;\n\tpflac->remain = len ;\n\n\t/* First copy data that has already been decoded and buffered. */\n\tif (pflac->frame != NULL && pflac->bufferpos < pflac->frame->header.blocksize)\n\t\tflac_buffer_copy (psf) ;\n\n\t/* Decode some more. */\n\twhile (pflac->pos < pflac->len)\n\t{\tif (FLAC__stream_decoder_process_single (pflac->fsd) == 0)\n\t\t\tbreak ;\n\t\tif (FLAC__stream_decoder_get_state (pflac->fsd) >= FLAC__STREAM_DECODER_END_OF_STREAM)\n\t\t\tbreak ;\n\t\t} ;\n\n\tpflac->ptr = NULL ;\n\n\treturn pflac->pos ;\n} /* flac_read_loop */", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7585", "cwe_id": "CWE-119" }, { "id": 1678, "func": "flac_read_loop (SF_PRIVATE *psf, unsigned len)\n{\tFLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;\n\tFLAC__StreamDecoderState state ;\n\n\tpflac->pos = 0 ;\n\tpflac->len = len ;\n\tpflac->remain = len ;\n\n\tstate = FLAC__stream_decoder_get_state (pflac->fsd) ;\n\tif (state > FLAC__STREAM_DECODER_END_OF_STREAM)\n\t{\tpsf_log_printf (psf, \"FLAC__stream_decoder_get_state returned %s\\n\", FLAC__StreamDecoderStateString [state]) ;\n\t\t/* Current frame is busted, so NULL the pointer. */\n\t\tpflac->frame = NULL ;\n\t\t} ;\n\n\t/* First copy data that has already been decoded and buffered. */\n\tif (pflac->frame != NULL && pflac->bufferpos < pflac->frame->header.blocksize)\n\t\tflac_buffer_copy (psf) ;\n\n\t/* Decode some more. */\n\twhile (pflac->pos < pflac->len)\n\t{\tif (FLAC__stream_decoder_process_single (pflac->fsd) == 0)\n\t\t\tbreak ;\n\t\tstate = FLAC__stream_decoder_get_state (pflac->fsd) ;\n\t\tif (state >= FLAC__STREAM_DECODER_END_OF_STREAM)\n\t\t{\tpsf_log_printf (psf, \"FLAC__stream_decoder_get_state returned %s\\n\", FLAC__StreamDecoderStateString [state]) ;\n\t\t\t/* Current frame is busted, so NULL the pointer. */\n\t\t\tpflac->frame = NULL ;\n\t\t\tbreak ;\n\t\t\t} ;\n\t\t} ;\n\n\tpflac->ptr = NULL ;\n\n\treturn pflac->pos ;\n} /* flac_read_loop */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7585", "cwe_id": "CWE-119" }, { "id": 3261, "func": "struct btrfs_device *btrfs_find_device(struct btrfs_fs_devices *fs_devices,\n\t\t\t\t u64 devid, u8 *uuid, u8 *fsid)\n{\n\tstruct btrfs_device *device;\n\n\twhile (fs_devices) {\n\t\tif (!fsid ||\n\t\t !memcmp(fs_devices->metadata_uuid, fsid, BTRFS_FSID_SIZE)) {\n\t\t\tdevice = find_device(fs_devices, devid, uuid);\n\t\t\tif (device)\n\t\t\t\treturn device;\n\t\t}\n\t\tfs_devices = fs_devices->seed;\n\t}\n\treturn NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-18885", "cwe_id": "CWE-476" }, { "id": 3261, "func": "struct btrfs_device *btrfs_find_device(struct btrfs_fs_devices *fs_devices,\n\t\t\t\t u64 devid, u8 *uuid, u8 *fsid,\n\t\t\t\t bool seed)\n{\n\tstruct btrfs_device *device;\n\n\twhile (fs_devices) {\n\t\tif (!fsid ||\n\t\t !memcmp(fs_devices->metadata_uuid, fsid, BTRFS_FSID_SIZE)) {\n\t\t\tlist_for_each_entry(device, &fs_devices->devices,\n\t\t\t\t\t dev_list) {\n\t\t\t\tif (device->devid == devid &&\n\t\t\t\t (!uuid || memcmp(device->uuid, uuid,\n\t\t\t\t\t\t BTRFS_UUID_SIZE) == 0))\n\t\t\t\t\treturn device;\n\t\t\t}\n\t\t}\n\t\tif (seed)\n\t\t\tfs_devices = fs_devices->seed;\n\t\telse\n\t\t\treturn NULL;\n\t}\n\treturn NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-18885", "cwe_id": "CWE-476" }, { "id": 1274, "func": "archive_string_append_from_wcs(struct archive_string *as,\n const wchar_t *w, size_t len)\n{\n\t/* We cannot use the standard wcstombs() here because it\n\t * cannot tell us how big the output buffer should be. So\n\t * I've built a loop around wcrtomb() or wctomb() that\n\t * converts a character at a time and resizes the string as\n\t * needed. We prefer wcrtomb() when it's available because\n\t * it's thread-safe. */\n\tint n, ret_val = 0;\n\tchar *p;\n\tchar *end;\n#if HAVE_WCRTOMB\n\tmbstate_t shift_state;\n\n\tmemset(&shift_state, 0, sizeof(shift_state));\n#else\n\t/* Clear the shift state before starting. */\n\twctomb(NULL, L'\\0');\n#endif\n\t/*\n\t * Allocate buffer for MBS.\n\t * We need this allocation here since it is possible that\n\t * as->s is still NULL.\n\t */\n\tif (archive_string_ensure(as, as->length + len + 1) == NULL)\n\t\treturn (-1);\n\n\tp = as->s + as->length;\n\tend = as->s + as->buffer_length - MB_CUR_MAX -1;\n\twhile (*w != L'\\0' && len > 0) {\n\t\tif (p >= end) {\n\t\t\tas->length = p - as->s;\n\t\t\tas->s[as->length] = '\\0';\n\t\t\t/* Re-allocate buffer for MBS. */\n\t\t\tif (archive_string_ensure(as,\n\t\t\t as->length + len * 2 + 1) == NULL)\n\t\t\t\treturn (-1);\n\t\t\tp = as->s + as->length;\n\t\t\tend = as->s + as->buffer_length - MB_CUR_MAX -1;\n\t\t}\n#if HAVE_WCRTOMB\n\t\tn = wcrtomb(p, *w++, &shift_state);\n#else\n\t\tn = wctomb(p, *w++);\n#endif\n\t\tif (n == -1) {\n\t\t\tif (errno == EILSEQ) {\n\t\t\t\t/* Skip an illegal wide char. */\n\t\t\t\t*p++ = '?';\n\t\t\t\tret_val = -1;\n\t\t\t} else {\n\t\t\t\tret_val = -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else\n\t\t\tp += n;\n\t\tlen--;\n\t}\n\tas->length = p - as->s;\n\tas->s[as->length] = '\\0';\n\treturn (ret_val);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-21674", "cwe_id": "CWE-787" }, { "id": 1274, "func": "archive_string_append_from_wcs(struct archive_string *as,\n const wchar_t *w, size_t len)\n{\n\t/* We cannot use the standard wcstombs() here because it\n\t * cannot tell us how big the output buffer should be. So\n\t * I've built a loop around wcrtomb() or wctomb() that\n\t * converts a character at a time and resizes the string as\n\t * needed. We prefer wcrtomb() when it's available because\n\t * it's thread-safe. */\n\tint n, ret_val = 0;\n\tchar *p;\n\tchar *end;\n#if HAVE_WCRTOMB\n\tmbstate_t shift_state;\n\n\tmemset(&shift_state, 0, sizeof(shift_state));\n#else\n\t/* Clear the shift state before starting. */\n\twctomb(NULL, L'\\0');\n#endif\n\t/*\n\t * Allocate buffer for MBS.\n\t * We need this allocation here since it is possible that\n\t * as->s is still NULL.\n\t */\n\tif (archive_string_ensure(as, as->length + len + 1) == NULL)\n\t\treturn (-1);\n\n\tp = as->s + as->length;\n\tend = as->s + as->buffer_length - MB_CUR_MAX -1;\n\twhile (*w != L'\\0' && len > 0) {\n\t\tif (p >= end) {\n\t\t\tas->length = p - as->s;\n\t\t\tas->s[as->length] = '\\0';\n\t\t\t/* Re-allocate buffer for MBS. */\n\t\t\tif (archive_string_ensure(as,\n\t\t\t as->length + max(len * 2,\n\t\t\t (size_t)MB_CUR_MAX) + 1) == NULL)\n\t\t\t\treturn (-1);\n\t\t\tp = as->s + as->length;\n\t\t\tend = as->s + as->buffer_length - MB_CUR_MAX -1;\n\t\t}\n#if HAVE_WCRTOMB\n\t\tn = wcrtomb(p, *w++, &shift_state);\n#else\n\t\tn = wctomb(p, *w++);\n#endif\n\t\tif (n == -1) {\n\t\t\tif (errno == EILSEQ) {\n\t\t\t\t/* Skip an illegal wide char. */\n\t\t\t\t*p++ = '?';\n\t\t\t\tret_val = -1;\n\t\t\t} else {\n\t\t\t\tret_val = -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else\n\t\t\tp += n;\n\t\tlen--;\n\t}\n\tas->length = p - as->s;\n\tas->s[as->length] = '\\0';\n\treturn (ret_val);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-21674", "cwe_id": "CWE-787" }, { "id": 3074, "func": "static int validate_user_key(struct fscrypt_info *crypt_info,\n\t\t\tstruct fscrypt_context *ctx, u8 *raw_key,\n\t\t\tconst char *prefix)\n{\n\tchar *description;\n\tstruct key *keyring_key;\n\tstruct fscrypt_key *master_key;\n\tconst struct user_key_payload *ukp;\n\tint res;\n\n\tdescription = kasprintf(GFP_NOFS, \"%s%*phN\", prefix,\n\t\t\t\tFS_KEY_DESCRIPTOR_SIZE,\n\t\t\t\tctx->master_key_descriptor);\n\tif (!description)\n\t\treturn -ENOMEM;\n\n\tkeyring_key = request_key(&key_type_logon, description, NULL);\n\tkfree(description);\n\tif (IS_ERR(keyring_key))\n\t\treturn PTR_ERR(keyring_key);\n\n\tif (keyring_key->type != &key_type_logon) {\n\t\tprintk_once(KERN_WARNING\n\t\t\t\t\"%s: key type must be logon\\n\", __func__);\n\t\tres = -ENOKEY;\n\t\tgoto out;\n\t}\n\tdown_read(&keyring_key->sem);\n\tukp = user_key_payload(keyring_key);\n\tif (ukp->datalen != sizeof(struct fscrypt_key)) {\n\t\tres = -EINVAL;\n\t\tup_read(&keyring_key->sem);\n\t\tgoto out;\n\t}\n\tmaster_key = (struct fscrypt_key *)ukp->data;\n\tBUILD_BUG_ON(FS_AES_128_ECB_KEY_SIZE != FS_KEY_DERIVATION_NONCE_SIZE);\n\n\tif (master_key->size != FS_AES_256_XTS_KEY_SIZE) {\n\t\tprintk_once(KERN_WARNING\n\t\t\t\t\"%s: key size incorrect: %d\\n\",\n\t\t\t\t__func__, master_key->size);\n\t\tres = -ENOKEY;\n\t\tup_read(&keyring_key->sem);\n\t\tgoto out;\n\t}\n\tres = derive_key_aes(ctx->nonce, master_key->raw, raw_key);\n\tup_read(&keyring_key->sem);\n\tif (res)\n\t\tgoto out;\n\n\tcrypt_info->ci_keyring_key = keyring_key;\n\treturn 0;\nout:\n\tkey_put(keyring_key);\n\treturn res;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7374", "cwe_id": "CWE-476" }, { "id": 3074, "func": "static int validate_user_key(struct fscrypt_info *crypt_info,\n\t\t\tstruct fscrypt_context *ctx, u8 *raw_key,\n\t\t\tconst char *prefix)\n{\n\tchar *description;\n\tstruct key *keyring_key;\n\tstruct fscrypt_key *master_key;\n\tconst struct user_key_payload *ukp;\n\tint res;\n\n\tdescription = kasprintf(GFP_NOFS, \"%s%*phN\", prefix,\n\t\t\t\tFS_KEY_DESCRIPTOR_SIZE,\n\t\t\t\tctx->master_key_descriptor);\n\tif (!description)\n\t\treturn -ENOMEM;\n\n\tkeyring_key = request_key(&key_type_logon, description, NULL);\n\tkfree(description);\n\tif (IS_ERR(keyring_key))\n\t\treturn PTR_ERR(keyring_key);\n\tdown_read(&keyring_key->sem);\n\n\tif (keyring_key->type != &key_type_logon) {\n\t\tprintk_once(KERN_WARNING\n\t\t\t\t\"%s: key type must be logon\\n\", __func__);\n\t\tres = -ENOKEY;\n\t\tgoto out;\n\t}\n\tukp = user_key_payload(keyring_key);\n\tif (ukp->datalen != sizeof(struct fscrypt_key)) {\n\t\tres = -EINVAL;\n\t\tgoto out;\n\t}\n\tmaster_key = (struct fscrypt_key *)ukp->data;\n\tBUILD_BUG_ON(FS_AES_128_ECB_KEY_SIZE != FS_KEY_DERIVATION_NONCE_SIZE);\n\n\tif (master_key->size != FS_AES_256_XTS_KEY_SIZE) {\n\t\tprintk_once(KERN_WARNING\n\t\t\t\t\"%s: key size incorrect: %d\\n\",\n\t\t\t\t__func__, master_key->size);\n\t\tres = -ENOKEY;\n\t\tgoto out;\n\t}\n\tres = derive_key_aes(ctx->nonce, master_key->raw, raw_key);\nout:\n\tup_read(&keyring_key->sem);\n\tkey_put(keyring_key);\n\treturn res;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7374", "cwe_id": "CWE-476" }, { "id": 17, "func": "bool Unpack::UnpackLargeBlock(UnpackThreadData &D)\n{\n if (!D.TableRead)\n {\n D.TableRead=true;\n if (!ReadTables(D.Inp,D.BlockHeader,D.BlockTables))\n {\n D.DamagedData=true;\n return false;\n }\n }\n\n if (D.Inp.InAddr>D.BlockHeader.HeaderSize+D.BlockHeader.BlockSize)\n {\n D.DamagedData=true;\n return false;\n }\n \n int BlockBorder=D.BlockHeader.BlockStart+D.BlockHeader.BlockSize-1;\n\n // Reserve enough space even for filter entry.\n int DataBorder=D.DataSize-16;\n int ReadBorder=Min(BlockBorder,DataBorder);\n\n while (true)\n {\n UnpPtr&=MaxWinMask;\n if (D.Inp.InAddr>=ReadBorder)\n {\n if (D.Inp.InAddr>BlockBorder || D.Inp.InAddr==BlockBorder && \n D.Inp.InBit>=D.BlockHeader.BlockBitSize)\n break;\n\n // If we do not have any more data in file to read, we must process\n // what we have until last byte. Otherwise we can return and append\n // more data to unprocessed few bytes.\n if ((D.Inp.InAddr>=DataBorder) && !D.NoDataLeft || D.Inp.InAddr>=D.DataSize)\n {\n D.Incomplete=true;\n break;\n }\n }\n if (((WriteBorder-UnpPtr) & MaxWinMask)DestUnpSize)\n return false;\n }\n\n uint MainSlot=DecodeNumber(D.Inp,&D.BlockTables.LD);\n if (MainSlot<256)\n {\n Window[UnpPtr++]=(byte)MainSlot;\n continue;\n }\n if (MainSlot>=262)\n {\n uint Length=SlotToLength(D.Inp,MainSlot-262);\n\n uint DBits,Distance=1,DistSlot=DecodeNumber(D.Inp,&D.BlockTables.DD);\n if (DistSlot<4)\n {\n DBits=0;\n Distance+=DistSlot;\n }\n else\n {\n DBits=DistSlot/2 - 1;\n Distance+=(2 | (DistSlot & 1)) << DBits;\n }\n\n if (DBits>0)\n {\n if (DBits>=4)\n {\n if (DBits>4)\n {\n Distance+=((D.Inp.getbits32()>>(36-DBits))<<4);\n D.Inp.addbits(DBits-4);\n }\n uint LowDist=DecodeNumber(D.Inp,&D.BlockTables.LDD);\n Distance+=LowDist;\n }\n else\n {\n Distance+=D.Inp.getbits32()>>(32-DBits);\n D.Inp.addbits(DBits);\n }\n }\n\n if (Distance>0x100)\n {\n Length++;\n if (Distance>0x2000)\n {\n Length++;\n if (Distance>0x40000)\n Length++;\n }\n }\n\n InsertOldDist(Distance);\n LastLength=Length;\n CopyString(Length,Distance);\n continue;\n }\n if (MainSlot==256)\n {\n UnpackFilter Filter;\n if (!ReadFilter(D.Inp,Filter) || !AddFilter(Filter))\n break;\n continue;\n }\n if (MainSlot==257)\n {\n if (LastLength!=0)\n CopyString(LastLength,OldDist[0]);\n continue;\n }\n if (MainSlot<262)\n {\n uint DistNum=MainSlot-258;\n uint Distance=OldDist[DistNum];\n for (uint I=DistNum;I>0;I--)\n OldDist[I]=OldDist[I-1];\n OldDist[0]=Distance;\n\n uint LengthSlot=DecodeNumber(D.Inp,&D.BlockTables.RD);\n uint Length=SlotToLength(D.Inp,LengthSlot);\n LastLength=Length;\n CopyString(Length,Distance);\n continue;\n }\n }\n return true;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-20006", "cwe_id": "CWE-787" }, { "id": 17, "func": "bool Unpack::UnpackLargeBlock(UnpackThreadData &D)\n{\n if (!D.TableRead)\n {\n D.TableRead=true;\n if (!ReadTables(D.Inp,D.BlockHeader,D.BlockTables))\n {\n D.DamagedData=true;\n return false;\n }\n }\n\n if (D.Inp.InAddr>D.BlockHeader.HeaderSize+D.BlockHeader.BlockSize)\n {\n D.DamagedData=true;\n return false;\n }\n \n int BlockBorder=D.BlockHeader.BlockStart+D.BlockHeader.BlockSize-1;\n\n // Reserve enough space even for filter entry.\n int DataBorder=D.DataSize-16;\n int ReadBorder=Min(BlockBorder,DataBorder);\n\n while (true)\n {\n UnpPtr&=MaxWinMask;\n if (D.Inp.InAddr>=ReadBorder)\n {\n if (D.Inp.InAddr>BlockBorder || D.Inp.InAddr==BlockBorder && \n D.Inp.InBit>=D.BlockHeader.BlockBitSize)\n break;\n\n // If we do not have any more data in file to read, we must process\n // what we have until last byte. Otherwise we can return and append\n // more data to unprocessed few bytes.\n if ((D.Inp.InAddr>=DataBorder) && !D.NoDataLeft || D.Inp.InAddr>=D.DataSize)\n {\n D.Incomplete=true;\n break;\n }\n }\n if (((WriteBorder-UnpPtr) & MaxWinMask)DestUnpSize)\n return false;\n }\n\n uint MainSlot=DecodeNumber(D.Inp,&D.BlockTables.LD);\n if (MainSlot<256)\n {\n Window[UnpPtr++]=(byte)MainSlot;\n continue;\n }\n if (MainSlot>=262)\n {\n uint Length=SlotToLength(D.Inp,MainSlot-262);\n\n uint DBits,Distance=1,DistSlot=DecodeNumber(D.Inp,&D.BlockTables.DD);\n if (DistSlot<4)\n {\n DBits=0;\n Distance+=DistSlot;\n }\n else\n {\n DBits=DistSlot/2 - 1;\n Distance+=(2 | (DistSlot & 1)) << DBits;\n }\n\n if (DBits>0)\n {\n if (DBits>=4)\n {\n if (DBits>4)\n {\n Distance+=((D.Inp.getbits32()>>(36-DBits))<<4);\n D.Inp.addbits(DBits-4);\n }\n uint LowDist=DecodeNumber(D.Inp,&D.BlockTables.LDD);\n Distance+=LowDist;\n }\n else\n {\n Distance+=D.Inp.getbits32()>>(32-DBits);\n D.Inp.addbits(DBits);\n }\n }\n\n if (Distance>0x100)\n {\n Length++;\n if (Distance>0x2000)\n {\n Length++;\n if (Distance>0x40000)\n Length++;\n }\n }\n\n InsertOldDist(Distance);\n LastLength=Length;\n CopyString(Length,Distance);\n continue;\n }\n if (MainSlot==256)\n {\n UnpackFilter Filter;\n if (!ReadFilter(D.Inp,Filter) || !AddFilter(Filter))\n break;\n continue;\n }\n if (MainSlot==257)\n {\n if (LastLength!=0)\n CopyString(LastLength,OldDist[0]);\n continue;\n }\n if (MainSlot<262)\n {\n uint DistNum=MainSlot-258;\n uint Distance=OldDist[DistNum];\n for (uint I=DistNum;I>0;I--)\n OldDist[I]=OldDist[I-1];\n OldDist[0]=Distance;\n\n uint LengthSlot=DecodeNumber(D.Inp,&D.BlockTables.RD);\n uint Length=SlotToLength(D.Inp,LengthSlot);\n LastLength=Length;\n CopyString(Length,Distance);\n continue;\n }\n }\n return true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-20006", "cwe_id": "CWE-787" }, { "id": 2280, "func": "mp_dss_print(netdissect_options *ndo,\n const u_char *opt, u_int opt_len, u_char flags)\n{\n const struct mp_dss *mdss = (const struct mp_dss *) opt;\n\n if ((opt_len != mp_dss_len(mdss, 1) &&\n opt_len != mp_dss_len(mdss, 0)) || flags & TH_SYN)\n return 0;\n\n if (mdss->flags & MP_DSS_F)\n ND_PRINT((ndo, \" fin\"));\n\n opt += 4;\n if (mdss->flags & MP_DSS_A) {\n ND_PRINT((ndo, \" ack \"));\n if (mdss->flags & MP_DSS_a) {\n ND_PRINT((ndo, \"%\" PRIu64, EXTRACT_64BITS(opt)));\n opt += 8;\n } else {\n ND_PRINT((ndo, \"%u\", EXTRACT_32BITS(opt)));\n opt += 4;\n }\n }\n\n if (mdss->flags & MP_DSS_M) {\n ND_PRINT((ndo, \" seq \"));\n if (mdss->flags & MP_DSS_m) {\n ND_PRINT((ndo, \"%\" PRIu64, EXTRACT_64BITS(opt)));\n opt += 8;\n } else {\n ND_PRINT((ndo, \"%u\", EXTRACT_32BITS(opt)));\n opt += 4;\n }\n ND_PRINT((ndo, \" subseq %u\", EXTRACT_32BITS(opt)));\n opt += 4;\n ND_PRINT((ndo, \" len %u\", EXTRACT_16BITS(opt)));\n opt += 2;\n\n if (opt_len == mp_dss_len(mdss, 1))\n ND_PRINT((ndo, \" csum 0x%x\", EXTRACT_16BITS(opt)));\n }\n return 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13040", "cwe_id": "CWE-125" }, { "id": 2280, "func": "mp_dss_print(netdissect_options *ndo,\n const u_char *opt, u_int opt_len, u_char flags)\n{\n const struct mp_dss *mdss = (const struct mp_dss *) opt;\n\n /* We need the flags, at a minimum. */\n if (opt_len < 4)\n return 0;\n\n if (flags & TH_SYN)\n return 0;\n\n if (mdss->flags & MP_DSS_F)\n ND_PRINT((ndo, \" fin\"));\n\n opt += 4;\n opt_len -= 4;\n if (mdss->flags & MP_DSS_A) {\n /* Ack present */\n ND_PRINT((ndo, \" ack \"));\n /*\n * If the a flag is set, we have an 8-byte ack; if it's\n * clear, we have a 4-byte ack.\n */\n if (mdss->flags & MP_DSS_a) {\n if (opt_len < 8)\n return 0;\n ND_PRINT((ndo, \"%\" PRIu64, EXTRACT_64BITS(opt)));\n opt += 8;\n opt_len -= 8;\n } else {\n if (opt_len < 4)\n return 0;\n ND_PRINT((ndo, \"%u\", EXTRACT_32BITS(opt)));\n opt += 4;\n opt_len -= 4;\n }\n }\n\n if (mdss->flags & MP_DSS_M) {\n /*\n * Data Sequence Number (DSN), Subflow Sequence Number (SSN),\n * Data-Level Length present, and Checksum possibly present.\n */\n ND_PRINT((ndo, \" seq \"));\n\t\t/*\n * If the m flag is set, we have an 8-byte NDS; if it's clear,\n * we have a 4-byte DSN.\n */\n if (mdss->flags & MP_DSS_m) {\n if (opt_len < 8)\n return 0;\n ND_PRINT((ndo, \"%\" PRIu64, EXTRACT_64BITS(opt)));\n opt += 8;\n opt_len -= 8;\n } else {\n if (opt_len < 4)\n return 0;\n ND_PRINT((ndo, \"%u\", EXTRACT_32BITS(opt)));\n opt += 4;\n opt_len -= 4;\n }\n if (opt_len < 4)\n return 0;\n ND_PRINT((ndo, \" subseq %u\", EXTRACT_32BITS(opt)));\n opt += 4;\n opt_len -= 4;\n if (opt_len < 2)\n return 0;\n ND_PRINT((ndo, \" len %u\", EXTRACT_16BITS(opt)));\n opt += 2;\n opt_len -= 2;\n\n /*\n * The Checksum is present only if negotiated.\n * If there are at least 2 bytes left, process the next 2\n * bytes as the Checksum.\n */\n if (opt_len >= 2) {\n ND_PRINT((ndo, \" csum 0x%x\", EXTRACT_16BITS(opt)));\n opt_len -= 2;\n }\n }\n if (opt_len != 0)\n return 0;\n return 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13040", "cwe_id": "CWE-125" }, { "id": 3249, "func": "struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,\n\t\t\t\t struct sctp_chunk *asconf)\n{\n\tsctp_addiphdr_t\t\t*hdr;\n\tunion sctp_addr_param\t*addr_param;\n\tsctp_addip_param_t\t*asconf_param;\n\tstruct sctp_chunk\t*asconf_ack;\n\n\t__be16\terr_code;\n\tint\tlength = 0;\n\tint\tchunk_len;\n\t__u32\tserial;\n\tint\tall_param_pass = 1;\n\n\tchunk_len = ntohs(asconf->chunk_hdr->length) - sizeof(sctp_chunkhdr_t);\n\thdr = (sctp_addiphdr_t *)asconf->skb->data;\n\tserial = ntohl(hdr->serial);\n\n\t/* Skip the addiphdr and store a pointer to address parameter. */\n\tlength = sizeof(sctp_addiphdr_t);\n\taddr_param = (union sctp_addr_param *)(asconf->skb->data + length);\n\tchunk_len -= length;\n\n\t/* Skip the address parameter and store a pointer to the first\n\t * asconf parameter.\n\t */\n\tlength = ntohs(addr_param->p.length);\n\tasconf_param = (void *)addr_param + length;\n\tchunk_len -= length;\n\n\t/* create an ASCONF_ACK chunk.\n\t * Based on the definitions of parameters, we know that the size of\n\t * ASCONF_ACK parameters are less than or equal to the fourfold of ASCONF\n\t * parameters.\n\t */\n\tasconf_ack = sctp_make_asconf_ack(asoc, serial, chunk_len * 4);\n\tif (!asconf_ack)\n\t\tgoto done;\n\n\t/* Process the TLVs contained within the ASCONF chunk. */\n\twhile (chunk_len > 0) {\n\t\terr_code = sctp_process_asconf_param(asoc, asconf,\n\t\t\t\t\t\t asconf_param);\n\t\t/* ADDIP 4.1 A7)\n\t\t * If an error response is received for a TLV parameter,\n\t\t * all TLVs with no response before the failed TLV are\n\t\t * considered successful if not reported. All TLVs after\n\t\t * the failed response are considered unsuccessful unless\n\t\t * a specific success indication is present for the parameter.\n\t\t */\n\t\tif (SCTP_ERROR_NO_ERROR != err_code)\n\t\t\tall_param_pass = 0;\n\n\t\tif (!all_param_pass)\n\t\t\tsctp_add_asconf_response(asconf_ack,\n\t\t\t\t\t\t asconf_param->crr_id, err_code,\n\t\t\t\t\t\t asconf_param);\n\n\t\t/* ADDIP 4.3 D11) When an endpoint receiving an ASCONF to add\n\t\t * an IP address sends an 'Out of Resource' in its response, it\n\t\t * MUST also fail any subsequent add or delete requests bundled\n\t\t * in the ASCONF.\n\t\t */\n\t\tif (SCTP_ERROR_RSRC_LOW == err_code)\n\t\t\tgoto done;\n\n\t\t/* Move to the next ASCONF param. */\n\t\tlength = ntohs(asconf_param->param_hdr.length);\n\t\tasconf_param = (void *)asconf_param + length;\n\t\tchunk_len -= length;\n\t}\n\ndone:\n\tasoc->peer.addip_serial++;\n\n\t/* If we are sending a new ASCONF_ACK hold a reference to it in assoc\n\t * after freeing the reference to old asconf ack if any.\n\t */\n\tif (asconf_ack) {\n\t\tsctp_chunk_hold(asconf_ack);\n\t\tlist_add_tail(&asconf_ack->transmitted_list,\n\t\t\t &asoc->asconf_ack_list);\n\t}\n\n\treturn asconf_ack;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-3673", "cwe_id": "CWE-20" }, { "id": 3249, "func": "struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,\n\t\t\t\t struct sctp_chunk *asconf)\n{\n\tsctp_addip_chunk_t *addip = (sctp_addip_chunk_t *) asconf->chunk_hdr;\n\tbool all_param_pass = true;\n\tunion sctp_params param;\n\tsctp_addiphdr_t\t\t*hdr;\n\tunion sctp_addr_param\t*addr_param;\n\tsctp_addip_param_t\t*asconf_param;\n\tstruct sctp_chunk\t*asconf_ack;\n\t__be16\terr_code;\n\tint\tlength = 0;\n\tint\tchunk_len;\n\t__u32\tserial;\n\n\tchunk_len = ntohs(asconf->chunk_hdr->length) - sizeof(sctp_chunkhdr_t);\n\thdr = (sctp_addiphdr_t *)asconf->skb->data;\n\tserial = ntohl(hdr->serial);\n\n\t/* Skip the addiphdr and store a pointer to address parameter. */\n\tlength = sizeof(sctp_addiphdr_t);\n\taddr_param = (union sctp_addr_param *)(asconf->skb->data + length);\n\tchunk_len -= length;\n\n\t/* Skip the address parameter and store a pointer to the first\n\t * asconf parameter.\n\t */\n\tlength = ntohs(addr_param->p.length);\n\tasconf_param = (void *)addr_param + length;\n\tchunk_len -= length;\n\n\t/* create an ASCONF_ACK chunk.\n\t * Based on the definitions of parameters, we know that the size of\n\t * ASCONF_ACK parameters are less than or equal to the fourfold of ASCONF\n\t * parameters.\n\t */\n\tasconf_ack = sctp_make_asconf_ack(asoc, serial, chunk_len * 4);\n\tif (!asconf_ack)\n\t\tgoto done;\n\n\t/* Process the TLVs contained within the ASCONF chunk. */\n\tsctp_walk_params(param, addip, addip_hdr.params) {\n\t\t/* Skip preceeding address parameters. */\n\t\tif (param.p->type == SCTP_PARAM_IPV4_ADDRESS ||\n\t\t param.p->type == SCTP_PARAM_IPV6_ADDRESS)\n\t\t\tcontinue;\n\n\t\terr_code = sctp_process_asconf_param(asoc, asconf,\n\t\t\t\t\t\t param.addip);\n\t\t/* ADDIP 4.1 A7)\n\t\t * If an error response is received for a TLV parameter,\n\t\t * all TLVs with no response before the failed TLV are\n\t\t * considered successful if not reported. All TLVs after\n\t\t * the failed response are considered unsuccessful unless\n\t\t * a specific success indication is present for the parameter.\n\t\t */\n\t\tif (err_code != SCTP_ERROR_NO_ERROR)\n\t\t\tall_param_pass = false;\n\t\tif (!all_param_pass)\n\t\t\tsctp_add_asconf_response(asconf_ack, param.addip->crr_id,\n\t\t\t\t\t\t err_code, param.addip);\n\n\t\t/* ADDIP 4.3 D11) When an endpoint receiving an ASCONF to add\n\t\t * an IP address sends an 'Out of Resource' in its response, it\n\t\t * MUST also fail any subsequent add or delete requests bundled\n\t\t * in the ASCONF.\n\t\t */\n\t\tif (err_code == SCTP_ERROR_RSRC_LOW)\n\t\t\tgoto done;\n\t}\ndone:\n\tasoc->peer.addip_serial++;\n\n\t/* If we are sending a new ASCONF_ACK hold a reference to it in assoc\n\t * after freeing the reference to old asconf ack if any.\n\t */\n\tif (asconf_ack) {\n\t\tsctp_chunk_hold(asconf_ack);\n\t\tlist_add_tail(&asconf_ack->transmitted_list,\n\t\t\t &asoc->asconf_ack_list);\n\t}\n\n\treturn asconf_ack;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-3673", "cwe_id": "CWE-20" }, { "id": 2082, "func": "TfLiteStatus NonMaxSuppressionMultiClassFastHelper(TfLiteContext* context,\n TfLiteNode* node,\n OpData* op_data,\n const float* scores) {\n const TfLiteTensor* input_box_encodings =\n GetInput(context, node, kInputTensorBoxEncodings);\n const TfLiteTensor* input_class_predictions =\n GetInput(context, node, kInputTensorClassPredictions);\n const TfLiteTensor* decoded_boxes =\n &context->tensors[op_data->decoded_boxes_index];\n\n TfLiteTensor* detection_boxes =\n GetOutput(context, node, kOutputTensorDetectionBoxes);\n TfLiteTensor* detection_classes =\n GetOutput(context, node, kOutputTensorDetectionClasses);\n TfLiteTensor* detection_scores =\n GetOutput(context, node, kOutputTensorDetectionScores);\n TfLiteTensor* num_detections =\n GetOutput(context, node, kOutputTensorNumDetections);\n\n const int num_boxes = input_box_encodings->dims->data[1];\n const int num_classes = op_data->num_classes;\n const int max_categories_per_anchor = op_data->max_classes_per_detection;\n const int num_classes_with_background =\n input_class_predictions->dims->data[2];\n // The row index offset is 1 if background class is included and 0 otherwise.\n int label_offset = num_classes_with_background - num_classes;\n TF_LITE_ENSURE(context, (max_categories_per_anchor > 0));\n const int num_categories_per_anchor =\n std::min(max_categories_per_anchor, num_classes);\n std::vector max_scores;\n max_scores.resize(num_boxes);\n std::vector sorted_class_indices;\n sorted_class_indices.resize(num_boxes * num_classes);\n for (int row = 0; row < num_boxes; row++) {\n const float* box_scores =\n scores + row * num_classes_with_background + label_offset;\n int* class_indices = sorted_class_indices.data() + row * num_classes;\n DecreasingPartialArgSort(box_scores, num_classes, num_categories_per_anchor,\n class_indices);\n max_scores[row] = box_scores[class_indices[0]];\n }\n // Perform non-maximal suppression on max scores\n std::vector selected;\n TF_LITE_ENSURE_STATUS(NonMaxSuppressionSingleClassHelper(\n context, node, op_data, max_scores, &selected, op_data->max_detections));\n // Allocate output tensors\n int output_box_index = 0;\n for (const auto& selected_index : selected) {\n const float* box_scores =\n scores + selected_index * num_classes_with_background + label_offset;\n const int* class_indices =\n sorted_class_indices.data() + selected_index * num_classes;\n\n for (int col = 0; col < num_categories_per_anchor; ++col) {\n int box_offset = num_categories_per_anchor * output_box_index + col;\n // detection_boxes\n ReInterpretTensor(detection_boxes)[box_offset] =\n ReInterpretTensor(\n decoded_boxes)[selected_index];\n // detection_classes\n GetTensorData(detection_classes)[box_offset] = class_indices[col];\n // detection_scores\n GetTensorData(detection_scores)[box_offset] =\n box_scores[class_indices[col]];\n output_box_index++;\n }\n }\n GetTensorData(num_detections)[0] = output_box_index;\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2082, "func": "TfLiteStatus NonMaxSuppressionMultiClassFastHelper(TfLiteContext* context,\n TfLiteNode* node,\n OpData* op_data,\n const float* scores) {\n const TfLiteTensor* input_box_encodings;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensorBoxEncodings,\n &input_box_encodings));\n const TfLiteTensor* input_class_predictions;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensorClassPredictions,\n &input_class_predictions));\n const TfLiteTensor* decoded_boxes =\n &context->tensors[op_data->decoded_boxes_index];\n\n TfLiteTensor* detection_boxes;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensorDetectionBoxes,\n &detection_boxes));\n TfLiteTensor* detection_classes;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensorDetectionClasses,\n &detection_classes));\n TfLiteTensor* detection_scores;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensorDetectionScores,\n &detection_scores));\n TfLiteTensor* num_detections;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensorNumDetections,\n &num_detections));\n\n const int num_boxes = input_box_encodings->dims->data[1];\n const int num_classes = op_data->num_classes;\n const int max_categories_per_anchor = op_data->max_classes_per_detection;\n const int num_classes_with_background =\n input_class_predictions->dims->data[2];\n // The row index offset is 1 if background class is included and 0 otherwise.\n int label_offset = num_classes_with_background - num_classes;\n TF_LITE_ENSURE(context, (max_categories_per_anchor > 0));\n const int num_categories_per_anchor =\n std::min(max_categories_per_anchor, num_classes);\n std::vector max_scores;\n max_scores.resize(num_boxes);\n std::vector sorted_class_indices;\n sorted_class_indices.resize(num_boxes * num_classes);\n for (int row = 0; row < num_boxes; row++) {\n const float* box_scores =\n scores + row * num_classes_with_background + label_offset;\n int* class_indices = sorted_class_indices.data() + row * num_classes;\n DecreasingPartialArgSort(box_scores, num_classes, num_categories_per_anchor,\n class_indices);\n max_scores[row] = box_scores[class_indices[0]];\n }\n // Perform non-maximal suppression on max scores\n std::vector selected;\n TF_LITE_ENSURE_STATUS(NonMaxSuppressionSingleClassHelper(\n context, node, op_data, max_scores, &selected, op_data->max_detections));\n // Allocate output tensors\n int output_box_index = 0;\n for (const auto& selected_index : selected) {\n const float* box_scores =\n scores + selected_index * num_classes_with_background + label_offset;\n const int* class_indices =\n sorted_class_indices.data() + selected_index * num_classes;\n\n for (int col = 0; col < num_categories_per_anchor; ++col) {\n int box_offset = num_categories_per_anchor * output_box_index + col;\n // detection_boxes\n ReInterpretTensor(detection_boxes)[box_offset] =\n ReInterpretTensor(\n decoded_boxes)[selected_index];\n // detection_classes\n GetTensorData(detection_classes)[box_offset] = class_indices[col];\n // detection_scores\n GetTensorData(detection_scores)[box_offset] =\n box_scores[class_indices[col]];\n output_box_index++;\n }\n }\n GetTensorData(num_detections)[0] = output_box_index;\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1281, "func": "check_owner_password_V4(std::string& user_password,\n std::string const& owner_password,\n QPDF::EncryptionData const& data)\n{\n // Algorithm 3.7 from the PDF 1.7 Reference Manual\n\n unsigned char key[OU_key_bytes_V4];\n compute_O_rc4_key(user_password, owner_password, data, key);\n unsigned char O_data[key_bytes];\n memcpy(O_data, QUtil::unsigned_char_pointer(data.getO()), key_bytes);\n iterate_rc4(O_data, key_bytes, key, data.getLengthBytes(),\n (data.getR() >= 3) ? 20 : 1, true);\n std::string new_user_password =\n std::string(reinterpret_cast(O_data), key_bytes);\n bool result = false;\n if (check_user_password(new_user_password, data))\n {\n result = true;\n user_password = new_user_password;\n }\n return result;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-18184", "cwe_id": "CWE-125" }, { "id": 1281, "func": "check_owner_password_V4(std::string& user_password,\n std::string const& owner_password,\n QPDF::EncryptionData const& data)\n{\n // Algorithm 3.7 from the PDF 1.7 Reference Manual\n\n unsigned char key[OU_key_bytes_V4];\n compute_O_rc4_key(user_password, owner_password, data, key);\n unsigned char O_data[key_bytes];\n memcpy(O_data, QUtil::unsigned_char_pointer(data.getO()), key_bytes);\n std::string k1(reinterpret_cast(key), OU_key_bytes_V4);\n pad_short_parameter(k1, data.getLengthBytes());\n iterate_rc4(O_data, key_bytes, QUtil::unsigned_char_pointer(k1),\n data.getLengthBytes(),\n (data.getR() >= 3) ? 20 : 1, true);\n std::string new_user_password =\n std::string(reinterpret_cast(O_data), key_bytes);\n bool result = false;\n if (check_user_password(new_user_password, data))\n {\n result = true;\n user_password = new_user_password;\n }\n return result;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-18184", "cwe_id": "CWE-125" }, { "id": 3188, "func": "void Curl_detach_connnection(struct Curl_easy *data)\n{\n struct connectdata *conn = data->conn;\n if(conn)\n Curl_llist_remove(&conn->easyq, &data->conn_queue, NULL);\n data->conn = NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-22901", "cwe_id": "CWE-416" }, { "id": 3188, "func": "void Curl_detach_connnection(struct Curl_easy *data)\n{\n struct connectdata *conn = data->conn;\n if(conn) {\n Curl_llist_remove(&conn->easyq, &data->conn_queue, NULL);\n Curl_ssl_detach_conn(data, conn);\n }\n data->conn = NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-22901", "cwe_id": "CWE-416" }, { "id": 381, "func": "CAMLprim value caml_blit_string(value s1, value ofs1, value s2, value ofs2,\n value n)\n{\n memmove(&Byte(s2, Long_val(ofs2)), &Byte(s1, Long_val(ofs1)), Int_val(n));\n return Val_unit;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-8869", "cwe_id": "CWE-119" }, { "id": 381, "func": "CAMLprim value caml_blit_string(value s1, value ofs1, value s2, value ofs2,\n value n)\n{\n memmove(&Byte(s2, Long_val(ofs2)), &Byte(s1, Long_val(ofs1)), Long_val(n));\n return Val_unit;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-8869", "cwe_id": "CWE-119" }, { "id": 2556, "func": "static Status ValidateSavedTensors(const GraphDef& graph_def) {\n for (const auto& node : graph_def.node()) {\n const auto node_iterator = node.attr().find(\"value\");\n if (node_iterator != node.attr().end()) {\n AttrValue node_value = node_iterator->second;\n if (node_value.has_tensor()) {\n const PartialTensorShape node_shape(node_value.tensor().tensor_shape());\n if (node_shape.num_elements() < 0) {\n return errors::FailedPrecondition(\n \"Saved model contains node \\\"\", node.name(), \"\\\" (op \\\"\",\n node.op(), \"\\\") which initializes from a tensor with \",\n node_shape.num_elements(), \" elements\");\n }\n }\n } else if (node.op() == \"Const\") {\n return errors::FailedPrecondition(\n \"Saved model contains node \\\"\", node.name(),\n \"\\\" which is a constant tensor but no value has been provided\");\n }\n }\n return Status::OK();\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15206", "cwe_id": "CWE-20" }, { "id": 2556, "func": "static Status ValidateSavedTensors(const GraphDef& graph_def) {\n for (const auto& node : graph_def.node()) {\n TF_RETURN_IF_ERROR(ValidateNode(node));\n }\n\n if (graph_def.has_library()) {\n const FunctionDefLibrary& library = graph_def.library();\n for (const auto& function : library.function()) {\n for (const auto& node : function.node_def()) {\n TF_RETURN_IF_ERROR(ValidateNode(node));\n }\n }\n }\n\n return Status::OK();\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15206", "cwe_id": "CWE-20" }, { "id": 1363, "func": "static void nsc_decode(NSC_CONTEXT* context)\n{\n\tUINT16 x;\n\tUINT16 y;\n\tUINT16 rw = ROUND_UP_TO(context->width, 8);\n\tBYTE shift = context->ColorLossLevel - 1; /* colorloss recovery + YCoCg shift */\n\tBYTE* bmpdata = context->BitmapData;\n\n\tfor (y = 0; y < context->height; y++)\n\t{\n\t\tconst BYTE* yplane;\n\t\tconst BYTE* coplane;\n\t\tconst BYTE* cgplane;\n\t\tconst BYTE* aplane = context->priv->PlaneBuffers[3] + y * context->width; /* A */\n\n\t\tif (context->ChromaSubsamplingLevel)\n\t\t{\n\t\t\typlane = context->priv->PlaneBuffers[0] + y * rw; /* Y */\n\t\t\tcoplane = context->priv->PlaneBuffers[1] + (y >> 1) * (rw >>\n\t\t\t 1); /* Co, supersampled */\n\t\t\tcgplane = context->priv->PlaneBuffers[2] + (y >> 1) * (rw >>\n\t\t\t 1); /* Cg, supersampled */\n\t\t}\n\t\telse\n\t\t{\n\t\t\typlane = context->priv->PlaneBuffers[0] + y * context->width; /* Y */\n\t\t\tcoplane = context->priv->PlaneBuffers[1] + y * context->width; /* Co */\n\t\t\tcgplane = context->priv->PlaneBuffers[2] + y * context->width; /* Cg */\n\t\t}\n\n\t\tfor (x = 0; x < context->width; x++)\n\t\t{\n\t\t\tINT16 y_val = (INT16) * yplane;\n\t\t\tINT16 co_val = (INT16)(INT8)(*coplane << shift);\n\t\t\tINT16 cg_val = (INT16)(INT8)(*cgplane << shift);\n\t\t\tINT16 r_val = y_val + co_val - cg_val;\n\t\t\tINT16 g_val = y_val + cg_val;\n\t\t\tINT16 b_val = y_val - co_val - cg_val;\n\t\t\t*bmpdata++ = MINMAX(b_val, 0, 0xFF);\n\t\t\t*bmpdata++ = MINMAX(g_val, 0, 0xFF);\n\t\t\t*bmpdata++ = MINMAX(r_val, 0, 0xFF);\n\t\t\t*bmpdata++ = *aplane;\n\t\t\typlane++;\n\t\t\tcoplane += (context->ChromaSubsamplingLevel ? x % 2 : 1);\n\t\t\tcgplane += (context->ChromaSubsamplingLevel ? x % 2 : 1);\n\t\t\taplane++;\n\t\t}\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-8788", "cwe_id": "CWE-787" }, { "id": 1363, "func": "static BOOL nsc_decode(NSC_CONTEXT* context)\n{\n\tUINT16 x;\n\tUINT16 y;\n\tUINT16 rw;\n\tBYTE shift;\n\tBYTE* bmpdata;\n\tsize_t pos = 0;\n\n\tif (!context)\n\t\treturn FALSE;\n\n\trw = ROUND_UP_TO(context->width, 8);\n\tshift = context->ColorLossLevel - 1; /* colorloss recovery + YCoCg shift */\n\tbmpdata = context->BitmapData;\n\n\tif (!bmpdata)\n\t\treturn FALSE;\n\n\tfor (y = 0; y < context->height; y++)\n\t{\n\t\tconst BYTE* yplane;\n\t\tconst BYTE* coplane;\n\t\tconst BYTE* cgplane;\n\t\tconst BYTE* aplane = context->priv->PlaneBuffers[3] + y * context->width; /* A */\n\n\t\tif (context->ChromaSubsamplingLevel)\n\t\t{\n\t\t\typlane = context->priv->PlaneBuffers[0] + y * rw; /* Y */\n\t\t\tcoplane = context->priv->PlaneBuffers[1] + (y >> 1) * (rw >>\n\t\t\t 1); /* Co, supersampled */\n\t\t\tcgplane = context->priv->PlaneBuffers[2] + (y >> 1) * (rw >>\n\t\t\t 1); /* Cg, supersampled */\n\t\t}\n\t\telse\n\t\t{\n\t\t\typlane = context->priv->PlaneBuffers[0] + y * context->width; /* Y */\n\t\t\tcoplane = context->priv->PlaneBuffers[1] + y * context->width; /* Co */\n\t\t\tcgplane = context->priv->PlaneBuffers[2] + y * context->width; /* Cg */\n\t\t}\n\n\t\tfor (x = 0; x < context->width; x++)\n\t\t{\n\t\t\tINT16 y_val = (INT16) * yplane;\n\t\t\tINT16 co_val = (INT16)(INT8)(*coplane << shift);\n\t\t\tINT16 cg_val = (INT16)(INT8)(*cgplane << shift);\n\t\t\tINT16 r_val = y_val + co_val - cg_val;\n\t\t\tINT16 g_val = y_val + cg_val;\n\t\t\tINT16 b_val = y_val - co_val - cg_val;\n\n\t\t\tif (pos + 4 > context->BitmapDataLength)\n\t\t\t\treturn FALSE;\n\n\t\t\tpos += 4;\n\t\t\t*bmpdata++ = MINMAX(b_val, 0, 0xFF);\n\t\t\t*bmpdata++ = MINMAX(g_val, 0, 0xFF);\n\t\t\t*bmpdata++ = MINMAX(r_val, 0, 0xFF);\n\t\t\t*bmpdata++ = *aplane;\n\t\t\typlane++;\n\t\t\tcoplane += (context->ChromaSubsamplingLevel ? x % 2 : 1);\n\t\t\tcgplane += (context->ChromaSubsamplingLevel ? x % 2 : 1);\n\t\t\taplane++;\n\t\t}\n\t}\n\n\treturn TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-8788", "cwe_id": "CWE-787" }, { "id": 160, "func": "header_gets (SF_PRIVATE *psf, char *ptr, int bufsize)\n{\tint\t\tk ;\n\n\tfor (k = 0 ; k < bufsize - 1 ; k++)\n\t{\tif (psf->headindex < psf->headend)\n\t\t{\tptr [k] = psf->header [psf->headindex] ;\n\t\t\tpsf->headindex ++ ;\n\t\t\t}\n\t\telse\n\t\t{\tpsf->headend += psf_fread (psf->header + psf->headend, 1, 1, psf) ;\n\t\t\tptr [k] = psf->header [psf->headindex] ;\n\t\t\tpsf->headindex = psf->headend ;\n\t\t\t} ;\n\n\t\tif (ptr [k] == '\\n')\n\t\t\tbreak ;\n\t\t} ;\n\n\tptr [k] = 0 ;\n\n\treturn k ;\n} /* header_gets */", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 160, "func": "header_gets (SF_PRIVATE *psf, char *ptr, int bufsize)\n{\tint\t\tk ;\n\n\tif (psf->header.indx + bufsize >= psf->header.len && psf_bump_header_allocation (psf, bufsize))\n\t\treturn 0 ;\n\n\tfor (k = 0 ; k < bufsize - 1 ; k++)\n\t{\tif (psf->header.indx < psf->header.end)\n\t\t{\tptr [k] = psf->header.ptr [psf->header.indx] ;\n\t\t\tpsf->header.indx ++ ;\n\t\t\t}\n\t\telse\n\t\t{\tpsf->header.end += psf_fread (psf->header.ptr + psf->header.end, 1, 1, psf) ;\n\t\t\tptr [k] = psf->header.ptr [psf->header.indx] ;\n\t\t\tpsf->header.indx = psf->header.end ;\n\t\t\t} ;\n\n\t\tif (ptr [k] == '\\n')\n\t\t\tbreak ;\n\t\t} ;\n\n\tptr [k] = 0 ;\n\n\treturn k ;\n} /* header_gets */", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7586", "cwe_id": "CWE-119" }, { "id": 340, "func": " void * alloc_top(size_t size) {\n top -= size;\n if (top < bottom) {new_chunk(); top -= size;}\n return top;\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-25051", "cwe_id": "CWE-787" }, { "id": 340, "func": " void * alloc_top(size_t size, size_t align) \n {loop:\n top -= size;\n align_top(align);\n if (top < bottom) {check_size(size); new_chunk(); goto loop;}\n return top;\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-25051", "cwe_id": "CWE-787" }, { "id": 2962, "func": "static void __munlock_pagevec(struct pagevec *pvec, struct zone *zone)\n{\n\tint i;\n\tint nr = pagevec_count(pvec);\n\tint delta_munlocked;\n\tstruct pagevec pvec_putback;\n\tint pgrescued = 0;\n\n\tpagevec_init(&pvec_putback, 0);\n\n\t/* Phase 1: page isolation */\n\tspin_lock_irq(zone_lru_lock(zone));\n\tfor (i = 0; i < nr; i++) {\n\t\tstruct page *page = pvec->pages[i];\n\n\t\tif (TestClearPageMlocked(page)) {\n\t\t\t/*\n\t\t\t * We already have pin from follow_page_mask()\n\t\t\t * so we can spare the get_page() here.\n\t\t\t */\n\t\t\tif (__munlock_isolate_lru_page(page, false))\n\t\t\t\tcontinue;\n\t\t\telse\n\t\t\t\t__munlock_isolation_failed(page);\n\t\t}\n\n\t\t/*\n\t\t * We won't be munlocking this page in the next phase\n\t\t * but we still need to release the follow_page_mask()\n\t\t * pin. We cannot do it under lru_lock however. If it's\n\t\t * the last pin, __page_cache_release() would deadlock.\n\t\t */\n\t\tpagevec_add(&pvec_putback, pvec->pages[i]);\n\t\tpvec->pages[i] = NULL;\n\t}\n\tdelta_munlocked = -nr + pagevec_count(&pvec_putback);\n\t__mod_zone_page_state(zone, NR_MLOCK, delta_munlocked);\n\tspin_unlock_irq(zone_lru_lock(zone));\n\n\t/* Now we can release pins of pages that we are not munlocking */\n\tpagevec_release(&pvec_putback);\n\n\t/* Phase 2: page munlock */\n\tfor (i = 0; i < nr; i++) {\n\t\tstruct page *page = pvec->pages[i];\n\n\t\tif (page) {\n\t\t\tlock_page(page);\n\t\t\tif (!__putback_lru_fast_prepare(page, &pvec_putback,\n\t\t\t\t\t&pgrescued)) {\n\t\t\t\t/*\n\t\t\t\t * Slow path. We don't want to lose the last\n\t\t\t\t * pin before unlock_page()\n\t\t\t\t */\n\t\t\t\tget_page(page); /* for putback_lru_page() */\n\t\t\t\t__munlock_isolated_page(page);\n\t\t\t\tunlock_page(page);\n\t\t\t\tput_page(page); /* from follow_page_mask() */\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Phase 3: page putback for pages that qualified for the fast path\n\t * This will also call put_page() to return pin from follow_page_mask()\n\t */\n\tif (pagevec_count(&pvec_putback))\n\t\t__putback_lru_fast(&pvec_putback, pgrescued);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-18221", "cwe_id": "CWE-20" }, { "id": 2962, "func": "static void __munlock_pagevec(struct pagevec *pvec, struct zone *zone)\n{\n\tint i;\n\tint nr = pagevec_count(pvec);\n\tint delta_munlocked = -nr;\n\tstruct pagevec pvec_putback;\n\tint pgrescued = 0;\n\n\tpagevec_init(&pvec_putback, 0);\n\n\t/* Phase 1: page isolation */\n\tspin_lock_irq(zone_lru_lock(zone));\n\tfor (i = 0; i < nr; i++) {\n\t\tstruct page *page = pvec->pages[i];\n\n\t\tif (TestClearPageMlocked(page)) {\n\t\t\t/*\n\t\t\t * We already have pin from follow_page_mask()\n\t\t\t * so we can spare the get_page() here.\n\t\t\t */\n\t\t\tif (__munlock_isolate_lru_page(page, false))\n\t\t\t\tcontinue;\n\t\t\telse\n\t\t\t\t__munlock_isolation_failed(page);\n\t\t} else {\n\t\t\tdelta_munlocked++;\n\t\t}\n\n\t\t/*\n\t\t * We won't be munlocking this page in the next phase\n\t\t * but we still need to release the follow_page_mask()\n\t\t * pin. We cannot do it under lru_lock however. If it's\n\t\t * the last pin, __page_cache_release() would deadlock.\n\t\t */\n\t\tpagevec_add(&pvec_putback, pvec->pages[i]);\n\t\tpvec->pages[i] = NULL;\n\t}\n\t__mod_zone_page_state(zone, NR_MLOCK, delta_munlocked);\n\tspin_unlock_irq(zone_lru_lock(zone));\n\n\t/* Now we can release pins of pages that we are not munlocking */\n\tpagevec_release(&pvec_putback);\n\n\t/* Phase 2: page munlock */\n\tfor (i = 0; i < nr; i++) {\n\t\tstruct page *page = pvec->pages[i];\n\n\t\tif (page) {\n\t\t\tlock_page(page);\n\t\t\tif (!__putback_lru_fast_prepare(page, &pvec_putback,\n\t\t\t\t\t&pgrescued)) {\n\t\t\t\t/*\n\t\t\t\t * Slow path. We don't want to lose the last\n\t\t\t\t * pin before unlock_page()\n\t\t\t\t */\n\t\t\t\tget_page(page); /* for putback_lru_page() */\n\t\t\t\t__munlock_isolated_page(page);\n\t\t\t\tunlock_page(page);\n\t\t\t\tput_page(page); /* from follow_page_mask() */\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Phase 3: page putback for pages that qualified for the fast path\n\t * This will also call put_page() to return pin from follow_page_mask()\n\t */\n\tif (pagevec_count(&pvec_putback))\n\t\t__putback_lru_fast(&pvec_putback, pgrescued);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-18221", "cwe_id": "CWE-20" }, { "id": 1613, "func": "static int key_verify(pam_handle_t *pamh, int flags, PKCS11_KEY *authkey)\n{\n\tint ok = 0;\n\tunsigned char challenge[30];\n\tunsigned char signature[256];\n\tunsigned int siglen = sizeof signature;\n\tconst EVP_MD *md = EVP_sha1();\n\tEVP_MD_CTX *md_ctx = EVP_MD_CTX_new();\n\tEVP_PKEY *privkey = PKCS11_get_private_key(authkey);\n\tEVP_PKEY *pubkey = PKCS11_get_public_key(authkey);\n\n\t/* Verify a SHA-1 hash of random data, signed by the key.\n\t *\n\t * Note that this will not work keys that aren't eligible for signing.\n\t * Unfortunately, libp11 currently has no way of checking\n\t * C_GetAttributeValue(CKA_SIGN), see\n\t * https://github.com/OpenSC/libp11/issues/219. Since we don't want to\n\t * implement try and error, we live with this limitation */\n\tif (1 != randomize(pamh, challenge, sizeof challenge)) {\n\t\tgoto err;\n\t}\n\tif (NULL == pubkey || NULL == privkey || NULL == md_ctx || NULL == md\n\t\t\t|| !EVP_SignInit(md_ctx, md)\n\t\t\t|| !EVP_SignUpdate(md_ctx, challenge, sizeof challenge)\n\t\t\t|| !EVP_SignFinal(md_ctx, signature, &siglen, privkey)\n\t\t\t|| !EVP_MD_CTX_reset(md_ctx)\n\t\t\t|| !EVP_VerifyInit(md_ctx, md)\n\t\t\t|| !EVP_VerifyUpdate(md_ctx, challenge, sizeof challenge)\n\t\t\t|| 1 != EVP_VerifyFinal(md_ctx, signature, siglen, pubkey)) {\n\t\tpam_syslog(pamh, LOG_DEBUG, \"Error verifying key: %s\\n\",\n\t\t\t\tERR_reason_error_string(ERR_get_error()));\n\t\tprompt(flags, pamh, PAM_ERROR_MSG, NULL, _(\"Error verifying key\"));\n\t\tgoto err;\n\t}\n\tok = 1;\n\nerr:\n\tif (NULL != pubkey)\n\t\tEVP_PKEY_free(pubkey);\n\tif (NULL != privkey)\n\t\tEVP_PKEY_free(privkey);\n\tif (NULL != md_ctx) {\n\t\tEVP_MD_CTX_free(md_ctx);\n\t}\n\treturn ok;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-16058", "cwe_id": "CWE-119" }, { "id": 1613, "func": "static int key_verify(pam_handle_t *pamh, int flags, PKCS11_KEY *authkey)\n{\n\tint ok = 0;\n\tunsigned char challenge[30];\n\tunsigned char *signature = NULL;\n\tunsigned int siglen;\n\tconst EVP_MD *md = EVP_sha1();\n\tEVP_MD_CTX *md_ctx = EVP_MD_CTX_new();\n\tEVP_PKEY *privkey = PKCS11_get_private_key(authkey);\n\tEVP_PKEY *pubkey = PKCS11_get_public_key(authkey);\n\n\tif (NULL == privkey)\n\t\tgoto err;\n\tsiglen = EVP_PKEY_size(privkey);\n\tif (siglen <= 0)\n\t\tgoto err;\n\tsignature = malloc(siglen);\n\tif (NULL == signature)\n\t\tgoto err;\n\n\t/* Verify a SHA-1 hash of random data, signed by the key.\n\t *\n\t * Note that this will not work keys that aren't eligible for signing.\n\t * Unfortunately, libp11 currently has no way of checking\n\t * C_GetAttributeValue(CKA_SIGN), see\n\t * https://github.com/OpenSC/libp11/issues/219. Since we don't want to\n\t * implement try and error, we live with this limitation */\n\tif (1 != randomize(pamh, challenge, sizeof challenge)) {\n\t\tgoto err;\n\t}\n\tif (NULL == pubkey || NULL == privkey || NULL == md_ctx || NULL == md\n\t\t\t|| !EVP_SignInit(md_ctx, md)\n\t\t\t|| !EVP_SignUpdate(md_ctx, challenge, sizeof challenge)\n\t\t\t|| !EVP_SignFinal(md_ctx, signature, &siglen, privkey)\n\t\t\t|| !EVP_MD_CTX_reset(md_ctx)\n\t\t\t|| !EVP_VerifyInit(md_ctx, md)\n\t\t\t|| !EVP_VerifyUpdate(md_ctx, challenge, sizeof challenge)\n\t\t\t|| 1 != EVP_VerifyFinal(md_ctx, signature, siglen, pubkey)) {\n\t\tpam_syslog(pamh, LOG_DEBUG, \"Error verifying key: %s\\n\",\n\t\t\t\tERR_reason_error_string(ERR_get_error()));\n\t\tprompt(flags, pamh, PAM_ERROR_MSG, NULL, _(\"Error verifying key\"));\n\t\tgoto err;\n\t}\n\tok = 1;\n\nerr:\n\tfree(signature);\n\tif (NULL != pubkey)\n\t\tEVP_PKEY_free(pubkey);\n\tif (NULL != privkey)\n\t\tEVP_PKEY_free(privkey);\n\tif (NULL != md_ctx) {\n\t\tEVP_MD_CTX_free(md_ctx);\n\t}\n\treturn ok;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-16058", "cwe_id": "CWE-119" }, { "id": 816, "func": "mptctl_readtest (unsigned long arg)\n{\n\tstruct mpt_ioctl_test __user *uarg = (void __user *) arg;\n\tstruct mpt_ioctl_test\t karg;\n\tMPT_ADAPTER *ioc;\n\tint iocnum;\n\n\tif (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) {\n\t\tprintk(KERN_ERR MYNAM \"%s@%d::mptctl_readtest - \"\n\t\t\t\"Unable to read in mpt_ioctl_test struct @ %p\\n\",\n\t\t\t\t__FILE__, __LINE__, uarg);\n\t\treturn -EFAULT;\n\t}\n\n\tif (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||\n\t (ioc == NULL)) {\n\t\tprintk(KERN_DEBUG MYNAM \"%s::mptctl_readtest() @%d - ioc%d not found!\\n\",\n\t\t\t\t__FILE__, __LINE__, iocnum);\n\t\treturn -ENODEV;\n\t}\n\n\tdctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT \"mptctl_readtest called.\\n\",\n\t ioc->name));\n\t/* Fill in the data and return the structure to the calling\n\t * program\n\t */\n\n#ifdef MFCNT\n\tkarg.chip_type = ioc->mfcnt;\n#else\n\tkarg.chip_type = ioc->pcidev->device;\n#endif\n\tstrncpy (karg.name, ioc->name, MPT_MAX_NAME);\n\tkarg.name[MPT_MAX_NAME-1]='\\0';\n\tstrncpy (karg.product, ioc->prod_name, MPT_PRODUCT_LENGTH);\n\tkarg.product[MPT_PRODUCT_LENGTH-1]='\\0';\n\n\t/* Copy the data from kernel memory to user memory\n\t */\n\tif (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_test))) {\n\t\tprintk(MYIOC_s_ERR_FMT \"%s@%d::mptctl_readtest - \"\n\t\t\t\"Unable to write out mpt_ioctl_test struct @ %p\\n\",\n\t\t\tioc->name, __FILE__, __LINE__, uarg);\n\t\treturn -EFAULT;\n\t}\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12652", "cwe_id": "CWE-362" }, { "id": 816, "func": "mptctl_readtest (MPT_ADAPTER *ioc, unsigned long arg)\n{\n\tstruct mpt_ioctl_test __user *uarg = (void __user *) arg;\n\tstruct mpt_ioctl_test\t karg;\n\n\tif (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) {\n\t\tprintk(KERN_ERR MYNAM \"%s@%d::mptctl_readtest - \"\n\t\t\t\"Unable to read in mpt_ioctl_test struct @ %p\\n\",\n\t\t\t\t__FILE__, __LINE__, uarg);\n\t\treturn -EFAULT;\n\t}\n\n\tdctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT \"mptctl_readtest called.\\n\",\n\t ioc->name));\n\t/* Fill in the data and return the structure to the calling\n\t * program\n\t */\n\n#ifdef MFCNT\n\tkarg.chip_type = ioc->mfcnt;\n#else\n\tkarg.chip_type = ioc->pcidev->device;\n#endif\n\tstrncpy (karg.name, ioc->name, MPT_MAX_NAME);\n\tkarg.name[MPT_MAX_NAME-1]='\\0';\n\tstrncpy (karg.product, ioc->prod_name, MPT_PRODUCT_LENGTH);\n\tkarg.product[MPT_PRODUCT_LENGTH-1]='\\0';\n\n\t/* Copy the data from kernel memory to user memory\n\t */\n\tif (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_test))) {\n\t\tprintk(MYIOC_s_ERR_FMT \"%s@%d::mptctl_readtest - \"\n\t\t\t\"Unable to write out mpt_ioctl_test struct @ %p\\n\",\n\t\t\tioc->name, __FILE__, __LINE__, uarg);\n\t\treturn -EFAULT;\n\t}\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12652", "cwe_id": "CWE-362" }, { "id": 2145, "func": "static void exif_process_APP12(image_info_type *ImageInfo,\n char *buffer, size_t length) {\n size_t l1, l2=0;\n if ((l1 = php_strnlen(buffer+2, length-2)) > 0) {\n exif_iif_add_tag(ImageInfo, SECTION_APP12, \"Company\",\n TAG_NONE, TAG_FMT_STRING, l1, buffer+2);\n if (length > 2+l1+1) {\n l2 = php_strnlen(buffer+2+l1+1, length-2-l1+1);\n exif_iif_add_tag(ImageInfo, SECTION_APP12, \"Info\",\n TAG_NONE, TAG_FMT_STRING, l2, buffer+2+l1+1);\n }\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-11925", "cwe_id": "CWE-125" }, { "id": 2145, "func": "static void exif_process_APP12(image_info_type *ImageInfo,\n char *buffer, size_t length) {\n size_t l1, l2=0;\n if ((l1 = php_strnlen(buffer+2, length-2)) > 0) {\n exif_iif_add_tag(ImageInfo, SECTION_APP12, \"Company\",\n TAG_NONE, TAG_FMT_STRING, l1, buffer+2);\n if (length > 2+l1+1) {\n l2 = php_strnlen(buffer+2+l1+1, length-2-l1-1);\n exif_iif_add_tag(ImageInfo, SECTION_APP12, \"Info\",\n TAG_NONE, TAG_FMT_STRING, l2, buffer+2+l1+1);\n }\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-11925", "cwe_id": "CWE-125" }, { "id": 2898, "func": "static void mpeg4_encode_gop_header(MpegEncContext *s)\n{\n int hours, minutes, seconds;\n int64_t time;\n\n put_bits(&s->pb, 16, 0);\n put_bits(&s->pb, 16, GOP_STARTCODE);\n\n time = s->current_picture_ptr->f->pts;\n if (s->reordered_input_picture[1])\n time = FFMIN(time, s->reordered_input_picture[1]->f->pts);\n time = time * s->avctx->time_base.num;\n s->last_time_base = FFUDIV(time, s->avctx->time_base.den);\n\n seconds = FFUDIV(time, s->avctx->time_base.den);\n minutes = FFUDIV(seconds, 60); seconds = FFUMOD(seconds, 60);\n hours = FFUDIV(minutes, 60); minutes = FFUMOD(minutes, 60);\n hours = FFUMOD(hours , 24);\n\n put_bits(&s->pb, 5, hours);\n put_bits(&s->pb, 6, minutes);\n put_bits(&s->pb, 1, 1);\n put_bits(&s->pb, 6, seconds);\n\n put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP));\n put_bits(&s->pb, 1, 0); // broken link == NO\n\n ff_mpeg4_stuffing(&s->pb);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-12458", "cwe_id": "CWE-20" }, { "id": 2898, "func": "static void mpeg4_encode_gop_header(MpegEncContext *s)\n{\n int64_t hours, minutes, seconds;\n int64_t time;\n\n put_bits(&s->pb, 16, 0);\n put_bits(&s->pb, 16, GOP_STARTCODE);\n\n time = s->current_picture_ptr->f->pts;\n if (s->reordered_input_picture[1])\n time = FFMIN(time, s->reordered_input_picture[1]->f->pts);\n time = time * s->avctx->time_base.num;\n s->last_time_base = FFUDIV(time, s->avctx->time_base.den);\n\n seconds = FFUDIV(time, s->avctx->time_base.den);\n minutes = FFUDIV(seconds, 60); seconds = FFUMOD(seconds, 60);\n hours = FFUDIV(minutes, 60); minutes = FFUMOD(minutes, 60);\n hours = FFUMOD(hours , 24);\n\n put_bits(&s->pb, 5, hours);\n put_bits(&s->pb, 6, minutes);\n put_bits(&s->pb, 1, 1);\n put_bits(&s->pb, 6, seconds);\n\n put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP));\n put_bits(&s->pb, 1, 0); // broken link == NO\n\n ff_mpeg4_stuffing(&s->pb);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-12458", "cwe_id": "CWE-20" }, { "id": 725, "func": "int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {\n int j, loops = server.cronloops++;\n REDIS_NOTUSED(eventLoop);\n REDIS_NOTUSED(id);\n REDIS_NOTUSED(clientData);\n\n /* We take a cached value of the unix time in the global state because\n * with virtual memory and aging there is to store the current time\n * in objects at every object access, and accuracy is not needed.\n * To access a global var is faster than calling time(NULL) */\n server.unixtime = time(NULL);\n /* We have just 22 bits per object for LRU information.\n * So we use an (eventually wrapping) LRU clock with 10 seconds resolution.\n * 2^22 bits with 10 seconds resoluton is more or less 1.5 years.\n *\n * Note that even if this will wrap after 1.5 years it's not a problem,\n * everything will still work but just some object will appear younger\n * to Redis. But for this to happen a given object should never be touched\n * for 1.5 years.\n *\n * Note that you can change the resolution altering the\n * REDIS_LRU_CLOCK_RESOLUTION define.\n */\n updateLRUClock();\n\n /* We received a SIGTERM, shutting down here in a safe way, as it is\n * not ok doing so inside the signal handler. */\n if (server.shutdown_asap) {\n if (prepareForShutdown() == REDIS_OK) exit(0);\n redisLog(REDIS_WARNING,\"SIGTERM received but errors trying to shut down the server, check the logs for more information\");\n }\n\n /* Show some info about non-empty databases */\n for (j = 0; j < server.dbnum; j++) {\n long long size, used, vkeys;\n\n size = dictSlots(server.db[j].dict);\n used = dictSize(server.db[j].dict);\n vkeys = dictSize(server.db[j].expires);\n if (!(loops % 50) && (used || vkeys)) {\n redisLog(REDIS_VERBOSE,\"DB %d: %lld keys (%lld volatile) in %lld slots HT.\",j,used,vkeys,size);\n /* dictPrintStats(server.dict); */\n }\n }\n\n /* We don't want to resize the hash tables while a bacground saving\n * is in progress: the saving child is created using fork() that is\n * implemented with a copy-on-write semantic in most modern systems, so\n * if we resize the HT while there is the saving child at work actually\n * a lot of memory movements in the parent will cause a lot of pages\n * copied. */\n if (server.bgsavechildpid == -1 && server.bgrewritechildpid == -1) {\n if (!(loops % 10)) tryResizeHashTables();\n if (server.activerehashing) incrementallyRehash();\n }\n\n /* Show information about connected clients */\n if (!(loops % 50)) {\n redisLog(REDIS_VERBOSE,\"%d clients connected (%d slaves), %zu bytes in use\",\n listLength(server.clients)-listLength(server.slaves),\n listLength(server.slaves),\n zmalloc_used_memory());\n }\n\n /* Close connections of timedout clients */\n if ((server.maxidletime && !(loops % 100)) || server.bpop_blocked_clients)\n closeTimedoutClients();\n\n /* Check if a background saving or AOF rewrite in progress terminated */\n if (server.bgsavechildpid != -1 || server.bgrewritechildpid != -1) {\n int statloc;\n pid_t pid;\n\n if ((pid = wait3(&statloc,WNOHANG,NULL)) != 0) {\n if (pid == server.bgsavechildpid) {\n backgroundSaveDoneHandler(statloc);\n } else {\n backgroundRewriteDoneHandler(statloc);\n }\n updateDictResizePolicy();\n }\n } else {\n /* If there is not a background saving in progress check if\n * we have to save now */\n time_t now = time(NULL);\n for (j = 0; j < server.saveparamslen; j++) {\n struct saveparam *sp = server.saveparams+j;\n\n if (server.dirty >= sp->changes &&\n now-server.lastsave > sp->seconds) {\n redisLog(REDIS_NOTICE,\"%d changes in %d seconds. Saving...\",\n sp->changes, sp->seconds);\n rdbSaveBackground(server.dbfilename);\n break;\n }\n }\n }\n\n /* Expire a few keys per cycle, only if this is a master.\n * On slaves we wait for DEL operations synthesized by the master\n * in order to guarantee a strict consistency. */\n if (server.masterhost == NULL) activeExpireCycle();\n\n /* Swap a few keys on disk if we are over the memory limit and VM\n * is enbled. Try to free objects from the free list first. */\n if (vmCanSwapOut()) {\n while (server.vm_enabled && zmalloc_used_memory() >\n server.vm_max_memory)\n {\n int retval = (server.vm_max_threads == 0) ?\n vmSwapOneObjectBlocking() :\n vmSwapOneObjectThreaded();\n if (retval == REDIS_ERR && !(loops % 300) &&\n zmalloc_used_memory() >\n (server.vm_max_memory+server.vm_max_memory/10))\n {\n redisLog(REDIS_WARNING,\"WARNING: vm-max-memory limit exceeded by more than 10%% but unable to swap more objects out!\");\n }\n /* Note that when using threade I/O we free just one object,\n * because anyway when the I/O thread in charge to swap this\n * object out will finish, the handler of completed jobs\n * will try to swap more objects if we are still out of memory. */\n if (retval == REDIS_ERR || server.vm_max_threads > 0) break;\n }\n }\n\n /* Replication cron function -- used to reconnect to master and\n * to detect transfer failures. */\n if (!(loops % 10)) replicationCron();\n\n return 100;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-0178", "cwe_id": "CWE-20" }, { "id": 725, "func": "int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {\n int j, loops = server.cronloops++;\n REDIS_NOTUSED(eventLoop);\n REDIS_NOTUSED(id);\n REDIS_NOTUSED(clientData);\n\n /* We take a cached value of the unix time in the global state because\n * with virtual memory and aging there is to store the current time\n * in objects at every object access, and accuracy is not needed.\n * To access a global var is faster than calling time(NULL) */\n server.unixtime = time(NULL);\n /* We have just 22 bits per object for LRU information.\n * So we use an (eventually wrapping) LRU clock with 10 seconds resolution.\n * 2^22 bits with 10 seconds resoluton is more or less 1.5 years.\n *\n * Note that even if this will wrap after 1.5 years it's not a problem,\n * everything will still work but just some object will appear younger\n * to Redis. But for this to happen a given object should never be touched\n * for 1.5 years.\n *\n * Note that you can change the resolution altering the\n * REDIS_LRU_CLOCK_RESOLUTION define.\n */\n updateLRUClock();\n\n /* We received a SIGTERM, shutting down here in a safe way, as it is\n * not ok doing so inside the signal handler. */\n if (server.shutdown_asap) {\n if (prepareForShutdown() == REDIS_OK) exit(0);\n redisLog(REDIS_WARNING,\"SIGTERM received but errors trying to shut down the server, check the logs for more information\");\n }\n\n /* Show some info about non-empty databases */\n for (j = 0; j < server.dbnum; j++) {\n long long size, used, vkeys;\n\n size = dictSlots(server.db[j].dict);\n used = dictSize(server.db[j].dict);\n vkeys = dictSize(server.db[j].expires);\n if (!(loops % 50) && (used || vkeys)) {\n redisLog(REDIS_VERBOSE,\"DB %d: %lld keys (%lld volatile) in %lld slots HT.\",j,used,vkeys,size);\n /* dictPrintStats(server.dict); */\n }\n }\n\n /* We don't want to resize the hash tables while a bacground saving\n * is in progress: the saving child is created using fork() that is\n * implemented with a copy-on-write semantic in most modern systems, so\n * if we resize the HT while there is the saving child at work actually\n * a lot of memory movements in the parent will cause a lot of pages\n * copied. */\n if (server.bgsavechildpid == -1 && server.bgrewritechildpid == -1) {\n if (!(loops % 10)) tryResizeHashTables();\n if (server.activerehashing) incrementallyRehash();\n }\n\n /* Show information about connected clients */\n if (!(loops % 50)) {\n redisLog(REDIS_VERBOSE,\"%d clients connected (%d slaves), %zu bytes in use\",\n listLength(server.clients)-listLength(server.slaves),\n listLength(server.slaves),\n zmalloc_used_memory());\n }\n\n /* Close connections of timedout clients */\n if ((server.maxidletime && !(loops % 100)) || server.bpop_blocked_clients)\n closeTimedoutClients();\n\n /* Check if a background saving or AOF rewrite in progress terminated */\n if (server.bgsavechildpid != -1 || server.bgrewritechildpid != -1) {\n int statloc;\n pid_t pid;\n\n if ((pid = wait3(&statloc,WNOHANG,NULL)) != 0) {\n if (pid == server.bgsavechildpid) {\n backgroundSaveDoneHandler(statloc);\n } else {\n backgroundRewriteDoneHandler(statloc);\n }\n updateDictResizePolicy();\n }\n } else {\n /* If there is not a background saving in progress check if\n * we have to save now */\n time_t now = time(NULL);\n for (j = 0; j < server.saveparamslen; j++) {\n struct saveparam *sp = server.saveparams+j;\n\n if (server.dirty >= sp->changes &&\n now-server.lastsave > sp->seconds) {\n redisLog(REDIS_NOTICE,\"%d changes in %d seconds. Saving...\",\n sp->changes, sp->seconds);\n rdbSaveBackground(server.dbfilename);\n break;\n }\n }\n }\n\n /* Expire a few keys per cycle, only if this is a master.\n * On slaves we wait for DEL operations synthesized by the master\n * in order to guarantee a strict consistency. */\n if (server.masterhost == NULL) activeExpireCycle();\n\n /* Remove a few cached objects from memory if we are over the\n * configured memory limit */\n while (server.ds_enabled && zmalloc_used_memory() >\n server.cache_max_memory)\n {\n cacheFreeOneEntry();\n }\n\n /* Replication cron function -- used to reconnect to master and\n * to detect transfer failures. */\n if (!(loops % 10)) replicationCron();\n\n return 100;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-0178", "cwe_id": "CWE-20" }, { "id": 1851, "func": "op_insert(oparg_T *oap, long count1)\n{\n long\t\tins_len, pre_textlen = 0;\n char_u\t\t*firstline, *ins_text;\n colnr_T\t\tind_pre_col = 0, ind_post_col;\n int\t\t\tind_pre_vcol = 0, ind_post_vcol = 0;\n struct block_def\tbd;\n int\t\t\ti;\n pos_T\t\tt1;\n pos_T\t\tstart_insert;\n\t\t\t// offset when cursor was moved in insert mode\n int\t\t\toffset = 0;\n\n // edit() changes this - record it for OP_APPEND\n bd.is_MAX = (curwin->w_curswant == MAXCOL);\n\n // vis block is still marked. Get rid of it now.\n curwin->w_cursor.lnum = oap->start.lnum;\n update_screen(INVERTED);\n\n if (oap->block_mode)\n {\n\t// When 'virtualedit' is used, need to insert the extra spaces before\n\t// doing block_prep(). When only \"block\" is used, virtual edit is\n\t// already disabled, but still need it when calling\n\t// coladvance_force().\n\t// coladvance_force() uses get_ve_flags() to get the 'virtualedit'\n\t// state for the current window. To override that state, we need to\n\t// set the window-local value of ve_flags rather than the global value.\n\tif (curwin->w_cursor.coladd > 0)\n\t{\n\t int\t\told_ve_flags = curwin->w_ve_flags;\n\n\t if (u_save_cursor() == FAIL)\n\t\treturn;\n\n\t curwin->w_ve_flags = VE_ALL;\n\t coladvance_force(oap->op_type == OP_APPEND\n\t\t\t\t\t ? oap->end_vcol + 1 : getviscol());\n\t if (oap->op_type == OP_APPEND)\n\t\t--curwin->w_cursor.col;\n\t curwin->w_ve_flags = old_ve_flags;\n\t}\n\t// Get the info about the block before entering the text\n\tblock_prep(oap, &bd, oap->start.lnum, TRUE);\n\t// Get indent information\n\tind_pre_col = (colnr_T)getwhitecols_curline();\n\tind_pre_vcol = get_indent();\n\tfirstline = ml_get(oap->start.lnum) + bd.textcol;\n\n\tif (oap->op_type == OP_APPEND)\n\t firstline += bd.textlen;\n\tpre_textlen = (long)STRLEN(firstline);\n }\n\n if (oap->op_type == OP_APPEND)\n {\n\tif (oap->block_mode && curwin->w_cursor.coladd == 0)\n\t{\n\t // Move the cursor to the character right of the block.\n\t curwin->w_set_curswant = TRUE;\n\t while (*ml_get_cursor() != NUL\n\t\t && (curwin->w_cursor.col < bd.textcol + bd.textlen))\n\t\t++curwin->w_cursor.col;\n\t if (bd.is_short && !bd.is_MAX)\n\t {\n\t\t// First line was too short, make it longer and adjust the\n\t\t// values in \"bd\".\n\t\tif (u_save_cursor() == FAIL)\n\t\t return;\n\t\tfor (i = 0; i < bd.endspaces; ++i)\n\t\t ins_char(' ');\n\t\tbd.textlen += bd.endspaces;\n\t }\n\t}\n\telse\n\t{\n\t curwin->w_cursor = oap->end;\n\t check_cursor_col();\n\n\t // Works just like an 'i'nsert on the next character.\n\t if (!LINEEMPTY(curwin->w_cursor.lnum)\n\t\t && oap->start_vcol != oap->end_vcol)\n\t\tinc_cursor();\n\t}\n }\n\n t1 = oap->start;\n start_insert = curwin->w_cursor;\n (void)edit(NUL, FALSE, (linenr_T)count1);\n\n // When a tab was inserted, and the characters in front of the tab\n // have been converted to a tab as well, the column of the cursor\n // might have actually been reduced, so need to adjust here.\n if (t1.lnum == curbuf->b_op_start_orig.lnum\n\t && LT_POS(curbuf->b_op_start_orig, t1))\n\toap->start = curbuf->b_op_start_orig;\n\n // If user has moved off this line, we don't know what to do, so do\n // nothing.\n // Also don't repeat the insert when Insert mode ended with CTRL-C.\n if (curwin->w_cursor.lnum != oap->start.lnum || got_int)\n\treturn;\n\n if (oap->block_mode)\n {\n\tstruct block_def\tbd2;\n\tint\t\t\tdid_indent = FALSE;\n\tsize_t\t\t\tlen;\n\tint\t\t\tadd;\n\n\t// If indent kicked in, the firstline might have changed\n\t// but only do that, if the indent actually increased.\n\tind_post_col = (colnr_T)getwhitecols_curline();\n\tif (curbuf->b_op_start.col > ind_pre_col && ind_post_col > ind_pre_col)\n\t{\n\t bd.textcol += ind_post_col - ind_pre_col;\n\t ind_post_vcol = get_indent();\n\t bd.start_vcol += ind_post_vcol - ind_pre_vcol;\n\t did_indent = TRUE;\n\t}\n\n\t// The user may have moved the cursor before inserting something, try\n\t// to adjust the block for that. But only do it, if the difference\n\t// does not come from indent kicking in.\n\tif (oap->start.lnum == curbuf->b_op_start_orig.lnum\n\t\t\t\t\t\t && !bd.is_MAX && !did_indent)\n\t{\n\t int t = getviscol2(curbuf->b_op_start_orig.col,\n\t\t\t\t\t curbuf->b_op_start_orig.coladd);\n\n\t if (!bd.is_MAX)\n\t {\n\t\tif (oap->op_type == OP_INSERT\n\t\t\t&& oap->start.col + oap->start.coladd\n\t\t\t\t!= curbuf->b_op_start_orig.col\n\t\t\t\t\t + curbuf->b_op_start_orig.coladd)\n\t\t{\n\t\t oap->start.col = curbuf->b_op_start_orig.col;\n\t\t pre_textlen -= t - oap->start_vcol;\n\t\t oap->start_vcol = t;\n\t\t}\n\t\telse if (oap->op_type == OP_APPEND\n\t\t\t&& oap->end.col + oap->end.coladd\n\t\t\t\t>= curbuf->b_op_start_orig.col\n\t\t\t\t\t + curbuf->b_op_start_orig.coladd)\n\t\t{\n\t\t oap->start.col = curbuf->b_op_start_orig.col;\n\t\t // reset pre_textlen to the value of OP_INSERT\n\t\t pre_textlen += bd.textlen;\n\t\t pre_textlen -= t - oap->start_vcol;\n\t\t oap->start_vcol = t;\n\t\t oap->op_type = OP_INSERT;\n\t\t}\n\t }\n\t else if (bd.is_MAX && oap->op_type == OP_APPEND)\n\t {\n\t\t// reset pre_textlen to the value of OP_INSERT\n\t\tpre_textlen += bd.textlen;\n\t\tpre_textlen -= t - oap->start_vcol;\n\t }\n\t}\n\n\t// Spaces and tabs in the indent may have changed to other spaces and\n\t// tabs. Get the starting column again and correct the length.\n\t// Don't do this when \"$\" used, end-of-line will have changed.\n\t//\n\t// if indent was added and the inserted text was after the indent,\n\t// correct the selection for the new indent.\n\tif (did_indent && bd.textcol - ind_post_col > 0)\n\t{\n\t oap->start.col += ind_post_col - ind_pre_col;\n\t oap->start_vcol += ind_post_vcol - ind_pre_vcol;\n\t oap->end.col += ind_post_col - ind_pre_col;\n\t oap->end_vcol += ind_post_vcol - ind_pre_vcol;\n\t}\n\tblock_prep(oap, &bd2, oap->start.lnum, TRUE);\n\tif (did_indent && bd.textcol - ind_post_col > 0)\n\t{\n\t // undo for where \"oap\" is used below\n\t oap->start.col -= ind_post_col - ind_pre_col;\n\t oap->start_vcol -= ind_post_vcol - ind_pre_vcol;\n\t oap->end.col -= ind_post_col - ind_pre_col;\n\t oap->end_vcol -= ind_post_vcol - ind_pre_vcol;\n\t}\n\tif (!bd.is_MAX || bd2.textlen < bd.textlen)\n\t{\n\t if (oap->op_type == OP_APPEND)\n\t {\n\t\tpre_textlen += bd2.textlen - bd.textlen;\n\t\tif (bd2.endspaces)\n\t\t --bd2.textlen;\n\t }\n\t bd.textcol = bd2.textcol;\n\t bd.textlen = bd2.textlen;\n\t}\n\n\t/*\n\t * Subsequent calls to ml_get() flush the firstline data - take a\n\t * copy of the required string.\n\t */\n\tfirstline = ml_get(oap->start.lnum);\n\tlen = STRLEN(firstline);\n\tadd = bd.textcol;\n\tif (oap->op_type == OP_APPEND)\n\t{\n\t add += bd.textlen;\n\t // account for pressing cursor in insert mode when '$' was used\n\t if (bd.is_MAX\n\t\t&& (start_insert.lnum == Insstart.lnum\n\t\t\t\t\t && start_insert.col > Insstart.col))\n\t {\n\t\toffset = (start_insert.col - Insstart.col);\n\t\tadd -= offset;\n\t\tif (oap->end_vcol > offset)\n\t\t oap->end_vcol -= (offset + 1);\n\t\telse\n\t\t // moved outside of the visual block, what to do?\n\t\t return;\n\t }\n\t}\n\tif ((size_t)add > len)\n\t firstline += len; // short line, point to the NUL\n\telse\n\t firstline += add;\n\tif (pre_textlen >= 0 && (ins_len =\n\t\t\t (long)STRLEN(firstline) - pre_textlen - offset) > 0)\n\t{\n\t ins_text = vim_strnsave(firstline, ins_len);\n\t if (ins_text != NULL)\n\t {\n\t\t// block handled here\n\t\tif (u_save(oap->start.lnum,\n\t\t\t\t\t (linenr_T)(oap->end.lnum + 1)) == OK)\n\t\t block_insert(oap, ins_text, (oap->op_type == OP_INSERT),\n\t\t\t\t\t\t\t\t\t &bd);\n\n\t\tcurwin->w_cursor.col = oap->start.col;\n\t\tcheck_cursor();\n\t\tvim_free(ins_text);\n\t }\n\t}\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-0261", "cwe_id": "CWE-787" }, { "id": 1851, "func": "op_insert(oparg_T *oap, long count1)\n{\n long\t\tins_len, pre_textlen = 0;\n char_u\t\t*firstline, *ins_text;\n colnr_T\t\tind_pre_col = 0, ind_post_col;\n int\t\t\tind_pre_vcol = 0, ind_post_vcol = 0;\n struct block_def\tbd;\n int\t\t\ti;\n pos_T\t\tt1;\n pos_T\t\tstart_insert;\n\t\t\t// offset when cursor was moved in insert mode\n int\t\t\toffset = 0;\n\n // edit() changes this - record it for OP_APPEND\n bd.is_MAX = (curwin->w_curswant == MAXCOL);\n\n // vis block is still marked. Get rid of it now.\n curwin->w_cursor.lnum = oap->start.lnum;\n update_screen(INVERTED);\n\n if (oap->block_mode)\n {\n\t// When 'virtualedit' is used, need to insert the extra spaces before\n\t// doing block_prep(). When only \"block\" is used, virtual edit is\n\t// already disabled, but still need it when calling\n\t// coladvance_force().\n\t// coladvance_force() uses get_ve_flags() to get the 'virtualedit'\n\t// state for the current window. To override that state, we need to\n\t// set the window-local value of ve_flags rather than the global value.\n\tif (curwin->w_cursor.coladd > 0)\n\t{\n\t int\t\told_ve_flags = curwin->w_ve_flags;\n\n\t if (u_save_cursor() == FAIL)\n\t\treturn;\n\n\t curwin->w_ve_flags = VE_ALL;\n\t coladvance_force(oap->op_type == OP_APPEND\n\t\t\t\t\t ? oap->end_vcol + 1 : getviscol());\n\t if (oap->op_type == OP_APPEND)\n\t\t--curwin->w_cursor.col;\n\t curwin->w_ve_flags = old_ve_flags;\n\t}\n\t// Get the info about the block before entering the text\n\tblock_prep(oap, &bd, oap->start.lnum, TRUE);\n\t// Get indent information\n\tind_pre_col = (colnr_T)getwhitecols_curline();\n\tind_pre_vcol = get_indent();\n\tfirstline = ml_get(oap->start.lnum) + bd.textcol;\n\n\tif (oap->op_type == OP_APPEND)\n\t firstline += bd.textlen;\n\tpre_textlen = (long)STRLEN(firstline);\n }\n\n if (oap->op_type == OP_APPEND)\n {\n\tif (oap->block_mode && curwin->w_cursor.coladd == 0)\n\t{\n\t // Move the cursor to the character right of the block.\n\t curwin->w_set_curswant = TRUE;\n\t while (*ml_get_cursor() != NUL\n\t\t && (curwin->w_cursor.col < bd.textcol + bd.textlen))\n\t\t++curwin->w_cursor.col;\n\t if (bd.is_short && !bd.is_MAX)\n\t {\n\t\t// First line was too short, make it longer and adjust the\n\t\t// values in \"bd\".\n\t\tif (u_save_cursor() == FAIL)\n\t\t return;\n\t\tfor (i = 0; i < bd.endspaces; ++i)\n\t\t ins_char(' ');\n\t\tbd.textlen += bd.endspaces;\n\t }\n\t}\n\telse\n\t{\n\t curwin->w_cursor = oap->end;\n\t check_cursor_col();\n\n\t // Works just like an 'i'nsert on the next character.\n\t if (!LINEEMPTY(curwin->w_cursor.lnum)\n\t\t && oap->start_vcol != oap->end_vcol)\n\t\tinc_cursor();\n\t}\n }\n\n t1 = oap->start;\n start_insert = curwin->w_cursor;\n (void)edit(NUL, FALSE, (linenr_T)count1);\n\n // When a tab was inserted, and the characters in front of the tab\n // have been converted to a tab as well, the column of the cursor\n // might have actually been reduced, so need to adjust here.\n if (t1.lnum == curbuf->b_op_start_orig.lnum\n\t && LT_POS(curbuf->b_op_start_orig, t1))\n\toap->start = curbuf->b_op_start_orig;\n\n // If user has moved off this line, we don't know what to do, so do\n // nothing.\n // Also don't repeat the insert when Insert mode ended with CTRL-C.\n if (curwin->w_cursor.lnum != oap->start.lnum || got_int)\n\treturn;\n\n if (oap->block_mode)\n {\n\tstruct block_def\tbd2;\n\tint\t\t\tdid_indent = FALSE;\n\tsize_t\t\t\tlen;\n\tint\t\t\tadd;\n\n\t// If indent kicked in, the firstline might have changed\n\t// but only do that, if the indent actually increased.\n\tind_post_col = (colnr_T)getwhitecols_curline();\n\tif (curbuf->b_op_start.col > ind_pre_col && ind_post_col > ind_pre_col)\n\t{\n\t bd.textcol += ind_post_col - ind_pre_col;\n\t ind_post_vcol = get_indent();\n\t bd.start_vcol += ind_post_vcol - ind_pre_vcol;\n\t did_indent = TRUE;\n\t}\n\n\t// The user may have moved the cursor before inserting something, try\n\t// to adjust the block for that. But only do it, if the difference\n\t// does not come from indent kicking in.\n\tif (oap->start.lnum == curbuf->b_op_start_orig.lnum\n\t\t\t\t\t\t && !bd.is_MAX && !did_indent)\n\t{\n\t int t = getviscol2(curbuf->b_op_start_orig.col,\n\t\t\t\t\t curbuf->b_op_start_orig.coladd);\n\n\t if (!bd.is_MAX)\n\t {\n\t\tif (oap->op_type == OP_INSERT\n\t\t\t&& oap->start.col + oap->start.coladd\n\t\t\t\t!= curbuf->b_op_start_orig.col\n\t\t\t\t\t + curbuf->b_op_start_orig.coladd)\n\t\t{\n\t\t oap->start.col = curbuf->b_op_start_orig.col;\n\t\t pre_textlen -= t - oap->start_vcol;\n\t\t oap->start_vcol = t;\n\t\t}\n\t\telse if (oap->op_type == OP_APPEND\n\t\t\t&& oap->start.col + oap->start.coladd\n\t\t\t\t>= curbuf->b_op_start_orig.col\n\t\t\t\t\t + curbuf->b_op_start_orig.coladd)\n\t\t{\n\t\t oap->start.col = curbuf->b_op_start_orig.col;\n\t\t // reset pre_textlen to the value of OP_INSERT\n\t\t pre_textlen += bd.textlen;\n\t\t pre_textlen -= t - oap->start_vcol;\n\t\t oap->start_vcol = t;\n\t\t oap->op_type = OP_INSERT;\n\t\t}\n\t }\n\t else if (bd.is_MAX && oap->op_type == OP_APPEND)\n\t {\n\t\t// reset pre_textlen to the value of OP_INSERT\n\t\tpre_textlen += bd.textlen;\n\t\tpre_textlen -= t - oap->start_vcol;\n\t }\n\t}\n\n\t// Spaces and tabs in the indent may have changed to other spaces and\n\t// tabs. Get the starting column again and correct the length.\n\t// Don't do this when \"$\" used, end-of-line will have changed.\n\t//\n\t// if indent was added and the inserted text was after the indent,\n\t// correct the selection for the new indent.\n\tif (did_indent && bd.textcol - ind_post_col > 0)\n\t{\n\t oap->start.col += ind_post_col - ind_pre_col;\n\t oap->start_vcol += ind_post_vcol - ind_pre_vcol;\n\t oap->end.col += ind_post_col - ind_pre_col;\n\t oap->end_vcol += ind_post_vcol - ind_pre_vcol;\n\t}\n\tblock_prep(oap, &bd2, oap->start.lnum, TRUE);\n\tif (did_indent && bd.textcol - ind_post_col > 0)\n\t{\n\t // undo for where \"oap\" is used below\n\t oap->start.col -= ind_post_col - ind_pre_col;\n\t oap->start_vcol -= ind_post_vcol - ind_pre_vcol;\n\t oap->end.col -= ind_post_col - ind_pre_col;\n\t oap->end_vcol -= ind_post_vcol - ind_pre_vcol;\n\t}\n\tif (!bd.is_MAX || bd2.textlen < bd.textlen)\n\t{\n\t if (oap->op_type == OP_APPEND)\n\t {\n\t\tpre_textlen += bd2.textlen - bd.textlen;\n\t\tif (bd2.endspaces)\n\t\t --bd2.textlen;\n\t }\n\t bd.textcol = bd2.textcol;\n\t bd.textlen = bd2.textlen;\n\t}\n\n\t/*\n\t * Subsequent calls to ml_get() flush the firstline data - take a\n\t * copy of the required string.\n\t */\n\tfirstline = ml_get(oap->start.lnum);\n\tlen = STRLEN(firstline);\n\tadd = bd.textcol;\n\tif (oap->op_type == OP_APPEND)\n\t{\n\t add += bd.textlen;\n\t // account for pressing cursor in insert mode when '$' was used\n\t if (bd.is_MAX\n\t\t&& (start_insert.lnum == Insstart.lnum\n\t\t\t\t\t && start_insert.col > Insstart.col))\n\t {\n\t\toffset = (start_insert.col - Insstart.col);\n\t\tadd -= offset;\n\t\tif (oap->end_vcol > offset)\n\t\t oap->end_vcol -= (offset + 1);\n\t\telse\n\t\t // moved outside of the visual block, what to do?\n\t\t return;\n\t }\n\t}\n\tif ((size_t)add > len)\n\t firstline += len; // short line, point to the NUL\n\telse\n\t firstline += add;\n\tif (pre_textlen >= 0 && (ins_len =\n\t\t\t (long)STRLEN(firstline) - pre_textlen - offset) > 0)\n\t{\n\t ins_text = vim_strnsave(firstline, ins_len);\n\t if (ins_text != NULL)\n\t {\n\t\t// block handled here\n\t\tif (u_save(oap->start.lnum,\n\t\t\t\t\t (linenr_T)(oap->end.lnum + 1)) == OK)\n\t\t block_insert(oap, ins_text, (oap->op_type == OP_INSERT),\n\t\t\t\t\t\t\t\t\t &bd);\n\n\t\tcurwin->w_cursor.col = oap->start.col;\n\t\tcheck_cursor();\n\t\tvim_free(ins_text);\n\t }\n\t}\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-0261", "cwe_id": "CWE-787" }, { "id": 962, "func": "swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc)\n{\n uint32* wp = (uint32*) cp0;\n tmsize_t wc = cc / 4;\n\n horDiff32(tif, cp0, cc);\n\n TIFFSwabArrayOfLong(wp, wc);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9535", "cwe_id": "CWE-119" }, { "id": 962, "func": "swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc)\n{\n uint32* wp = (uint32*) cp0;\n tmsize_t wc = cc / 4;\n\n if( !horDiff32(tif, cp0, cc) )\n return 0;\n\n TIFFSwabArrayOfLong(wp, wc);\n return 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9535", "cwe_id": "CWE-119" }, { "id": 2719, "func": "static bool parseOperands(char* str, ArmOp *op) {\n\tchar *t = strdup (str);\n\tint operand = 0;\n\tchar *token = t;\n\tchar *x;\n\tint imm_count = 0;\n\tint mem_opt = 0;\n\tif (!token) {\n\t\treturn false;\n\t}\n\n\twhile (token) {\n\t\tchar *next = strchr (token, ',');\n\t\tif (next) {\n\t\t\t*next++ = 0;\n\t\t}\n\t\twhile (token[0] == ' ') {\n\t\t\ttoken++;\n\t\t}\n\t\tif (operand >= MAX_OPERANDS) {\n\t\t\teprintf (\"Too many operands\\n\");\n\t\t\treturn false;\n\t\t}\n\t\top->operands[operand].type = ARM_NOTYPE;\n\t\top->operands[operand].reg_type = ARM_UNDEFINED;\n\t\top->operands[operand].shift = ARM_NO_SHIFT;\n\n\t\twhile (token[0] == ' ' || token[0] == '[' || token[0] == ']') {\n\t\t\ttoken ++;\n\t\t}\n\n\t\tif (!strncmp (token, \"lsl\", 3)) {\n\t\t\top->operands[operand].shift = ARM_LSL;\n\t\t} else if (!strncmp (token, \"lsr\", 3)) {\n\t\t\top->operands[operand].shift = ARM_LSR;\n\t\t} else if (!strncmp (token, \"asr\", 3)) {\n\t\t\top->operands[operand].shift = ARM_ASR;\n\t\t}\n\t\tif (op->operands[operand].shift != ARM_NO_SHIFT) {\n\t\t\top->operands_count ++;\n\t\t\top->operands[operand].shift_amount = r_num_math (NULL, token + 4);\n\t\t\tif (op->operands[operand].shift_amount > 63) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\toperand ++;\n\t\t\ttoken = next;\n\t\t\tcontinue;\n\t\t}\n\n\t\tswitch (token[0]) {\n\t\tcase 'x':\n\t\t\tx = strchr (token, ',');\n\t\t\tif (x) {\n\t\t\t\tx[0] = '\\0';\n\t\t\t}\n\t\t\top->operands_count ++;\n\t\t\top->operands[operand].type = ARM_GPR;\n\t\t\top->operands[operand].reg_type = ARM_REG64;\n\t\t\top->operands[operand].reg = r_num_math (NULL, token + 1);\n\t\t\tif (op->operands[operand].reg > 31) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'w':\n\t\t\top->operands_count ++;\n\t\t\top->operands[operand].type = ARM_GPR;\n\t\t\top->operands[operand].reg_type = ARM_REG32;\n\t\t\top->operands[operand].reg = r_num_math (NULL, token + 1);\n\t\t\tif (op->operands[operand].reg > 31) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'v':\n\t\t\top->operands_count ++;\n\t\t\top->operands[operand].type = ARM_FP;\n\t\t\top->operands[operand].reg = r_num_math (NULL, token + 1);\n\t\t\tbreak;\n\t\tcase 's':\n\t\tcase 'S':\n\t\t\tif (token[1] == 'P' || token [1] == 'p') {\n\t\t\t\tint i;\n\t\t\t\tfor (i = 0; msr_const[i].name; i++) {\n\t\t\t\t\tif (!r_str_ncasecmp (token, msr_const[i].name, strlen (msr_const[i].name))) {\n\t\t\t\t\t\top->operands[operand].sp_val = msr_const[i].val;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\top->operands_count ++;\n\t\t\t\top->operands[operand].type = ARM_GPR;\n\t\t\t\top->operands[operand].reg_type = ARM_SP | ARM_REG64;\n\t\t\t\top->operands[operand].reg = 31;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmem_opt = get_mem_option (token);\n\t\t\tif (mem_opt != -1) {\n\t\t\t\top->operands_count ++;\n\t\t\t\top->operands[operand].type = ARM_MEM_OPT;\n\t\t\t\top->operands[operand].mem_option = mem_opt;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'L':\n\t\tcase 'l':\n\t\tcase 'I':\n\t\tcase 'i':\n\t\tcase 'N':\n\t\tcase 'n':\n\t\tcase 'O':\n\t\tcase 'o':\n\t\tcase 'p':\n\t\tcase 'P':\n\t\t\tmem_opt = get_mem_option (token);\n\t\t\tif (mem_opt != -1) {\n\t\t\t\top->operands_count ++;\n\t\t\t\top->operands[operand].type = ARM_MEM_OPT;\n\t\t\t\top->operands[operand].mem_option = mem_opt;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase '-':\n\t\t\top->operands[operand].sign = -1;\n\t\t\t// falthru\n\t\tdefault:\n\t\t\top->operands_count ++;\n\t\t\top->operands[operand].type = ARM_CONSTANT;\n\t\t\top->operands[operand].immediate = r_num_math (NULL, token);\n\t\t\timm_count++;\n\t\t\tbreak;\n\t\t}\n\t\ttoken = next;\n\n\t\toperand ++;\n\t\tif (operand > MAX_OPERANDS) {\n\t\t\tfree (t);\n\t\t\treturn false;\n\t\t}\n\t}\n\tfree (t);\n\treturn true;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20457", "cwe_id": "CWE-125" }, { "id": 2719, "func": "static bool parseOperands(char* str, ArmOp *op) {\n\tchar *t = strdup (str);\n\tint operand = 0;\n\tchar *token = t;\n\tchar *x;\n\tint imm_count = 0;\n\tint mem_opt = 0;\n\tif (!token) {\n\t\treturn false;\n\t}\n\n\twhile (token) {\n\t\tchar *next = strchr (token, ',');\n\t\tif (next) {\n\t\t\t*next++ = 0;\n\t\t}\n\t\twhile (token[0] == ' ') {\n\t\t\ttoken++;\n\t\t}\n\t\tif (operand >= MAX_OPERANDS) {\n\t\t\teprintf (\"Too many operands\\n\");\n\t\t\treturn false;\n\t\t}\n\t\top->operands[operand].type = ARM_NOTYPE;\n\t\top->operands[operand].reg_type = ARM_UNDEFINED;\n\t\top->operands[operand].shift = ARM_NO_SHIFT;\n\n\t\twhile (token[0] == ' ' || token[0] == '[' || token[0] == ']') {\n\t\t\ttoken ++;\n\t\t}\n\n\t\tif (!strncmp (token, \"lsl\", 3)) {\n\t\t\top->operands[operand].shift = ARM_LSL;\n\t\t} else if (!strncmp (token, \"lsr\", 3)) {\n\t\t\top->operands[operand].shift = ARM_LSR;\n\t\t} else if (!strncmp (token, \"asr\", 3)) {\n\t\t\top->operands[operand].shift = ARM_ASR;\n\t\t}\n\t\tif (strlen (token) > 4 && op->operands[operand].shift != ARM_NO_SHIFT) {\n\t\t\top->operands_count ++;\n\t\t\top->operands[operand].shift_amount = r_num_math (NULL, token + 4);\n\t\t\tif (op->operands[operand].shift_amount > 63) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\toperand ++;\n\t\t\ttoken = next;\n\t\t\tcontinue;\n\t\t}\n\n\t\tswitch (token[0]) {\n\t\tcase 'x':\n\t\t\tx = strchr (token, ',');\n\t\t\tif (x) {\n\t\t\t\tx[0] = '\\0';\n\t\t\t}\n\t\t\top->operands_count ++;\n\t\t\top->operands[operand].type = ARM_GPR;\n\t\t\top->operands[operand].reg_type = ARM_REG64;\n\t\t\top->operands[operand].reg = r_num_math (NULL, token + 1);\n\t\t\tif (op->operands[operand].reg > 31) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'w':\n\t\t\top->operands_count ++;\n\t\t\top->operands[operand].type = ARM_GPR;\n\t\t\top->operands[operand].reg_type = ARM_REG32;\n\t\t\top->operands[operand].reg = r_num_math (NULL, token + 1);\n\t\t\tif (op->operands[operand].reg > 31) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'v':\n\t\t\top->operands_count ++;\n\t\t\top->operands[operand].type = ARM_FP;\n\t\t\top->operands[operand].reg = r_num_math (NULL, token + 1);\n\t\t\tbreak;\n\t\tcase 's':\n\t\tcase 'S':\n\t\t\tif (token[1] == 'P' || token [1] == 'p') {\n\t\t\t\tint i;\n\t\t\t\tfor (i = 0; msr_const[i].name; i++) {\n\t\t\t\t\tif (!r_str_ncasecmp (token, msr_const[i].name, strlen (msr_const[i].name))) {\n\t\t\t\t\t\top->operands[operand].sp_val = msr_const[i].val;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\top->operands_count ++;\n\t\t\t\top->operands[operand].type = ARM_GPR;\n\t\t\t\top->operands[operand].reg_type = ARM_SP | ARM_REG64;\n\t\t\t\top->operands[operand].reg = 31;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmem_opt = get_mem_option (token);\n\t\t\tif (mem_opt != -1) {\n\t\t\t\top->operands_count ++;\n\t\t\t\top->operands[operand].type = ARM_MEM_OPT;\n\t\t\t\top->operands[operand].mem_option = mem_opt;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'L':\n\t\tcase 'l':\n\t\tcase 'I':\n\t\tcase 'i':\n\t\tcase 'N':\n\t\tcase 'n':\n\t\tcase 'O':\n\t\tcase 'o':\n\t\tcase 'p':\n\t\tcase 'P':\n\t\t\tmem_opt = get_mem_option (token);\n\t\t\tif (mem_opt != -1) {\n\t\t\t\top->operands_count ++;\n\t\t\t\top->operands[operand].type = ARM_MEM_OPT;\n\t\t\t\top->operands[operand].mem_option = mem_opt;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase '-':\n\t\t\top->operands[operand].sign = -1;\n\t\t\t// falthru\n\t\tdefault:\n\t\t\top->operands_count ++;\n\t\t\top->operands[operand].type = ARM_CONSTANT;\n\t\t\top->operands[operand].immediate = r_num_math (NULL, token);\n\t\t\timm_count++;\n\t\t\tbreak;\n\t\t}\n\t\ttoken = next;\n\n\t\toperand ++;\n\t\tif (operand > MAX_OPERANDS) {\n\t\t\tfree (t);\n\t\t\treturn false;\n\t\t}\n\t}\n\tfree (t);\n\treturn true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20457", "cwe_id": "CWE-125" }, { "id": 806, "func": "static int mptctl_do_reset(unsigned long arg)\n{\n\tstruct mpt_ioctl_diag_reset __user *urinfo = (void __user *) arg;\n\tstruct mpt_ioctl_diag_reset krinfo;\n\tMPT_ADAPTER\t\t*iocp;\n\n\tif (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) {\n\t\tprintk(KERN_ERR MYNAM \"%s@%d::mptctl_do_reset - \"\n\t\t\t\t\"Unable to copy mpt_ioctl_diag_reset struct @ %p\\n\",\n\t\t\t\t__FILE__, __LINE__, urinfo);\n\t\treturn -EFAULT;\n\t}\n\n\tif (mpt_verify_adapter(krinfo.hdr.iocnum, &iocp) < 0) {\n\t\tprintk(KERN_DEBUG MYNAM \"%s@%d::mptctl_do_reset - ioc%d not found!\\n\",\n\t\t\t\t__FILE__, __LINE__, krinfo.hdr.iocnum);\n\t\treturn -ENODEV; /* (-6) No such device or address */\n\t}\n\n\tdctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT \"mptctl_do_reset called.\\n\",\n\t iocp->name));\n\n\tif (mpt_HardResetHandler(iocp, CAN_SLEEP) != 0) {\n\t\tprintk (MYIOC_s_ERR_FMT \"%s@%d::mptctl_do_reset - reset failed.\\n\",\n\t\t\tiocp->name, __FILE__, __LINE__);\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12652", "cwe_id": "CWE-362" }, { "id": 806, "func": "static int mptctl_do_reset(MPT_ADAPTER *iocp, unsigned long arg)\n{\n\tstruct mpt_ioctl_diag_reset __user *urinfo = (void __user *) arg;\n\tstruct mpt_ioctl_diag_reset krinfo;\n\n\tif (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) {\n\t\tprintk(KERN_ERR MYNAM \"%s@%d::mptctl_do_reset - \"\n\t\t\t\t\"Unable to copy mpt_ioctl_diag_reset struct @ %p\\n\",\n\t\t\t\t__FILE__, __LINE__, urinfo);\n\t\treturn -EFAULT;\n\t}\n\n\tdctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT \"mptctl_do_reset called.\\n\",\n\t iocp->name));\n\n\tif (mpt_HardResetHandler(iocp, CAN_SLEEP) != 0) {\n\t\tprintk (MYIOC_s_ERR_FMT \"%s@%d::mptctl_do_reset - reset failed.\\n\",\n\t\t\tiocp->name, __FILE__, __LINE__);\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12652", "cwe_id": "CWE-362" }, { "id": 1194, "func": "idn2_to_ascii_4i (const uint32_t * input, size_t inlen, char * output, int flags)\n{\n uint32_t *input_u32;\n uint8_t *input_u8, *output_u8;\n size_t length;\n int rc;\n\n if (!input)\n {\n if (output)\n\t*output = 0;\n return IDN2_OK;\n }\n\n input_u32 = (uint32_t *) malloc ((inlen + 1) * sizeof(uint32_t));\n if (!input_u32)\n return IDN2_MALLOC;\n\n u32_cpy (input_u32, input, inlen);\n input_u32[inlen] = 0;\n\n input_u8 = u32_to_u8 (input_u32, inlen + 1, NULL, &length);\n free (input_u32);\n if (!input_u8)\n {\n if (errno == ENOMEM)\n\treturn IDN2_MALLOC;\n return IDN2_ENCODING_ERROR;\n }\n\n rc = idn2_lookup_u8 (input_u8, &output_u8, flags);\n free (input_u8);\n\n if (rc == IDN2_OK)\n {\n /* wow, this is ugly, but libidn manpage states:\n * char * out output zero terminated string that must have room for at\n * least 63 characters plus the terminating zero.\n */\n if (output)\n\tstrcpy (output, (const char *) output_u8);\n\n free(output_u8);\n }\n\n return rc;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-18224", "cwe_id": "CWE-787" }, { "id": 1194, "func": "idn2_to_ascii_4i (const uint32_t * input, size_t inlen, char * output, int flags)\n{\n uint32_t *input_u32;\n uint8_t *input_u8, *output_u8;\n size_t length;\n int rc;\n\n if (!input)\n {\n if (output)\n\t*output = 0;\n return IDN2_OK;\n }\n\n input_u32 = (uint32_t *) malloc ((inlen + 1) * sizeof(uint32_t));\n if (!input_u32)\n return IDN2_MALLOC;\n\n u32_cpy (input_u32, input, inlen);\n input_u32[inlen] = 0;\n\n input_u8 = u32_to_u8 (input_u32, inlen + 1, NULL, &length);\n free (input_u32);\n if (!input_u8)\n {\n if (errno == ENOMEM)\n\treturn IDN2_MALLOC;\n return IDN2_ENCODING_ERROR;\n }\n\n rc = idn2_lookup_u8 (input_u8, &output_u8, flags);\n free (input_u8);\n\n if (rc == IDN2_OK)\n {\n /* wow, this is ugly, but libidn manpage states:\n * char * out output zero terminated string that must have room for at\n * least 63 characters plus the terminating zero.\n */\n size_t len = strlen ((char *) output_u8);\n\n if (len > 63)\n {\n\t free (output_u8);\n\t return IDN2_TOO_BIG_DOMAIN;\n }\n\n if (output)\n\tstrcpy (output, (char *) output_u8);\n\n free (output_u8);\n }\n\n return rc;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-18224", "cwe_id": "CWE-787" }, { "id": 181, "func": "atol8(const char *p, size_t char_cnt)\n{\n\tint64_t l;\n\tint digit;\n \n\tl = 0;\n\twhile (char_cnt-- > 0) {\n\t\tif (*p >= '0' && *p <= '7')\n\t\t\tdigit = *p - '0';\n\t\telse\n\t\t\tbreak;\n\t\tp++;\n\t\tl <<= 3;\n\t\tl |= digit;\n\t}\n\treturn (l);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-14166", "cwe_id": "CWE-125" }, { "id": 181, "func": "atol8(const char *p, size_t char_cnt)\n{\n\tint64_t l;\n\tint digit;\n\n\tif (char_cnt == 0)\n\t\treturn (0);\n\n\tl = 0;\n\twhile (char_cnt-- > 0) {\n\t\tif (*p >= '0' && *p <= '7')\n\t\t\tdigit = *p - '0';\n\t\telse\n\t\t\tbreak;\n\t\tp++;\n\t\tl <<= 3;\n\t\tl |= digit;\n\t}\n\treturn (l);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-14166", "cwe_id": "CWE-125" }, { "id": 1545, "func": "main(void)\n{\n\t/* exec sql begin declare section */\n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\n#line 52 \"dt_test2.pgc\"\n date date1 ;\n \n#line 53 \"dt_test2.pgc\"\n timestamp ts1 , ts2 ;\n \n#line 54 \"dt_test2.pgc\"\n char * text ;\n \n#line 55 \"dt_test2.pgc\"\n interval * i1 ;\n \n#line 56 \"dt_test2.pgc\"\n date * dc ;\n/* exec sql end declare section */\n#line 57 \"dt_test2.pgc\"\n\n\n\tint i, j;\n\tchar *endptr;\n\n\tECPGdebug(1, stderr);\n\n\tts1 = PGTYPEStimestamp_from_asc(\"2003-12-04 17:34:29\", NULL);\n\ttext = PGTYPEStimestamp_to_asc(ts1);\n\n\tprintf(\"timestamp: %s\\n\", text);\n\tfree(text);\n\n\tdate1 = PGTYPESdate_from_timestamp(ts1);\n\tdc = PGTYPESdate_new();\n\t*dc = date1;\n\ttext = PGTYPESdate_to_asc(*dc);\n\tprintf(\"Date of timestamp: %s\\n\", text);\n\tfree(text);\n\tPGTYPESdate_free(dc);\n\n\tfor (i = 0; dates[i]; i++)\n\t{\n\t\tbool err = false;\n\t\tdate1 = PGTYPESdate_from_asc(dates[i], &endptr);\n\t\tif (date1 == INT_MIN) {\n\t\t\terr = true;\n\t\t}\n\t\ttext = PGTYPESdate_to_asc(date1);\n\t\tprintf(\"Date[%d]: %s (%c - %c)\\n\",\n\t\t\t\t\ti, err ? \"-\" : text,\n\t\t\t\t\tendptr ? 'N' : 'Y',\n\t\t\t\t\terr ? 'T' : 'F');\n\t\tfree(text);\n\t\tif (!err)\n\t\t{\n\t\t\tfor (j = 0; times[j]; j++)\n\t\t\t{\n\t\t\t\tint length = strlen(dates[i])\n\t\t\t\t\t\t+ 1\n\t\t\t\t\t\t+ strlen(times[j])\n\t\t\t\t\t\t+ 1;\n\t\t\t\tchar* t = malloc(length);\n\t\t\t\tsprintf(t, \"%s %s\", dates[i], times[j]);\n\t\t\t\tts1 = PGTYPEStimestamp_from_asc(t, NULL);\n\t\t\t\ttext = PGTYPEStimestamp_to_asc(ts1);\n\t\t\t\tif (i != 19 || j != 3) /* timestamp as integer or double differ for this case */\n\t\t\t\t\tprintf(\"TS[%d,%d]: %s\\n\",\n\t\t\t\t\t\ti, j, errno ? \"-\" : text);\n\t\t\t\tfree(text);\n\t\t\t\tfree(t);\n\t\t\t}\n\t\t}\n\t}\n\n\tts1 = PGTYPEStimestamp_from_asc(\"2004-04-04 23:23:23\", NULL);\n\n\tfor (i = 0; intervals[i]; i++)\n\t{\n\t\tinterval *ic;\n\t\ti1 = PGTYPESinterval_from_asc(intervals[i], &endptr);\n\t\tif (*endptr)\n\t\t\tprintf(\"endptr set to %s\\n\", endptr);\n\t\tif (!i1)\n\t\t{\n\t\t\tprintf(\"Error parsing interval %d\\n\", i);\n\t\t\tcontinue;\n\t\t}\n\t\tj = PGTYPEStimestamp_add_interval(&ts1, i1, &ts2);\n\t\tif (j < 0)\n\t\t\tcontinue;\n\t\ttext = PGTYPESinterval_to_asc(i1);\n\t\tprintf(\"interval[%d]: %s\\n\", i, text ? text : \"-\");\n\t\tfree(text);\n\n\t\tic = PGTYPESinterval_new();\n\t\tPGTYPESinterval_copy(i1, ic);\n\t\ttext = PGTYPESinterval_to_asc(i1);\n\t\tprintf(\"interval_copy[%d]: %s\\n\", i, text ? text : \"-\");\n\t\tfree(text);\n\t\tPGTYPESinterval_free(ic);\n\t\tPGTYPESinterval_free(i1);\n\t}\n\n\treturn (0);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-0063", "cwe_id": "CWE-119" }, { "id": 1545, "func": "main(void)\n{\n\t/* exec sql begin declare section */\n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\n#line 62 \"dt_test2.pgc\"\n date date1 ;\n \n#line 63 \"dt_test2.pgc\"\n timestamp ts1 , ts2 ;\n \n#line 64 \"dt_test2.pgc\"\n char * text ;\n \n#line 65 \"dt_test2.pgc\"\n interval * i1 ;\n \n#line 66 \"dt_test2.pgc\"\n date * dc ;\n/* exec sql end declare section */\n#line 67 \"dt_test2.pgc\"\n\n\n\tint i, j;\n\tchar *endptr;\n\n\tECPGdebug(1, stderr);\n\n\tts1 = PGTYPEStimestamp_from_asc(\"2003-12-04 17:34:29\", NULL);\n\ttext = PGTYPEStimestamp_to_asc(ts1);\n\n\tprintf(\"timestamp: %s\\n\", text);\n\tfree(text);\n\n\tdate1 = PGTYPESdate_from_timestamp(ts1);\n\tdc = PGTYPESdate_new();\n\t*dc = date1;\n\ttext = PGTYPESdate_to_asc(*dc);\n\tprintf(\"Date of timestamp: %s\\n\", text);\n\tfree(text);\n\tPGTYPESdate_free(dc);\n\n\tfor (i = 0; dates[i]; i++)\n\t{\n\t\tbool err = false;\n\t\tdate1 = PGTYPESdate_from_asc(dates[i], &endptr);\n\t\tif (date1 == INT_MIN) {\n\t\t\terr = true;\n\t\t}\n\t\ttext = PGTYPESdate_to_asc(date1);\n\t\tprintf(\"Date[%d]: %s (%c - %c)\\n\",\n\t\t\t\t\ti, err ? \"-\" : text,\n\t\t\t\t\tendptr ? 'N' : 'Y',\n\t\t\t\t\terr ? 'T' : 'F');\n\t\tfree(text);\n\t\tif (!err)\n\t\t{\n\t\t\tfor (j = 0; times[j]; j++)\n\t\t\t{\n\t\t\t\tint length = strlen(dates[i])\n\t\t\t\t\t\t+ 1\n\t\t\t\t\t\t+ strlen(times[j])\n\t\t\t\t\t\t+ 1;\n\t\t\t\tchar* t = malloc(length);\n\t\t\t\tsprintf(t, \"%s %s\", dates[i], times[j]);\n\t\t\t\tts1 = PGTYPEStimestamp_from_asc(t, NULL);\n\t\t\t\ttext = PGTYPEStimestamp_to_asc(ts1);\n\t\t\t\tif (i != 19 || j != 3) /* timestamp as integer or double differ for this case */\n\t\t\t\t\tprintf(\"TS[%d,%d]: %s\\n\",\n\t\t\t\t\t\ti, j, errno ? \"-\" : text);\n\t\t\t\tfree(text);\n\t\t\t\tfree(t);\n\t\t\t}\n\t\t}\n\t}\n\n\tts1 = PGTYPEStimestamp_from_asc(\"2004-04-04 23:23:23\", NULL);\n\n\tfor (i = 0; intervals[i]; i++)\n\t{\n\t\tinterval *ic;\n\t\ti1 = PGTYPESinterval_from_asc(intervals[i], &endptr);\n\t\tif (*endptr)\n\t\t\tprintf(\"endptr set to %s\\n\", endptr);\n\t\tif (!i1)\n\t\t{\n\t\t\tprintf(\"Error parsing interval %d\\n\", i);\n\t\t\tcontinue;\n\t\t}\n\t\tj = PGTYPEStimestamp_add_interval(&ts1, i1, &ts2);\n\t\tif (j < 0)\n\t\t\tcontinue;\n\t\ttext = PGTYPESinterval_to_asc(i1);\n\t\tprintf(\"interval[%d]: %s\\n\", i, text ? text : \"-\");\n\t\tfree(text);\n\n\t\tic = PGTYPESinterval_new();\n\t\tPGTYPESinterval_copy(i1, ic);\n\t\ttext = PGTYPESinterval_to_asc(i1);\n\t\tprintf(\"interval_copy[%d]: %s\\n\", i, text ? text : \"-\");\n\t\tfree(text);\n\t\tPGTYPESinterval_free(ic);\n\t\tPGTYPESinterval_free(i1);\n\t}\n\n\treturn (0);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-0063", "cwe_id": "CWE-119" }, { "id": 864, "func": "fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mrb_bool resume, mrb_bool vmexec)\n{\n struct mrb_context *c = fiber_check(mrb, self);\n struct mrb_context *old_c = mrb->c;\n enum mrb_fiber_state status;\n mrb_value value;\n\n fiber_check_cfunc(mrb, c);\n status = c->status;\n switch (status) {\n case MRB_FIBER_TRANSFERRED:\n if (resume) {\n mrb_raise(mrb, E_FIBER_ERROR, \"resuming transferred fiber\");\n }\n break;\n case MRB_FIBER_RUNNING:\n case MRB_FIBER_RESUMED:\n mrb_raise(mrb, E_FIBER_ERROR, \"double resume\");\n break;\n case MRB_FIBER_TERMINATED:\n mrb_raise(mrb, E_FIBER_ERROR, \"resuming dead fiber\");\n break;\n default:\n break;\n }\n old_c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;\n c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);\n fiber_switch_context(mrb, c);\n if (status == MRB_FIBER_CREATED) {\n mrb_value *b, *e;\n\n if (!c->ci->proc) {\n mrb_raise(mrb, E_FIBER_ERROR, \"double resume (current)\");\n }\n mrb_stack_extend(mrb, len+2); /* for receiver and (optional) block */\n b = c->stbase+1;\n e = b + len;\n while (bci--; /* pop dummy callinfo */\n }\n c->cibase->n = len;\n value = c->stbase[0] = MRB_PROC_ENV(c->cibase->proc)->stack[0];\n }\n else {\n value = fiber_result(mrb, a, len);\n if (vmexec) {\n c->ci[1].stack[0] = value;\n }\n }\n\n if (vmexec) {\n c->vmexec = TRUE;\n value = mrb_vm_exec(mrb, c->ci->proc, c->ci->pc);\n mrb->c = old_c;\n }\n else {\n MARK_CONTEXT_MODIFY(c);\n }\n return value;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-0890", "cwe_id": "CWE-476" }, { "id": 864, "func": "fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mrb_bool resume, mrb_bool vmexec)\n{\n struct mrb_context *c = fiber_check(mrb, self);\n struct mrb_context *old_c = mrb->c;\n enum mrb_fiber_state status;\n mrb_value value;\n\n fiber_check_cfunc(mrb, c);\n status = c->status;\n switch (status) {\n case MRB_FIBER_TRANSFERRED:\n if (resume) {\n mrb_raise(mrb, E_FIBER_ERROR, \"resuming transferred fiber\");\n }\n break;\n case MRB_FIBER_RUNNING:\n case MRB_FIBER_RESUMED:\n mrb_raise(mrb, E_FIBER_ERROR, \"double resume\");\n break;\n case MRB_FIBER_TERMINATED:\n mrb_raise(mrb, E_FIBER_ERROR, \"resuming dead fiber\");\n break;\n default:\n break;\n }\n old_c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;\n c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);\n fiber_switch_context(mrb, c);\n if (status == MRB_FIBER_CREATED) {\n mrb_value *b, *e;\n\n if (!c->ci->proc) {\n mrb_raise(mrb, E_FIBER_ERROR, \"double resume (current)\");\n }\n if (vmexec) {\n c->ci--; /* pop dummy callinfo */\n }\n if (len >= 15) {\n mrb_stack_extend(mrb, 3); /* for receiver, args and (optional) block */\n c->stbase[1] = mrb_ary_new_from_values(mrb, len, a);\n len = 15;\n }\n else {\n mrb_stack_extend(mrb, len+2); /* for receiver and (optional) block */\n b = c->stbase+1;\n e = b + len;\n while (bcibase->n = len;\n value = c->stbase[0] = MRB_PROC_ENV(c->cibase->proc)->stack[0];\n }\n else {\n value = fiber_result(mrb, a, len);\n if (vmexec) {\n c->ci[1].stack[0] = value;\n }\n }\n\n if (vmexec) {\n c->vmexec = TRUE;\n value = mrb_vm_exec(mrb, c->ci->proc, c->ci->pc);\n mrb->c = old_c;\n }\n else {\n MARK_CONTEXT_MODIFY(c);\n }\n return value;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-0890", "cwe_id": "CWE-476" }, { "id": 1919, "func": "int yr_object_array_set_item(\n YR_OBJECT* object,\n YR_OBJECT* item,\n int index)\n{\n YR_OBJECT_ARRAY* array;\n\n int i;\n int count;\n\n assert(index >= 0);\n assert(object->type == OBJECT_TYPE_ARRAY);\n\n array = object_as_array(object);\n\n if (array->items == NULL)\n {\n count = yr_max(64, (index + 1) * 2);\n\n array->items = (YR_ARRAY_ITEMS*) yr_malloc(\n sizeof(YR_ARRAY_ITEMS) + count * sizeof(YR_OBJECT*));\n\n if (array->items == NULL)\n return ERROR_INSUFFICIENT_MEMORY;\n\n memset(array->items->objects, 0, count * sizeof(YR_OBJECT*));\n\n array->items->count = count;\n }\n else if (index >= array->items->count)\n {\n count = array->items->count * 2;\n array->items = (YR_ARRAY_ITEMS*) yr_realloc(\n array->items,\n sizeof(YR_ARRAY_ITEMS) + count * sizeof(YR_OBJECT*));\n\n if (array->items == NULL)\n return ERROR_INSUFFICIENT_MEMORY;\n\n for (i = array->items->count; i < count; i++)\n array->items->objects[i] = NULL;\n\n array->items->count = count;\n }\n\n item->parent = object;\n array->items->objects[index] = item;\n\n return ERROR_SUCCESS;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-11328", "cwe_id": "CWE-119" }, { "id": 1919, "func": "int yr_object_array_set_item(\n YR_OBJECT* object,\n YR_OBJECT* item,\n int index)\n{\n YR_OBJECT_ARRAY* array;\n\n int i;\n int count;\n\n assert(index >= 0);\n assert(object->type == OBJECT_TYPE_ARRAY);\n\n array = object_as_array(object);\n\n if (array->items == NULL)\n {\n count = 64;\n\n while (count <= index)\n count *= 2;\n\n array->items = (YR_ARRAY_ITEMS*) yr_malloc(\n sizeof(YR_ARRAY_ITEMS) + count * sizeof(YR_OBJECT*));\n\n if (array->items == NULL)\n return ERROR_INSUFFICIENT_MEMORY;\n\n memset(array->items->objects, 0, count * sizeof(YR_OBJECT*));\n\n array->items->count = count;\n }\n else if (index >= array->items->count)\n {\n count = array->items->count * 2;\n\n while (count <= index)\n count *= 2;\n\n array->items = (YR_ARRAY_ITEMS*) yr_realloc(\n array->items,\n sizeof(YR_ARRAY_ITEMS) + count * sizeof(YR_OBJECT*));\n\n if (array->items == NULL)\n return ERROR_INSUFFICIENT_MEMORY;\n\n for (i = array->items->count; i < count; i++)\n array->items->objects[i] = NULL;\n\n array->items->count = count;\n }\n\n item->parent = object;\n array->items->objects[index] = item;\n\n return ERROR_SUCCESS;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-11328", "cwe_id": "CWE-119" }, { "id": 3059, "func": "TfLiteStatus NotEqualEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n bool requires_broadcast = !HaveSameShapes(input1, input2);\n switch (input1->type) {\n case kTfLiteBool:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteFloat32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt64:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteUInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteString:\n ComparisonString(reference_ops::StringRefNotEqualFn, input1, input2,\n output, requires_broadcast);\n break;\n default:\n context->ReportError(\n context,\n \"Does not support type %d, requires bool|float|int|uint8|string\",\n input1->type);\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3059, "func": "TfLiteStatus NotEqualEval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n bool requires_broadcast = !HaveSameShapes(input1, input2);\n switch (input1->type) {\n case kTfLiteBool:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteFloat32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt32:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteInt64:\n Comparison(input1, input2, output,\n requires_broadcast);\n break;\n case kTfLiteUInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteInt8:\n ComparisonQuantized(\n input1, input2, output, requires_broadcast);\n break;\n case kTfLiteString:\n ComparisonString(reference_ops::StringRefNotEqualFn, input1, input2,\n output, requires_broadcast);\n break;\n default:\n context->ReportError(\n context,\n \"Does not support type %d, requires bool|float|int|uint8|string\",\n input1->type);\n return kTfLiteError;\n }\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1632, "func": "void Context::onDelete() {\n if (wasm_->onDelete_) {\n wasm_->onDelete_(this, id_);\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-10739", "cwe_id": "CWE-476" }, { "id": 1632, "func": "void Context::onDelete() {\n if (in_vm_context_created_ && wasm_->onDelete_) {\n wasm_->onDelete_(this, id_);\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-10739", "cwe_id": "CWE-476" }, { "id": 120, "func": "vhost_scsi_send_evt(struct vhost_scsi *vs,\n\t\t struct vhost_scsi_tpg *tpg,\n\t\t struct se_lun *lun,\n\t\t u32 event,\n\t\t u32 reason)\n{\n\tstruct vhost_scsi_evt *evt;\n\n\tevt = vhost_scsi_allocate_evt(vs, event, reason);\n\tif (!evt)\n\t\treturn;\n\n\tif (tpg && lun) {\n\t\t/* TODO: share lun setup code with virtio-scsi.ko */\n\t\t/*\n\t\t * Note: evt->event is zeroed when we allocate it and\n\t\t * lun[4-7] need to be zero according to virtio-scsi spec.\n\t\t */\n\t\tevt->event.lun[0] = 0x01;\n\t\tevt->event.lun[1] = tpg->tport_tpgt & 0xFF;\n\t\tif (lun->unpacked_lun >= 256)\n\t\t\tevt->event.lun[2] = lun->unpacked_lun >> 8 | 0x40 ;\n\t\tevt->event.lun[3] = lun->unpacked_lun & 0xFF;\n\t}\n\n\tllist_add(&evt->list, &vs->vs_event_list);\n\tvhost_work_queue(&vs->dev, &vs->vs_event_work);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-4036", "cwe_id": "CWE-119" }, { "id": 120, "func": "vhost_scsi_send_evt(struct vhost_scsi *vs,\n\t\t struct vhost_scsi_tpg *tpg,\n\t\t struct se_lun *lun,\n\t\t u32 event,\n\t\t u32 reason)\n{\n\tstruct vhost_scsi_evt *evt;\n\n\tevt = vhost_scsi_allocate_evt(vs, event, reason);\n\tif (!evt)\n\t\treturn;\n\n\tif (tpg && lun) {\n\t\t/* TODO: share lun setup code with virtio-scsi.ko */\n\t\t/*\n\t\t * Note: evt->event is zeroed when we allocate it and\n\t\t * lun[4-7] need to be zero according to virtio-scsi spec.\n\t\t */\n\t\tevt->event.lun[0] = 0x01;\n\t\tevt->event.lun[1] = tpg->tport_tpgt;\n\t\tif (lun->unpacked_lun >= 256)\n\t\t\tevt->event.lun[2] = lun->unpacked_lun >> 8 | 0x40 ;\n\t\tevt->event.lun[3] = lun->unpacked_lun & 0xFF;\n\t}\n\n\tllist_add(&evt->list, &vs->vs_event_list);\n\tvhost_work_queue(&vs->dev, &vs->vs_event_work);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-4036", "cwe_id": "CWE-119" }, { "id": 1839, "func": "TEST_F(ZNCTest, AwayNotify) {\n auto znc = Run();\n auto ircd = ConnectIRCd();\n auto client = ConnectClient();\n client.Write(\"CAP LS\");\n client.Write(\"PASS :hunter2\");\n client.Write(\"NICK nick\");\n client.Write(\"USER user/test x x :x\");\n QByteArray cap_ls;\n client.ReadUntilAndGet(\" LS :\", cap_ls);\n ASSERT_THAT(cap_ls.toStdString(), AllOf(HasSubstr(\"cap-notify\"), Not(HasSubstr(\"away-notify\"))));\n client.Write(\"CAP REQ :cap-notify\");\n client.ReadUntil(\"ACK :cap-notify\");\n client.Write(\"CAP END\");\n client.ReadUntil(\" 001 \");\n ircd.ReadUntil(\"USER\");\n ircd.Write(\"CAP user LS :away-notify\");\n ircd.ReadUntil(\"CAP REQ :away-notify\");\n ircd.Write(\"CAP user ACK :away-notify\");\n ircd.ReadUntil(\"CAP END\");\n ircd.Write(\":server 001 user :welcome\");\n client.ReadUntil(\"CAP user NEW :away-notify\");\n client.Write(\"CAP REQ :away-notify\");\n client.ReadUntil(\"ACK :away-notify\");\n ircd.Write(\":x!y@z AWAY :reason\");\n client.ReadUntil(\":x!y@z AWAY :reason\");\n ircd.Close();\n client.ReadUntil(\"DEL :away-notify\");\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-13775", "cwe_id": "CWE-476" }, { "id": 1839, "func": "TEST_F(ZNCTest, StatusEchoMessage) {\n auto znc = Run();\n auto ircd = ConnectIRCd();\n auto client = LoginClient();\n client.Write(\"CAP REQ :echo-message\");\n client.Write(\"PRIVMSG *status :blah\");\n client.ReadUntil(\":nick!user@irc.znc.in PRIVMSG *status :blah\");\n client.ReadUntil(\":*status!znc@znc.in PRIVMSG nick :Unknown command\");\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-13775", "cwe_id": "CWE-476" }, { "id": 94, "func": "void EvalHybrid(TfLiteContext* context, TfLiteNode* node,\n TfLiteConvParams* params, OpData* data,\n const TfLiteTensor* input, const TfLiteTensor* filter,\n const TfLiteTensor* bias, TfLiteTensor* im2col,\n TfLiteTensor* accum_scratch, TfLiteTensor* output) {\n float output_activation_min, output_activation_max;\n CalculateActivationRange(params->activation, &output_activation_min,\n &output_activation_max);\n\n const int input_size = NumElements(input) / SizeOfDimension(input, 0);\n const int batch_size = SizeOfDimension(input, 0);\n\n const float* input_ptr = GetTensorData(input);\n int8_t* quantized_input_ptr_batch = GetTensorData(\n GetTemporary(context, node, data->input_quantized_index));\n float* scaling_factors_ptr = GetTensorData(\n GetTemporary(context, node, data->scaling_factors_index));\n\n // Per-batch input quantization for higher accuracy.\n {\n ruy::profiler::ScopeLabel label(\"ConvHybridQuantizeInputs\");\n for (int b = 0; b < batch_size; ++b) {\n float unused_min, unused_max;\n const int offset = b * input_size;\n tensor_utils::SymmetricQuantizeFloats(\n input_ptr + offset, input_size, quantized_input_ptr_batch + offset,\n &unused_min, &unused_max, &scaling_factors_ptr[b]);\n scaling_factors_ptr[b] *= filter->params.scale;\n }\n }\n\n switch (kernel_type) {\n case kReference:\n case kGenericOptimized:\n case kMultithreadOptimized:\n case kCblasOptimized: {\n // There is only one implementation for hybrid kernel.\n ConvParams op_params;\n op_params.padding_type = PaddingType::kSame;\n op_params.padding_values.width = data->padding.width;\n op_params.padding_values.height = data->padding.height;\n op_params.stride_width = params->stride_width;\n op_params.stride_height = params->stride_height;\n op_params.dilation_width_factor = 1;\n op_params.dilation_height_factor = 1;\n op_params.float_activation_min = output_activation_min;\n op_params.float_activation_max = output_activation_max;\n optimized_ops::HybridConv(\n op_params, scaling_factors_ptr, GetTensorShape(input),\n quantized_input_ptr_batch, GetTensorShape(filter),\n GetTensorData(filter), GetTensorShape(bias),\n GetTensorData(bias), GetTensorShape(accum_scratch),\n GetTensorData(accum_scratch), GetTensorShape(output),\n GetTensorData(output), GetTensorShape(im2col),\n GetTensorData(im2col),\n CpuBackendContext::GetFromContext(context));\n break;\n }\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 94, "func": "TfLiteStatus EvalHybrid(TfLiteContext* context, TfLiteNode* node,\n TfLiteConvParams* params, OpData* data,\n const TfLiteTensor* input, const TfLiteTensor* filter,\n const TfLiteTensor* bias, TfLiteTensor* im2col,\n TfLiteTensor* accum_scratch, TfLiteTensor* output) {\n float output_activation_min, output_activation_max;\n CalculateActivationRange(params->activation, &output_activation_min,\n &output_activation_max);\n\n const int input_size = NumElements(input) / SizeOfDimension(input, 0);\n const int batch_size = SizeOfDimension(input, 0);\n\n const float* input_ptr = GetTensorData(input);\n TfLiteTensor* quantized_input_tensor;\n TF_LITE_ENSURE_OK(context,\n GetTemporarySafe(context, node, data->input_quantized_index,\n &quantized_input_tensor));\n int8_t* quantized_input_ptr_batch =\n GetTensorData(quantized_input_tensor);\n TfLiteTensor* scaling_factors_tensor;\n TF_LITE_ENSURE_OK(context,\n GetTemporarySafe(context, node, data->scaling_factors_index,\n &scaling_factors_tensor));\n float* scaling_factors_ptr = GetTensorData(scaling_factors_tensor);\n\n // Per-batch input quantization for higher accuracy.\n {\n ruy::profiler::ScopeLabel label(\"ConvHybridQuantizeInputs\");\n for (int b = 0; b < batch_size; ++b) {\n float unused_min, unused_max;\n const int offset = b * input_size;\n tensor_utils::SymmetricQuantizeFloats(\n input_ptr + offset, input_size, quantized_input_ptr_batch + offset,\n &unused_min, &unused_max, &scaling_factors_ptr[b]);\n scaling_factors_ptr[b] *= filter->params.scale;\n }\n }\n\n switch (kernel_type) {\n case kReference:\n case kGenericOptimized:\n case kMultithreadOptimized:\n case kCblasOptimized: {\n // There is only one implementation for hybrid kernel.\n ConvParams op_params;\n op_params.padding_type = PaddingType::kSame;\n op_params.padding_values.width = data->padding.width;\n op_params.padding_values.height = data->padding.height;\n op_params.stride_width = params->stride_width;\n op_params.stride_height = params->stride_height;\n op_params.dilation_width_factor = 1;\n op_params.dilation_height_factor = 1;\n op_params.float_activation_min = output_activation_min;\n op_params.float_activation_max = output_activation_max;\n optimized_ops::HybridConv(\n op_params, scaling_factors_ptr, GetTensorShape(input),\n quantized_input_ptr_batch, GetTensorShape(filter),\n GetTensorData(filter), GetTensorShape(bias),\n GetTensorData(bias), GetTensorShape(accum_scratch),\n GetTensorData(accum_scratch), GetTensorShape(output),\n GetTensorData(output), GetTensorShape(im2col),\n GetTensorData(im2col),\n CpuBackendContext::GetFromContext(context));\n break;\n }\n }\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2970, "func": "grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)\n{\n struct grub_ext2_data *data = node->data;\n struct grub_ext2_inode *inode = &node->inode;\n int blknr = -1;\n unsigned int blksz = EXT2_BLOCK_SIZE (data);\n int log2_blksz = LOG2_EXT2_BLOCK_SIZE (data);\n\n if (grub_le_to_cpu32(inode->flags) & EXT4_EXTENTS_FLAG)\n {\n#ifndef _MSC_VER\n\t char buf[EXT2_BLOCK_SIZE (data)];\n#else\n\t char * buf = grub_malloc (EXT2_BLOCK_SIZE(data));\n#endif\n struct grub_ext4_extent_header *leaf;\n struct grub_ext4_extent *ext;\n int i;\n\n leaf = grub_ext4_find_leaf (data, buf,\n\t\t (struct grub_ext4_extent_header *) inode->blocks.dir_blocks,\n\t\t fileblock);\n if (! leaf)\n {\n grub_error (GRUB_ERR_BAD_FS, \"invalid extent\");\n return -1;\n }\n\n ext = (struct grub_ext4_extent *) (leaf + 1);\n for (i = 0; i < grub_le_to_cpu16 (leaf->entries); i++)\n {\n if (fileblock < grub_le_to_cpu32 (ext[i].block))\n break;\n }\n\n if (--i >= 0)\n {\n fileblock -= grub_le_to_cpu32 (ext[i].block);\n if (fileblock >= grub_le_to_cpu16 (ext[i].len))\n return 0;\n else\n {\n grub_disk_addr_t start;\n\n start = grub_le_to_cpu16 (ext[i].start_hi);\n start = (start << 32) + grub_le_to_cpu32 (ext[i].start);\n\n return fileblock + start;\n }\n }\n else\n {\n grub_error (GRUB_ERR_BAD_FS, \"something wrong with extent\");\n return -1;\n }\n }\n /* Direct blocks. */\n if (fileblock < INDIRECT_BLOCKS) {\n blknr = grub_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]);\n /* Indirect. */\n } else if (fileblock < INDIRECT_BLOCKS + blksz / 4)\n {\n grub_uint32_t *indir;\n\n indir = grub_malloc (blksz);\n if (! indir)\n\treturn grub_errno;\n\n if (grub_disk_read (data->disk,\n\t\t\t ((grub_disk_addr_t)\n\t\t\t grub_le_to_cpu32 (inode->blocks.indir_block))\n\t\t\t << log2_blksz,\n\t\t\t 0, blksz, indir))\n\treturn grub_errno;\n\n blknr = grub_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]);\n grub_free (indir);\n }\n /* Double indirect. */\n else if (fileblock < (grub_disk_addr_t)(INDIRECT_BLOCKS + blksz / 4) \\\n\t\t * (grub_disk_addr_t)(blksz / 4 + 1))\n {\n unsigned int perblock = blksz / 4;\n unsigned int rblock = fileblock - (INDIRECT_BLOCKS\n\t\t\t\t\t + blksz / 4);\n grub_uint32_t *indir;\n\n indir = grub_malloc (blksz);\n if (! indir)\n\treturn grub_errno;\n\n if (grub_disk_read (data->disk,\n\t\t\t ((grub_disk_addr_t)\n\t\t\t grub_le_to_cpu32 (inode->blocks.double_indir_block))\n\t\t\t << log2_blksz,\n\t\t\t 0, blksz, indir))\n\treturn grub_errno;\n\n if (grub_disk_read (data->disk,\n\t\t\t ((grub_disk_addr_t)\n\t\t\t grub_le_to_cpu32 (indir[rblock / perblock]))\n\t\t\t << log2_blksz,\n\t\t\t 0, blksz, indir))\n\treturn grub_errno;\n\n blknr = grub_le_to_cpu32 (indir[rblock % perblock]);\n grub_free (indir);\n }\n /* triple indirect. */\n else\n {\n grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,\n\t\t \"ext2fs doesn't support triple indirect blocks\");\n }\n\n return blknr;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-9763", "cwe_id": "CWE-119" }, { "id": 2970, "func": "grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)\n{\n struct grub_ext2_data *data = node->data;\n struct grub_ext2_inode *inode = &node->inode;\n int blknr = -1;\n unsigned int blksz = EXT2_BLOCK_SIZE (data);\n int log2_blksz = LOG2_EXT2_BLOCK_SIZE (data);\n\n if (grub_le_to_cpu32(inode->flags) & EXT4_EXTENTS_FLAG)\n {\n\t char * buf = grub_malloc (EXT2_BLOCK_SIZE (data));\n if (!buf) {\n return -1;\n }\n struct grub_ext4_extent_header *leaf;\n struct grub_ext4_extent *ext;\n int i;\n\n leaf = grub_ext4_find_leaf (data, buf,\n\t\t (struct grub_ext4_extent_header *) inode->blocks.dir_blocks,\n\t\t fileblock);\n if (! leaf)\n {\n grub_error (GRUB_ERR_BAD_FS, \"invalid extent\");\n\t free (buf);\n return -1;\n }\n\n ext = (struct grub_ext4_extent *) (leaf + 1);\n for (i = 0; i < grub_le_to_cpu16 (leaf->entries); i++)\n {\n if (fileblock < grub_le_to_cpu32 (ext[i].block))\n break;\n }\n\n if (--i >= 0)\n {\n fileblock -= grub_le_to_cpu32 (ext[i].block);\n if (fileblock >= grub_le_to_cpu16 (ext[i].len)) {\n \t free (buf);\n return 0;\n } else\n {\n grub_disk_addr_t start;\n\n start = grub_le_to_cpu16 (ext[i].start_hi);\n start = (start << 32) + grub_le_to_cpu32 (ext[i].start);\n \t free (buf);\n\n return fileblock + start;\n }\n }\n else\n {\n grub_error (GRUB_ERR_BAD_FS, \"something wrong with extent\");\n \t free (buf);\n return -1;\n }\nfree (buf);\n }\n /* Direct blocks. */\n if (fileblock < INDIRECT_BLOCKS) {\n blknr = grub_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]);\n /* Indirect. */\n } else if (fileblock < INDIRECT_BLOCKS + blksz / 4)\n {\n grub_uint32_t *indir;\n\n indir = grub_malloc (blksz);\n if (! indir) {\n\treturn grub_errno;\n}\n\n if (grub_disk_read (data->disk,\n\t\t\t ((grub_disk_addr_t)\n\t\t\t grub_le_to_cpu32 (inode->blocks.indir_block))\n\t\t\t << log2_blksz,\n\t\t\t 0, blksz, indir)) {\n\treturn grub_errno;\n}\n\n blknr = grub_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]);\n grub_free (indir);\n }\n /* Double indirect. */\n else if (fileblock < (grub_disk_addr_t)(INDIRECT_BLOCKS + blksz / 4) \\\n\t\t * (grub_disk_addr_t)(blksz / 4 + 1))\n {\n unsigned int perblock = blksz / 4;\n unsigned int rblock = fileblock - (INDIRECT_BLOCKS\n\t\t\t\t\t + blksz / 4);\n grub_uint32_t *indir;\n\n indir = grub_malloc (blksz);\n if (! indir) {\n\treturn grub_errno;\n}\n\n if (grub_disk_read (data->disk,\n\t\t\t ((grub_disk_addr_t)\n\t\t\t grub_le_to_cpu32 (inode->blocks.double_indir_block))\n\t\t\t << log2_blksz,\n\t\t\t 0, blksz, indir)) {\n\treturn grub_errno;\n}\n\n if (grub_disk_read (data->disk,\n\t\t\t ((grub_disk_addr_t)\n\t\t\t grub_le_to_cpu32 (indir[rblock / perblock]))\n\t\t\t << log2_blksz,\n\t\t\t 0, blksz, indir)) {\n\treturn grub_errno;\n}\n\n blknr = grub_le_to_cpu32 (indir[rblock % perblock]);\n grub_free (indir);\n }\n /* triple indirect. */\n else\n {\n grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,\n\t\t \"ext2fs doesn't support triple indirect blocks\");\n }\n\n return blknr;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-9763", "cwe_id": "CWE-119" }, { "id": 1406, "func": "bool DISOpticalFlowImpl::ocl_calc(InputArray I0, InputArray I1, InputOutputArray flow)\n{\n UMat I0Mat = I0.getUMat();\n UMat I1Mat = I1.getUMat();\n bool use_input_flow = false;\n if (flow.sameSize(I0) && flow.depth() == CV_32F && flow.channels() == 2)\n use_input_flow = true;\n else\n flow.create(I1Mat.size(), CV_32FC2);\n UMat &u_flowMat = flow.getUMatRef();\n coarsest_scale = min((int)(log(max(I0Mat.cols, I0Mat.rows) / (4.0 * patch_size)) / log(2.0) + 0.5), /* Original code serach for maximal movement of width/4 */\n (int)(log(min(I0Mat.cols, I0Mat.rows) / patch_size) / log(2.0))); /* Deepest pyramid level greater or equal than patch*/\n\n ocl_prepareBuffers(I0Mat, I1Mat, u_flowMat, use_input_flow);\n u_Ux[coarsest_scale].setTo(0.0f);\n u_Uy[coarsest_scale].setTo(0.0f);\n\n for (int i = coarsest_scale; i >= finest_scale; i--)\n {\n w = u_I0s[i].cols;\n h = u_I0s[i].rows;\n ws = 1 + (w - patch_size) / patch_stride;\n hs = 1 + (h - patch_size) / patch_stride;\n\n if (!ocl_precomputeStructureTensor(u_I0xx_buf, u_I0yy_buf, u_I0xy_buf,\n u_I0x_buf, u_I0y_buf, u_I0xs[i], u_I0ys[i]))\n return false;\n\n if (!ocl_PatchInverseSearch(u_Ux[i], u_Uy[i], u_I0s[i], u_I1s_ext[i], u_I0xs[i], u_I0ys[i], 2, i))\n return false;\n\n if (!ocl_Densification(u_Ux[i], u_Uy[i], u_Sx, u_Sy, u_I0s[i], u_I1s[i]))\n return false;\n\n if (variational_refinement_iter > 0)\n variational_refinement_processors[i]->calcUV(u_I0s[i], u_I1s[i],\n u_Ux[i].getMat(ACCESS_WRITE), u_Uy[i].getMat(ACCESS_WRITE));\n\n if (i > finest_scale)\n {\n resize(u_Ux[i], u_Ux[i - 1], u_Ux[i - 1].size());\n resize(u_Uy[i], u_Uy[i - 1], u_Uy[i - 1].size());\n multiply(u_Ux[i - 1], 2, u_Ux[i - 1]);\n multiply(u_Uy[i - 1], 2, u_Uy[i - 1]);\n }\n }\n vector uxy(2);\n uxy[0] = u_Ux[finest_scale];\n uxy[1] = u_Uy[finest_scale];\n merge(uxy, u_U);\n resize(u_U, u_flowMat, u_flowMat.size());\n multiply(u_flowMat, 1 << finest_scale, u_flowMat);\n\n return true;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19624", "cwe_id": "CWE-125" }, { "id": 1406, "func": "bool DISOpticalFlowImpl::ocl_calc(InputArray I0, InputArray I1, InputOutputArray flow)\n{\n UMat I0Mat = I0.getUMat();\n UMat I1Mat = I1.getUMat();\n bool use_input_flow = false;\n if (flow.sameSize(I0) && flow.depth() == CV_32F && flow.channels() == 2)\n use_input_flow = true;\n else\n flow.create(I1Mat.size(), CV_32FC2);\n UMat &u_flowMat = flow.getUMatRef();\n coarsest_scale = min((int)(log(max(I0Mat.cols, I0Mat.rows) / (4.0 * patch_size)) / log(2.0) + 0.5), /* Original code search for maximal movement of width/4 */\n (int)(log(min(I0Mat.cols, I0Mat.rows) / patch_size) / log(2.0))); /* Deepest pyramid level greater or equal than patch*/\n\n if (coarsest_scale<0)\n CV_Error(cv::Error::StsBadSize, \"The input image must have either width or height >= 12\");\n\n if (coarsest_scale= finest_scale; i--)\n {\n w = u_I0s[i].cols;\n h = u_I0s[i].rows;\n ws = 1 + (w - patch_size) / patch_stride;\n hs = 1 + (h - patch_size) / patch_stride;\n\n if (!ocl_precomputeStructureTensor(u_I0xx_buf, u_I0yy_buf, u_I0xy_buf,\n u_I0x_buf, u_I0y_buf, u_I0xs[i], u_I0ys[i]))\n return false;\n\n if (!ocl_PatchInverseSearch(u_Ux[i], u_Uy[i], u_I0s[i], u_I1s_ext[i], u_I0xs[i], u_I0ys[i], 2, i))\n return false;\n\n if (!ocl_Densification(u_Ux[i], u_Uy[i], u_Sx, u_Sy, u_I0s[i], u_I1s[i]))\n return false;\n\n if (variational_refinement_iter > 0)\n variational_refinement_processors[i]->calcUV(u_I0s[i], u_I1s[i],\n u_Ux[i].getMat(ACCESS_WRITE), u_Uy[i].getMat(ACCESS_WRITE));\n\n if (i > finest_scale)\n {\n resize(u_Ux[i], u_Ux[i - 1], u_Ux[i - 1].size());\n resize(u_Uy[i], u_Uy[i - 1], u_Uy[i - 1].size());\n multiply(u_Ux[i - 1], 2, u_Ux[i - 1]);\n multiply(u_Uy[i - 1], 2, u_Uy[i - 1]);\n }\n }\n vector uxy(2);\n uxy[0] = u_Ux[finest_scale];\n uxy[1] = u_Uy[finest_scale];\n merge(uxy, u_U);\n resize(u_U, u_flowMat, u_flowMat.size());\n multiply(u_flowMat, 1 << finest_scale, u_flowMat);\n\n return true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19624", "cwe_id": "CWE-125" }, { "id": 73, "func": "static int msp430_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAnalOpMask mask) {\n\tint ret;\n\tstruct msp430_cmd cmd;\n\n\tmemset (&cmd, 0, sizeof (cmd));\n\t//op->id = ???;\n\top->size = -1;\n\top->nopcode = 1;\n\top->type = R_ANAL_OP_TYPE_UNK;\n\top->family = R_ANAL_OP_FAMILY_CPU;\n\n\tret = op->size = msp430_decode_command (buf, len, &cmd);\n\tif (mask & R_ANAL_OP_MASK_DISASM) {\n\t\tif (ret < 1) {\n\t\t\top->mnemonic = strdup (\"invalid\");\n\t\t} else if (ret > 0) {\n\t\t\tif (cmd.operands[0]) {\n\t\t\t\top->mnemonic = r_str_newf (\"%s %s\",cmd.instr, cmd.operands);\n\t\t\t} else {\n\t\t\t\top->mnemonic = strdup (cmd.instr);\n\t\t\t}\n\t\t}\n\t\t{ // if (a->syntax != R_ASM_SYNTAX_ATT)\n\t\t\tchar *ba = op->mnemonic;\n\t\t\tr_str_replace_ch (ba, '#', 0, 1);\n\t\t\t// r_str_replace_ch (ba, \"$\", \"$$\", 1);\n\t\t\tr_str_replace_ch (ba, '&', 0, 1);\n\t\t\tr_str_replace_ch (ba, '%', 0, 1);\n\t\t}\n\t}\n\n\tif (ret < 0) {\n\t\treturn ret;\n\t}\n\n\top->addr = addr;\n\n\tswitch (cmd.type) {\n\tcase MSP430_ONEOP:\n\t\tswitch (cmd.opcode) {\n\t\tcase MSP430_RRA:\n\t\tcase MSP430_RRC:\n\t\t\top->type = R_ANAL_OP_TYPE_ROR;\n\t\t\tbreak;\n\t\tcase MSP430_PUSH:\n\t\t\top->type = R_ANAL_OP_TYPE_PUSH;\n\t\t\tbreak;\n\t\tcase MSP430_CALL:\n\t\t\top->type = R_ANAL_OP_TYPE_CALL;\n\t\t\top->fail = addr + op->size;\n\t\t\top->jump = r_read_at_le16 (buf, 2);\n\t\t\tbreak;\n\t\tcase MSP430_RETI:\n\t\t\top->type = R_ANAL_OP_TYPE_RET;\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\tcase MSP430_TWOOP:\n\t\tswitch (cmd.opcode) {\n\t\tcase MSP430_BIT:\n\t\tcase MSP430_BIC:\n\t\tcase MSP430_BIS:\n\t\tcase MSP430_MOV:\n\t\t\top->type = R_ANAL_OP_TYPE_MOV;\n\t\t\tif ((cmd.instr)[0] == 'b' && (cmd.instr)[1] == 'r') {\n\t\t\t\t// Emulated branch instruction, moves source operand to PC register.\n\t\t\t\top->type = R_ANAL_OP_TYPE_UJMP;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase MSP430_DADD:\n\t\tcase MSP430_ADDC:\n\t\tcase MSP430_ADD: op->type = R_ANAL_OP_TYPE_ADD; break;\n\t\tcase MSP430_SUBC:\n\t\tcase MSP430_SUB: op->type = R_ANAL_OP_TYPE_SUB; break;\n\t\tcase MSP430_CMP: op->type = R_ANAL_OP_TYPE_CMP; break;\n\t\tcase MSP430_XOR: op->type = R_ANAL_OP_TYPE_XOR; break;\n\t\tcase MSP430_AND: op->type = R_ANAL_OP_TYPE_AND; break;\n\t\t}\n\t\tbreak;\n\tcase MSP430_JUMP:\n\t\tif (cmd.jmp_cond == MSP430_JMP) {\n\t\t\top->type = R_ANAL_OP_TYPE_JMP;\n\t\t} else {\n\t\t\top->type = R_ANAL_OP_TYPE_CJMP;\n\t\t}\n\t\top->jump = addr + cmd.jmp_addr;\n\t\top->fail = addr + 2;\n\t\tbreak;\n\tcase MSP430_INV:\n\t\top->type = R_ANAL_OP_TYPE_ILL;\n\t\tbreak;\n\tdefault:\n\t\top->type = R_ANAL_OP_TYPE_UNK;\n\t\tbreak;\n\t}\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-1714", "cwe_id": "CWE-787" }, { "id": 73, "func": "static int msp430_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAnalOpMask mask) {\n\tstruct msp430_cmd cmd = {0};\n\top->size = -1;\n\top->nopcode = 1;\n\top->type = R_ANAL_OP_TYPE_UNK;\n\top->family = R_ANAL_OP_FAMILY_CPU;\n\n\tint ret = op->size = msp430_decode_command (buf, len, &cmd);\n\tif (mask & R_ANAL_OP_MASK_DISASM) {\n\t\tif (ret < 1) {\n\t\t\top->mnemonic = strdup (\"invalid\");\n\t\t} else if (ret > 0) {\n\t\t\tif (cmd.operands[0]) {\n\t\t\t\top->mnemonic = r_str_newf (\"%s %s\",cmd.instr, cmd.operands);\n\t\t\t} else {\n\t\t\t\top->mnemonic = strdup (cmd.instr);\n\t\t\t}\n\t\t}\n\t\t{ // if (a->syntax != R_ASM_SYNTAX_ATT)\n\t\t\tchar *ba = op->mnemonic;\n\t\t\tr_str_replace_ch (ba, '#', 0, 1);\n\t\t\t// r_str_replace_ch (ba, \"$\", \"$$\", 1);\n\t\t\tr_str_replace_ch (ba, '&', 0, 1);\n\t\t\tr_str_replace_ch (ba, '%', 0, 1);\n\t\t}\n\t}\n\n\tif (ret < 0) {\n\t\treturn ret;\n\t}\n\n\top->addr = addr;\n\n\tswitch (cmd.type) {\n\tcase MSP430_ONEOP:\n\t\tswitch (cmd.opcode) {\n\t\tcase MSP430_RRA:\n\t\tcase MSP430_RRC:\n\t\t\top->type = R_ANAL_OP_TYPE_ROR;\n\t\t\tbreak;\n\t\tcase MSP430_PUSH:\n\t\t\top->type = R_ANAL_OP_TYPE_PUSH;\n\t\t\tbreak;\n\t\tcase MSP430_CALL:\n\t\t\top->type = R_ANAL_OP_TYPE_CALL;\n\t\t\top->fail = addr + op->size;\n\t\t\tif (len > 4) {\n\t\t\t\top->jump = r_read_at_le16 (buf, 2);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase MSP430_RETI:\n\t\t\top->type = R_ANAL_OP_TYPE_RET;\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\tcase MSP430_TWOOP:\n\t\tswitch (cmd.opcode) {\n\t\tcase MSP430_BIT:\n\t\tcase MSP430_BIC:\n\t\tcase MSP430_BIS:\n\t\tcase MSP430_MOV:\n\t\t\top->type = R_ANAL_OP_TYPE_MOV;\n\t\t\tif ((cmd.instr)[0] == 'b' && (cmd.instr)[1] == 'r') {\n\t\t\t\t// Emulated branch instruction, moves source operand to PC register.\n\t\t\t\top->type = R_ANAL_OP_TYPE_UJMP;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase MSP430_DADD:\n\t\tcase MSP430_ADDC:\n\t\tcase MSP430_ADD: op->type = R_ANAL_OP_TYPE_ADD; break;\n\t\tcase MSP430_SUBC:\n\t\tcase MSP430_SUB: op->type = R_ANAL_OP_TYPE_SUB; break;\n\t\tcase MSP430_CMP: op->type = R_ANAL_OP_TYPE_CMP; break;\n\t\tcase MSP430_XOR: op->type = R_ANAL_OP_TYPE_XOR; break;\n\t\tcase MSP430_AND: op->type = R_ANAL_OP_TYPE_AND; break;\n\t\t}\n\t\tbreak;\n\tcase MSP430_JUMP:\n\t\tif (cmd.jmp_cond == MSP430_JMP) {\n\t\t\top->type = R_ANAL_OP_TYPE_JMP;\n\t\t} else {\n\t\t\top->type = R_ANAL_OP_TYPE_CJMP;\n\t\t}\n\t\top->jump = addr + cmd.jmp_addr;\n\t\top->fail = addr + 2;\n\t\tbreak;\n\tcase MSP430_INV:\n\t\top->type = R_ANAL_OP_TYPE_ILL;\n\t\tbreak;\n\tdefault:\n\t\top->type = R_ANAL_OP_TYPE_UNK;\n\t\tbreak;\n\t}\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-1714", "cwe_id": "CWE-787" }, { "id": 3108, "func": "void PngImg::InitStorage_() {\n rowPtrs_.resize(info_.height, nullptr);\n data_ = new png_byte[info_.height * info_.rowbytes];\n\n for(size_t i = 0; i < info_.height; ++i) {\n rowPtrs_[i] = data_ + i * info_.rowbytes;\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-28248", "cwe_id": "CWE-787" }, { "id": 3108, "func": "void PngImg::InitStorage_() {\n rowPtrs_.resize(info_.height, nullptr);\n // Extend height and rowbytes from uint32_t to size_t to avoid multiplication overflow when size_t is larger\n size_t h = info_.height;\n size_t rb = info_.rowbytes;\n // We need to make sure that info_.height * info_.rowbytes will not overflow size_t\n // Unfotunately, there's no simple and portable way to do this in C++\n // For integer division of positive numbers a * b > c <==> a > c / b holds\n if (h > std::numeric_limits::max() / rb) {\n // TODO Propagate this exception to JS, and test it\n throw std::runtime_error(\"Image is too large to allocate single buffer\");\n }\n data_ = new png_byte[h * rb];\n\n for(size_t i = 0; i < info_.height; ++i) {\n rowPtrs_[i] = data_ + i * rb;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-28248", "cwe_id": "CWE-787" }, { "id": 2362, "func": "void stm32h7xxEthInitGpio(NetInterface *interface)\n{\n GPIO_InitTypeDef GPIO_InitStructure;\n\n//STM32F743I-EVAL, STM32F747I-EVAL or STM32H747I-Discovery evaluation board?\n#if defined(USE_STM32H743I_EVAL) || defined(USE_STM32H747I_EVAL) || \\\n defined(USE_STM32H747I_DISCO)\n //Enable SYSCFG clock\n __HAL_RCC_SYSCFG_CLK_ENABLE();\n\n //Enable GPIO clocks\n __HAL_RCC_GPIOA_CLK_ENABLE();\n __HAL_RCC_GPIOC_CLK_ENABLE();\n __HAL_RCC_GPIOG_CLK_ENABLE();\n\n //Select RMII interface mode\n HAL_SYSCFG_ETHInterfaceSelect(SYSCFG_ETH_RMII);\n\n //Configure RMII pins\n GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;\n GPIO_InitStructure.Pull = GPIO_NOPULL;\n GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\n GPIO_InitStructure.Alternate = GPIO_AF11_ETH;\n\n //Configure ETH_RMII_REF_CLK (PA1), ETH_MDIO (PA2) and ETH_RMII_CRS_DV (PA7)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;\n HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);\n\n //Configure ETH_MDC (PC1), ETH_RMII_RXD0 (PC4) and ETH_RMII_RXD1 (PC5)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;\n HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);\n\n //Configure RMII_TX_EN (PG11), ETH_RMII_TXD1 (PG12) and ETH_RMII_TXD0 (PG13)\n GPIO_InitStructure.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;\n HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);\n\n//STM32H745I-Discovery or STM32H750B-DK evaluation board?\n#elif defined(USE_STM32H745I_DISCO) || defined(USE_STM32H750B_DISCO)\n //Enable SYSCFG clock\n __HAL_RCC_SYSCFG_CLK_ENABLE();\n\n //Enable GPIO clocks\n __HAL_RCC_GPIOA_CLK_ENABLE();\n __HAL_RCC_GPIOB_CLK_ENABLE();\n __HAL_RCC_GPIOC_CLK_ENABLE();\n __HAL_RCC_GPIOE_CLK_ENABLE();\n __HAL_RCC_GPIOG_CLK_ENABLE();\n __HAL_RCC_GPIOH_CLK_ENABLE();\n __HAL_RCC_GPIOI_CLK_ENABLE();\n\n //Select MII interface mode\n HAL_SYSCFG_ETHInterfaceSelect(SYSCFG_ETH_MII);\n\n //Configure MII pins\n GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;\n GPIO_InitStructure.Pull = GPIO_NOPULL;\n GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\n GPIO_InitStructure.Alternate = GPIO_AF11_ETH;\n\n //Configure ETH_MII_RX_CLK (PA1), ETH_MDIO (PA2) and ETH_MII_RX_DV (PA7)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;\n HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);\n\n //Configure ETH_MII_RXD2 (PB0), ETH_MII_RXD3 (PB1) and ETH_MII_RX_ER (PB2)\n GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2;\n HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);\n\n //Configure ETH_MDC (PC1), ETH_MII_TXD2 (PC2), ETH_MII_TX_CLK (PC3),\n //ETH_MII_RXD0 (PC4) and ETH_MII_RXD1 (PC5)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5;\n HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);\n\n //Configure ETH_MII_TXD3 (PE2)\n GPIO_InitStructure.Pin = GPIO_PIN_2;\n HAL_GPIO_Init(GPIOE, &GPIO_InitStructure);\n\n //Configure ETH_MII_TX_EN (PG11), ETH_MII_TXD1 (PG12) and ETH_MII_TXD0 (PG13)\n GPIO_InitStructure.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;\n HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);\n\n //Configure ETH_MII_CRS (PH2) and ETH_MII_COL (PH3)\n //GPIO_InitStructure.Pin = GPIO_PIN_2 | GPIO_PIN_3;\n //HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);\n\n //Configure ETH_MII_RX_ER (PI10)\n GPIO_InitStructure.Pin = GPIO_PIN_10;\n HAL_GPIO_Init(GPIOI, &GPIO_InitStructure);\n\n//Nucleo-H743ZI, Nucleo-H743ZI2 or Nucleo-H745ZI-Q evaluation board?\n#elif defined(USE_STM32H7XX_NUCLEO_144) || defined(USE_STM32H7XX_NUCLEO_144_MB1363) || \\\n defined(USE_STM32H7XX_NUCLEO_144_MB1364)\n //Enable SYSCFG clock\n __HAL_RCC_SYSCFG_CLK_ENABLE();\n\n //Enable GPIO clocks\n __HAL_RCC_GPIOA_CLK_ENABLE();\n __HAL_RCC_GPIOB_CLK_ENABLE();\n __HAL_RCC_GPIOC_CLK_ENABLE();\n __HAL_RCC_GPIOG_CLK_ENABLE();\n\n //Select RMII interface mode\n HAL_SYSCFG_ETHInterfaceSelect(SYSCFG_ETH_RMII);\n\n //Configure RMII pins\n GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;\n GPIO_InitStructure.Pull = GPIO_NOPULL;\n GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\n GPIO_InitStructure.Alternate = GPIO_AF11_ETH;\n\n //Configure ETH_RMII_REF_CLK (PA1), ETH_MDIO (PA2) and ETH_RMII_CRS_DV (PA7)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;\n HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);\n\n //Configure ETH_RMII_TXD1 (PB13)\n GPIO_InitStructure.Pin = GPIO_PIN_13;\n HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);\n\n //Configure ETH_MDC (PC1), ETH_RMII_RXD0 (PC4) and ETH_RMII_RXD1 (PC5)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;\n HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);\n\n //Configure RMII_TX_EN (PG11) and ETH_RMII_TXD0 (PG13)\n GPIO_InitStructure.Pin = GPIO_PIN_11 | GPIO_PIN_13;\n HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);\n#endif\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 2362, "func": "void stm32h7xxEthInitGpio(NetInterface *interface)\n{\n GPIO_InitTypeDef GPIO_InitStructure;\n\n//STM32F743I-EVAL, STM32F747I-EVAL or STM32H747I-Discovery evaluation board?\n#if defined(USE_STM32H743I_EVAL) || defined(USE_STM32H747I_EVAL) || \\\n defined(USE_STM32H747I_DISCO)\n //Enable SYSCFG clock\n __HAL_RCC_SYSCFG_CLK_ENABLE();\n\n //Enable GPIO clocks\n __HAL_RCC_GPIOA_CLK_ENABLE();\n __HAL_RCC_GPIOC_CLK_ENABLE();\n __HAL_RCC_GPIOG_CLK_ENABLE();\n\n //Select RMII interface mode\n HAL_SYSCFG_ETHInterfaceSelect(SYSCFG_ETH_RMII);\n\n //Configure RMII pins\n GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;\n GPIO_InitStructure.Pull = GPIO_NOPULL;\n GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\n GPIO_InitStructure.Alternate = GPIO_AF11_ETH;\n\n //Configure ETH_RMII_REF_CLK (PA1), ETH_MDIO (PA2) and ETH_RMII_CRS_DV (PA7)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;\n HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);\n\n //Configure ETH_MDC (PC1), ETH_RMII_RXD0 (PC4) and ETH_RMII_RXD1 (PC5)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;\n HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);\n\n //Configure RMII_TX_EN (PG11), ETH_RMII_TXD1 (PG12) and ETH_RMII_TXD0 (PG13)\n GPIO_InitStructure.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;\n HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);\n\n//STM32H735G-DK evaluation board?\n#elif defined(USE_STM32H735G_DK)\n //Enable SYSCFG clock\n __HAL_RCC_SYSCFG_CLK_ENABLE();\n\n //Enable GPIO clocks\n __HAL_RCC_GPIOA_CLK_ENABLE();\n __HAL_RCC_GPIOB_CLK_ENABLE();\n __HAL_RCC_GPIOC_CLK_ENABLE();\n\n //Select RMII interface mode\n HAL_SYSCFG_ETHInterfaceSelect(SYSCFG_ETH_RMII);\n\n //Configure RMII pins\n GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;\n GPIO_InitStructure.Pull = GPIO_NOPULL;\n GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\n GPIO_InitStructure.Alternate = GPIO_AF11_ETH;\n\n //Configure ETH_RMII_REF_CLK (PA1), ETH_MDIO (PA2) and ETH_RMII_CRS_DV (PA7)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;\n HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);\n\n //Configure RMII_RX_ER (PB10), RMII_TX_EN (PB11), ETH_RMII_TXD1 (PB12)\n //and ETH_RMII_TXD0 (PB13)\n GPIO_InitStructure.Pin = GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;\n HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);\n\n //Configure ETH_MDC (PC1), ETH_RMII_RXD0 (PC4) and ETH_RMII_RXD1 (PC5)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;\n HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);\n\n//STM32H745I-Discovery or STM32H750B-DK evaluation board?\n#elif defined(USE_STM32H745I_DISCO) || defined(USE_STM32H750B_DISCO)\n //Enable SYSCFG clock\n __HAL_RCC_SYSCFG_CLK_ENABLE();\n\n //Enable GPIO clocks\n __HAL_RCC_GPIOA_CLK_ENABLE();\n __HAL_RCC_GPIOB_CLK_ENABLE();\n __HAL_RCC_GPIOC_CLK_ENABLE();\n __HAL_RCC_GPIOE_CLK_ENABLE();\n __HAL_RCC_GPIOG_CLK_ENABLE();\n __HAL_RCC_GPIOH_CLK_ENABLE();\n __HAL_RCC_GPIOI_CLK_ENABLE();\n\n //Select MII interface mode\n HAL_SYSCFG_ETHInterfaceSelect(SYSCFG_ETH_MII);\n\n //Configure MII pins\n GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;\n GPIO_InitStructure.Pull = GPIO_NOPULL;\n GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\n GPIO_InitStructure.Alternate = GPIO_AF11_ETH;\n\n //Configure ETH_MII_RX_CLK (PA1), ETH_MDIO (PA2) and ETH_MII_RX_DV (PA7)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;\n HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);\n\n //Configure ETH_MII_RXD2 (PB0), ETH_MII_RXD3 (PB1) and ETH_MII_RX_ER (PB2)\n GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2;\n HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);\n\n //Configure ETH_MDC (PC1), ETH_MII_TXD2 (PC2), ETH_MII_TX_CLK (PC3),\n //ETH_MII_RXD0 (PC4) and ETH_MII_RXD1 (PC5)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5;\n HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);\n\n //Configure ETH_MII_TXD3 (PE2)\n GPIO_InitStructure.Pin = GPIO_PIN_2;\n HAL_GPIO_Init(GPIOE, &GPIO_InitStructure);\n\n //Configure ETH_MII_TX_EN (PG11), ETH_MII_TXD1 (PG12) and ETH_MII_TXD0 (PG13)\n GPIO_InitStructure.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;\n HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);\n\n //Configure ETH_MII_CRS (PH2) and ETH_MII_COL (PH3)\n //GPIO_InitStructure.Pin = GPIO_PIN_2 | GPIO_PIN_3;\n //HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);\n\n //Configure ETH_MII_RX_ER (PI10)\n GPIO_InitStructure.Pin = GPIO_PIN_10;\n HAL_GPIO_Init(GPIOI, &GPIO_InitStructure);\n\n//Nucleo-H723ZG, Nucleo-H743ZI, Nucleo-H743ZI2 or Nucleo-H745ZI-Q evaluation\n//board?\n#elif defined(USE_NUCLEO_H723ZG) || defined(USE_NUCLEO_H743ZI) || \\\n defined(USE_NUCLEO_H743ZI2) || defined(USE_NUCLEO_H745ZI_Q)\n //Enable SYSCFG clock\n __HAL_RCC_SYSCFG_CLK_ENABLE();\n\n //Enable GPIO clocks\n __HAL_RCC_GPIOA_CLK_ENABLE();\n __HAL_RCC_GPIOB_CLK_ENABLE();\n __HAL_RCC_GPIOC_CLK_ENABLE();\n __HAL_RCC_GPIOG_CLK_ENABLE();\n\n //Select RMII interface mode\n HAL_SYSCFG_ETHInterfaceSelect(SYSCFG_ETH_RMII);\n\n //Configure RMII pins\n GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;\n GPIO_InitStructure.Pull = GPIO_NOPULL;\n GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;\n GPIO_InitStructure.Alternate = GPIO_AF11_ETH;\n\n //Configure ETH_RMII_REF_CLK (PA1), ETH_MDIO (PA2) and ETH_RMII_CRS_DV (PA7)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;\n HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);\n\n //Configure ETH_RMII_TXD1 (PB13)\n GPIO_InitStructure.Pin = GPIO_PIN_13;\n HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);\n\n //Configure ETH_MDC (PC1), ETH_RMII_RXD0 (PC4) and ETH_RMII_RXD1 (PC5)\n GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;\n HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);\n\n //Configure RMII_TX_EN (PG11) and ETH_RMII_TXD0 (PG13)\n GPIO_InitStructure.Pin = GPIO_PIN_11 | GPIO_PIN_13;\n HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);\n#endif\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 3218, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const auto* params =\n reinterpret_cast(node->builtin_data);\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n const TfLiteTensor* positions = GetInput(context, node, kInputPositions);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n if (positions->type == kTfLiteInt32) {\n switch (input->type) {\n case kTfLiteFloat32:\n return Gather(*params, input, positions, output);\n case kTfLiteUInt8:\n return Gather(*params, input, positions, output);\n case kTfLiteInt8:\n return Gather(*params, input, positions, output);\n case kTfLiteInt16:\n return Gather(*params, input, positions, output);\n case kTfLiteInt32:\n return Gather(*params, input, positions, output);\n case kTfLiteInt64:\n return Gather(*params, input, positions, output);\n case kTfLiteBool:\n return Gather(*params, input, positions, output);\n case kTfLiteString:\n return GatherStrings(context, input, positions, output);\n default:\n context->ReportError(context, \"Type '%s' is not supported by gather.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n }\n if (positions->type == kTfLiteInt64) {\n switch (input->type) {\n case kTfLiteFloat32:\n return Gather(*params, input, positions, output);\n case kTfLiteUInt8:\n return Gather(*params, input, positions, output);\n case kTfLiteInt8:\n return Gather(*params, input, positions, output);\n case kTfLiteInt16:\n return Gather(*params, input, positions, output);\n case kTfLiteInt32:\n return Gather(*params, input, positions, output);\n case kTfLiteInt64:\n return Gather(*params, input, positions, output);\n case kTfLiteBool:\n return Gather(*params, input, positions, output);\n case kTfLiteString:\n return GatherStrings(context, input, positions, output);\n default:\n context->ReportError(context, \"Type '%s' is not supported by gather.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n }\n context->ReportError(context,\n \"Positions of type '%s' are not supported by gather.\",\n TfLiteTypeGetName(positions->type));\n return kTfLiteError;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3218, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const auto* params =\n reinterpret_cast(node->builtin_data);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n const TfLiteTensor* positions;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputPositions, &positions));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n if (positions->type == kTfLiteInt32) {\n switch (input->type) {\n case kTfLiteFloat32:\n return Gather(*params, input, positions, output);\n case kTfLiteUInt8:\n return Gather(*params, input, positions, output);\n case kTfLiteInt8:\n return Gather(*params, input, positions, output);\n case kTfLiteInt16:\n return Gather(*params, input, positions, output);\n case kTfLiteInt32:\n return Gather(*params, input, positions, output);\n case kTfLiteInt64:\n return Gather(*params, input, positions, output);\n case kTfLiteBool:\n return Gather(*params, input, positions, output);\n case kTfLiteString:\n return GatherStrings(context, input, positions, output);\n default:\n context->ReportError(context, \"Type '%s' is not supported by gather.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n }\n if (positions->type == kTfLiteInt64) {\n switch (input->type) {\n case kTfLiteFloat32:\n return Gather(*params, input, positions, output);\n case kTfLiteUInt8:\n return Gather(*params, input, positions, output);\n case kTfLiteInt8:\n return Gather(*params, input, positions, output);\n case kTfLiteInt16:\n return Gather(*params, input, positions, output);\n case kTfLiteInt32:\n return Gather(*params, input, positions, output);\n case kTfLiteInt64:\n return Gather(*params, input, positions, output);\n case kTfLiteBool:\n return Gather(*params, input, positions, output);\n case kTfLiteString:\n return GatherStrings(context, input, positions, output);\n default:\n context->ReportError(context, \"Type '%s' is not supported by gather.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n }\n context->ReportError(context,\n \"Positions of type '%s' are not supported by gather.\",\n TfLiteTypeGetName(positions->type));\n return kTfLiteError;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 424, "func": "static int http_receive_data(HTTPContext *c)\n{\n HTTPContext *c1;\n int len, loop_run = 0;\n\n while (c->chunked_encoding && !c->chunk_size &&\n c->buffer_end > c->buffer_ptr) {\n /* read chunk header, if present */\n len = recv(c->fd, c->buffer_ptr, 1, 0);\n\n if (len < 0) {\n if (ff_neterrno() != AVERROR(EAGAIN) &&\n ff_neterrno() != AVERROR(EINTR))\n /* error : close connection */\n goto fail;\n return 0;\n } else if (len == 0) {\n /* end of connection : close it */\n goto fail;\n } else if (c->buffer_ptr - c->buffer >= 2 &&\n !memcmp(c->buffer_ptr - 1, \"\\r\\n\", 2)) {\n c->chunk_size = strtol(c->buffer, 0, 16);\n if (c->chunk_size == 0) // end of stream\n goto fail;\n c->buffer_ptr = c->buffer;\n break;\n } else if (++loop_run > 10)\n /* no chunk header, abort */\n goto fail;\n else\n c->buffer_ptr++;\n }\n\n if (c->buffer_end > c->buffer_ptr) {\n len = recv(c->fd, c->buffer_ptr,\n FFMIN(c->chunk_size, c->buffer_end - c->buffer_ptr), 0);\n if (len < 0) {\n if (ff_neterrno() != AVERROR(EAGAIN) &&\n ff_neterrno() != AVERROR(EINTR))\n /* error : close connection */\n goto fail;\n } else if (len == 0)\n /* end of connection : close it */\n goto fail;\n else {\n c->chunk_size -= len;\n c->buffer_ptr += len;\n c->data_count += len;\n update_datarate(&c->datarate, c->data_count);\n }\n }\n\n if (c->buffer_ptr - c->buffer >= 2 && c->data_count > FFM_PACKET_SIZE) {\n if (c->buffer[0] != 'f' ||\n c->buffer[1] != 'm') {\n http_log(\"Feed stream has become desynchronized -- disconnecting\\n\");\n goto fail;\n }\n }\n\n if (c->buffer_ptr >= c->buffer_end) {\n FFServerStream *feed = c->stream;\n /* a packet has been received : write it in the store, except\n * if header */\n if (c->data_count > FFM_PACKET_SIZE) {\n /* XXX: use llseek or url_seek\n * XXX: Should probably fail? */\n if (lseek(c->feed_fd, feed->feed_write_index, SEEK_SET) == -1)\n http_log(\"Seek to %\"PRId64\" failed\\n\", feed->feed_write_index);\n\n if (write(c->feed_fd, c->buffer, FFM_PACKET_SIZE) < 0) {\n http_log(\"Error writing to feed file: %s\\n\", strerror(errno));\n goto fail;\n }\n\n feed->feed_write_index += FFM_PACKET_SIZE;\n /* update file size */\n if (feed->feed_write_index > c->stream->feed_size)\n feed->feed_size = feed->feed_write_index;\n\n /* handle wrap around if max file size reached */\n if (c->stream->feed_max_size &&\n feed->feed_write_index >= c->stream->feed_max_size)\n feed->feed_write_index = FFM_PACKET_SIZE;\n\n /* write index */\n if (ffm_write_write_index(c->feed_fd, feed->feed_write_index) < 0) {\n http_log(\"Error writing index to feed file: %s\\n\",\n strerror(errno));\n goto fail;\n }\n\n /* wake up any waiting connections */\n for(c1 = first_http_ctx; c1; c1 = c1->next) {\n if (c1->state == HTTPSTATE_WAIT_FEED &&\n c1->stream->feed == c->stream->feed)\n c1->state = HTTPSTATE_SEND_DATA;\n }\n } else {\n /* We have a header in our hands that contains useful data */\n AVFormatContext *s = avformat_alloc_context();\n AVIOContext *pb;\n AVInputFormat *fmt_in;\n int i;\n\n if (!s)\n goto fail;\n\n /* use feed output format name to find corresponding input format */\n fmt_in = av_find_input_format(feed->fmt->name);\n if (!fmt_in)\n goto fail;\n\n pb = avio_alloc_context(c->buffer, c->buffer_end - c->buffer,\n 0, NULL, NULL, NULL, NULL);\n if (!pb)\n goto fail;\n\n pb->seekable = 0;\n\n s->pb = pb;\n if (avformat_open_input(&s, c->stream->feed_filename, fmt_in, NULL) < 0) {\n av_freep(&pb);\n goto fail;\n }\n\n /* Now we have the actual streams */\n if (s->nb_streams != feed->nb_streams) {\n avformat_close_input(&s);\n av_freep(&pb);\n http_log(\"Feed '%s' stream number does not match registered feed\\n\",\n c->stream->feed_filename);\n goto fail;\n }\n\n for (i = 0; i < s->nb_streams; i++) {\n LayeredAVStream *fst = feed->streams[i];\n AVStream *st = s->streams[i];\n avcodec_parameters_to_context(fst->codec, st->codecpar);\n avcodec_parameters_from_context(fst->codecpar, fst->codec);\n }\n\n avformat_close_input(&s);\n av_freep(&pb);\n }\n c->buffer_ptr = c->buffer;\n }\n\n return 0;\n fail:\n c->stream->feed_opened = 0;\n close(c->feed_fd);\n /* wake up any waiting connections to stop waiting for feed */\n for(c1 = first_http_ctx; c1; c1 = c1->next) {\n if (c1->state == HTTPSTATE_WAIT_FEED &&\n c1->stream->feed == c->stream->feed)\n c1->state = HTTPSTATE_SEND_DATA_TRAILER;\n }\n return -1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10192", "cwe_id": "CWE-119" }, { "id": 424, "func": "static int http_receive_data(HTTPContext *c)\n{\n HTTPContext *c1;\n int len, loop_run = 0;\n\n while (c->chunked_encoding && !c->chunk_size &&\n c->buffer_end > c->buffer_ptr) {\n /* read chunk header, if present */\n len = recv(c->fd, c->buffer_ptr, 1, 0);\n\n if (len < 0) {\n if (ff_neterrno() != AVERROR(EAGAIN) &&\n ff_neterrno() != AVERROR(EINTR))\n /* error : close connection */\n goto fail;\n return 0;\n } else if (len == 0) {\n /* end of connection : close it */\n goto fail;\n } else if (c->buffer_ptr - c->buffer >= 2 &&\n !memcmp(c->buffer_ptr - 1, \"\\r\\n\", 2)) {\n c->chunk_size = strtol(c->buffer, 0, 16);\n if (c->chunk_size <= 0) { // end of stream or invalid chunk size\n c->chunk_size = 0;\n goto fail;\n }\n c->buffer_ptr = c->buffer;\n break;\n } else if (++loop_run > 10)\n /* no chunk header, abort */\n goto fail;\n else\n c->buffer_ptr++;\n }\n\n if (c->buffer_end > c->buffer_ptr) {\n len = recv(c->fd, c->buffer_ptr,\n FFMIN(c->chunk_size, c->buffer_end - c->buffer_ptr), 0);\n if (len < 0) {\n if (ff_neterrno() != AVERROR(EAGAIN) &&\n ff_neterrno() != AVERROR(EINTR))\n /* error : close connection */\n goto fail;\n } else if (len == 0)\n /* end of connection : close it */\n goto fail;\n else {\n av_assert0(len <= c->chunk_size);\n c->chunk_size -= len;\n c->buffer_ptr += len;\n c->data_count += len;\n update_datarate(&c->datarate, c->data_count);\n }\n }\n\n if (c->buffer_ptr - c->buffer >= 2 && c->data_count > FFM_PACKET_SIZE) {\n if (c->buffer[0] != 'f' ||\n c->buffer[1] != 'm') {\n http_log(\"Feed stream has become desynchronized -- disconnecting\\n\");\n goto fail;\n }\n }\n\n if (c->buffer_ptr >= c->buffer_end) {\n FFServerStream *feed = c->stream;\n /* a packet has been received : write it in the store, except\n * if header */\n if (c->data_count > FFM_PACKET_SIZE) {\n /* XXX: use llseek or url_seek\n * XXX: Should probably fail? */\n if (lseek(c->feed_fd, feed->feed_write_index, SEEK_SET) == -1)\n http_log(\"Seek to %\"PRId64\" failed\\n\", feed->feed_write_index);\n\n if (write(c->feed_fd, c->buffer, FFM_PACKET_SIZE) < 0) {\n http_log(\"Error writing to feed file: %s\\n\", strerror(errno));\n goto fail;\n }\n\n feed->feed_write_index += FFM_PACKET_SIZE;\n /* update file size */\n if (feed->feed_write_index > c->stream->feed_size)\n feed->feed_size = feed->feed_write_index;\n\n /* handle wrap around if max file size reached */\n if (c->stream->feed_max_size &&\n feed->feed_write_index >= c->stream->feed_max_size)\n feed->feed_write_index = FFM_PACKET_SIZE;\n\n /* write index */\n if (ffm_write_write_index(c->feed_fd, feed->feed_write_index) < 0) {\n http_log(\"Error writing index to feed file: %s\\n\",\n strerror(errno));\n goto fail;\n }\n\n /* wake up any waiting connections */\n for(c1 = first_http_ctx; c1; c1 = c1->next) {\n if (c1->state == HTTPSTATE_WAIT_FEED &&\n c1->stream->feed == c->stream->feed)\n c1->state = HTTPSTATE_SEND_DATA;\n }\n } else {\n /* We have a header in our hands that contains useful data */\n AVFormatContext *s = avformat_alloc_context();\n AVIOContext *pb;\n AVInputFormat *fmt_in;\n int i;\n\n if (!s)\n goto fail;\n\n /* use feed output format name to find corresponding input format */\n fmt_in = av_find_input_format(feed->fmt->name);\n if (!fmt_in)\n goto fail;\n\n pb = avio_alloc_context(c->buffer, c->buffer_end - c->buffer,\n 0, NULL, NULL, NULL, NULL);\n if (!pb)\n goto fail;\n\n pb->seekable = 0;\n\n s->pb = pb;\n if (avformat_open_input(&s, c->stream->feed_filename, fmt_in, NULL) < 0) {\n av_freep(&pb);\n goto fail;\n }\n\n /* Now we have the actual streams */\n if (s->nb_streams != feed->nb_streams) {\n avformat_close_input(&s);\n av_freep(&pb);\n http_log(\"Feed '%s' stream number does not match registered feed\\n\",\n c->stream->feed_filename);\n goto fail;\n }\n\n for (i = 0; i < s->nb_streams; i++) {\n LayeredAVStream *fst = feed->streams[i];\n AVStream *st = s->streams[i];\n avcodec_parameters_to_context(fst->codec, st->codecpar);\n avcodec_parameters_from_context(fst->codecpar, fst->codec);\n }\n\n avformat_close_input(&s);\n av_freep(&pb);\n }\n c->buffer_ptr = c->buffer;\n }\n\n return 0;\n fail:\n c->stream->feed_opened = 0;\n close(c->feed_fd);\n /* wake up any waiting connections to stop waiting for feed */\n for(c1 = first_http_ctx; c1; c1 = c1->next) {\n if (c1->state == HTTPSTATE_WAIT_FEED &&\n c1->stream->feed == c->stream->feed)\n c1->state = HTTPSTATE_SEND_DATA_TRAILER;\n }\n return -1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10192", "cwe_id": "CWE-119" }, { "id": 1214, "func": "show_tree(tree_t *t, /* I - Parent node */\n int indent) /* I - Indentation */\n{\n while (t)\n {\n if (t->markup == MARKUP_NONE)\n printf(\"%*s\\\"%s\\\"\\n\", indent, \"\", t->data);\n else\n printf(\"%*s%s\\n\", indent, \"\", _htmlMarkups[t->markup]);\n\n if (t->child)\n show_tree(t->child, indent + 2);\n\n t = t->next;\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-34033", "cwe_id": "CWE-787" }, { "id": 1214, "func": "show_tree(tree_t *t, /* I - Parent node */\n int indent) /* I - Indentation */\n{\n static const char * const markups[] =\n {\n \"FILE\",\n \"UNKNOWN\",\n \"ERROR\"\n };\n\n while (t)\n {\n if (t->markup == MARKUP_NONE)\n printf(\"%*s\\\"%s\\\"\\n\", indent, \"\", t->data);\n else if (t->markup > MARKUP_NONE)\n printf(\"%*s%s\\n\", indent, \"\", _htmlMarkups[t->markup]);\n else\n printf(\"%*s%s\\n\", indent, \"\", markups[t->markup - MARKUP_FILE]);\n\n if (t->child)\n show_tree(t->child, indent + 2);\n\n t = t->next;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-34033", "cwe_id": "CWE-787" }, { "id": 1292, "func": "int CIFSFindNext(const int xid, struct cifs_tcon *tcon,\n\t\t __u16 searchHandle, struct cifs_search_info *psrch_inf)\n{\n\tTRANSACTION2_FNEXT_REQ *pSMB = NULL;\n\tTRANSACTION2_FNEXT_RSP *pSMBr = NULL;\n\tT2_FNEXT_RSP_PARMS *parms;\n\tchar *response_data;\n\tint rc = 0;\n\tint bytes_returned, name_len;\n\t__u16 params, byte_count;\n\n\tcFYI(1, \"In FindNext\");\n\n\tif (psrch_inf->endOfSearch)\n\t\treturn -ENOENT;\n\n\trc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,\n\t\t(void **) &pSMBr);\n\tif (rc)\n\t\treturn rc;\n\n\tparams = 14; /* includes 2 bytes of null string, converted to LE below*/\n\tbyte_count = 0;\n\tpSMB->TotalDataCount = 0; /* no EAs */\n\tpSMB->MaxParameterCount = cpu_to_le16(8);\n\tpSMB->MaxDataCount =\n\t\tcpu_to_le16((tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) &\n\t\t\t\t0xFFFFFF00);\n\tpSMB->MaxSetupCount = 0;\n\tpSMB->Reserved = 0;\n\tpSMB->Flags = 0;\n\tpSMB->Timeout = 0;\n\tpSMB->Reserved2 = 0;\n\tpSMB->ParameterOffset = cpu_to_le16(\n\t offsetof(struct smb_com_transaction2_fnext_req,SearchHandle) - 4);\n\tpSMB->DataCount = 0;\n\tpSMB->DataOffset = 0;\n\tpSMB->SetupCount = 1;\n\tpSMB->Reserved3 = 0;\n\tpSMB->SubCommand = cpu_to_le16(TRANS2_FIND_NEXT);\n\tpSMB->SearchHandle = searchHandle; /* always kept as le */\n\tpSMB->SearchCount =\n\t\tcpu_to_le16(CIFSMaxBufSize / sizeof(FILE_UNIX_INFO));\n\tpSMB->InformationLevel = cpu_to_le16(psrch_inf->info_level);\n\tpSMB->ResumeKey = psrch_inf->resume_key;\n\tpSMB->SearchFlags =\n\t cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME);\n\n\tname_len = psrch_inf->resume_name_len;\n\tparams += name_len;\n\tif (name_len < PATH_MAX) {\n\t\tmemcpy(pSMB->ResumeFileName, psrch_inf->presume_name, name_len);\n\t\tbyte_count += name_len;\n\t\t/* 14 byte parm len above enough for 2 byte null terminator */\n\t\tpSMB->ResumeFileName[name_len] = 0;\n\t\tpSMB->ResumeFileName[name_len+1] = 0;\n\t} else {\n\t\trc = -EINVAL;\n\t\tgoto FNext2_err_exit;\n\t}\n\tbyte_count = params + 1 /* pad */ ;\n\tpSMB->TotalParameterCount = cpu_to_le16(params);\n\tpSMB->ParameterCount = pSMB->TotalParameterCount;\n\tinc_rfc1001_len(pSMB, byte_count);\n\tpSMB->ByteCount = cpu_to_le16(byte_count);\n\n\trc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,\n\t\t\t(struct smb_hdr *) pSMBr, &bytes_returned, 0);\n\tcifs_stats_inc(&tcon->num_fnext);\n\tif (rc) {\n\t\tif (rc == -EBADF) {\n\t\t\tpsrch_inf->endOfSearch = true;\n\t\t\tcifs_buf_release(pSMB);\n\t\t\trc = 0; /* search probably was closed at end of search*/\n\t\t} else\n\t\t\tcFYI(1, \"FindNext returned = %d\", rc);\n\t} else { /* decode response */\n\t\trc = validate_t2((struct smb_t2_rsp *)pSMBr);\n\n\t\tif (rc == 0) {\n\t\t\tunsigned int lnoff;\n\n\t\t\t/* BB fixme add lock for file (srch_info) struct here */\n\t\t\tif (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)\n\t\t\t\tpsrch_inf->unicode = true;\n\t\t\telse\n\t\t\t\tpsrch_inf->unicode = false;\n\t\t\tresponse_data = (char *) &pSMBr->hdr.Protocol +\n\t\t\t le16_to_cpu(pSMBr->t2.ParameterOffset);\n\t\t\tparms = (T2_FNEXT_RSP_PARMS *)response_data;\n\t\t\tresponse_data = (char *)&pSMBr->hdr.Protocol +\n\t\t\t\tle16_to_cpu(pSMBr->t2.DataOffset);\n\t\t\tif (psrch_inf->smallBuf)\n\t\t\t\tcifs_small_buf_release(\n\t\t\t\t\tpsrch_inf->ntwrk_buf_start);\n\t\t\telse\n\t\t\t\tcifs_buf_release(psrch_inf->ntwrk_buf_start);\n\t\t\tpsrch_inf->srch_entries_start = response_data;\n\t\t\tpsrch_inf->ntwrk_buf_start = (char *)pSMB;\n\t\t\tpsrch_inf->smallBuf = 0;\n\t\t\tif (parms->EndofSearch)\n\t\t\t\tpsrch_inf->endOfSearch = true;\n\t\t\telse\n\t\t\t\tpsrch_inf->endOfSearch = false;\n\t\t\tpsrch_inf->entries_in_buffer =\n\t\t\t\t\t\tle16_to_cpu(parms->SearchCount);\n\t\t\tpsrch_inf->index_of_last_entry +=\n\t\t\t\tpsrch_inf->entries_in_buffer;\n\t\t\tlnoff = le16_to_cpu(parms->LastNameOffset);\n\t\t\tif (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE <\n\t\t\t lnoff) {\n\t\t\t\tcERROR(1, \"ignoring corrupt resume name\");\n\t\t\t\tpsrch_inf->last_entry = NULL;\n\t\t\t\treturn rc;\n\t\t\t} else\n\t\t\t\tpsrch_inf->last_entry =\n\t\t\t\t\tpsrch_inf->srch_entries_start + lnoff;\n\n/* cFYI(1, \"fnxt2 entries in buf %d index_of_last %d\",\n\t psrch_inf->entries_in_buffer, psrch_inf->index_of_last_entry); */\n\n\t\t\t/* BB fixme add unlock here */\n\t\t}\n\n\t}\n\n\t/* BB On error, should we leave previous search buf (and count and\n\tlast entry fields) intact or free the previous one? */\n\n\t/* Note: On -EAGAIN error only caller can retry on handle based calls\n\tsince file handle passed in no longer valid */\nFNext2_err_exit:\n\tif (rc != 0)\n\t\tcifs_buf_release(pSMB);\n\treturn rc;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-3191", "cwe_id": "CWE-119" }, { "id": 1292, "func": "int CIFSFindNext(const int xid, struct cifs_tcon *tcon,\n\t\t __u16 searchHandle, struct cifs_search_info *psrch_inf)\n{\n\tTRANSACTION2_FNEXT_REQ *pSMB = NULL;\n\tTRANSACTION2_FNEXT_RSP *pSMBr = NULL;\n\tT2_FNEXT_RSP_PARMS *parms;\n\tchar *response_data;\n\tint rc = 0;\n\tint bytes_returned;\n\tunsigned int name_len;\n\t__u16 params, byte_count;\n\n\tcFYI(1, \"In FindNext\");\n\n\tif (psrch_inf->endOfSearch)\n\t\treturn -ENOENT;\n\n\trc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,\n\t\t(void **) &pSMBr);\n\tif (rc)\n\t\treturn rc;\n\n\tparams = 14; /* includes 2 bytes of null string, converted to LE below*/\n\tbyte_count = 0;\n\tpSMB->TotalDataCount = 0; /* no EAs */\n\tpSMB->MaxParameterCount = cpu_to_le16(8);\n\tpSMB->MaxDataCount =\n\t\tcpu_to_le16((tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) &\n\t\t\t\t0xFFFFFF00);\n\tpSMB->MaxSetupCount = 0;\n\tpSMB->Reserved = 0;\n\tpSMB->Flags = 0;\n\tpSMB->Timeout = 0;\n\tpSMB->Reserved2 = 0;\n\tpSMB->ParameterOffset = cpu_to_le16(\n\t offsetof(struct smb_com_transaction2_fnext_req,SearchHandle) - 4);\n\tpSMB->DataCount = 0;\n\tpSMB->DataOffset = 0;\n\tpSMB->SetupCount = 1;\n\tpSMB->Reserved3 = 0;\n\tpSMB->SubCommand = cpu_to_le16(TRANS2_FIND_NEXT);\n\tpSMB->SearchHandle = searchHandle; /* always kept as le */\n\tpSMB->SearchCount =\n\t\tcpu_to_le16(CIFSMaxBufSize / sizeof(FILE_UNIX_INFO));\n\tpSMB->InformationLevel = cpu_to_le16(psrch_inf->info_level);\n\tpSMB->ResumeKey = psrch_inf->resume_key;\n\tpSMB->SearchFlags =\n\t cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME);\n\n\tname_len = psrch_inf->resume_name_len;\n\tparams += name_len;\n\tif (name_len < PATH_MAX) {\n\t\tmemcpy(pSMB->ResumeFileName, psrch_inf->presume_name, name_len);\n\t\tbyte_count += name_len;\n\t\t/* 14 byte parm len above enough for 2 byte null terminator */\n\t\tpSMB->ResumeFileName[name_len] = 0;\n\t\tpSMB->ResumeFileName[name_len+1] = 0;\n\t} else {\n\t\trc = -EINVAL;\n\t\tgoto FNext2_err_exit;\n\t}\n\tbyte_count = params + 1 /* pad */ ;\n\tpSMB->TotalParameterCount = cpu_to_le16(params);\n\tpSMB->ParameterCount = pSMB->TotalParameterCount;\n\tinc_rfc1001_len(pSMB, byte_count);\n\tpSMB->ByteCount = cpu_to_le16(byte_count);\n\n\trc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,\n\t\t\t(struct smb_hdr *) pSMBr, &bytes_returned, 0);\n\tcifs_stats_inc(&tcon->num_fnext);\n\tif (rc) {\n\t\tif (rc == -EBADF) {\n\t\t\tpsrch_inf->endOfSearch = true;\n\t\t\tcifs_buf_release(pSMB);\n\t\t\trc = 0; /* search probably was closed at end of search*/\n\t\t} else\n\t\t\tcFYI(1, \"FindNext returned = %d\", rc);\n\t} else { /* decode response */\n\t\trc = validate_t2((struct smb_t2_rsp *)pSMBr);\n\n\t\tif (rc == 0) {\n\t\t\tunsigned int lnoff;\n\n\t\t\t/* BB fixme add lock for file (srch_info) struct here */\n\t\t\tif (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)\n\t\t\t\tpsrch_inf->unicode = true;\n\t\t\telse\n\t\t\t\tpsrch_inf->unicode = false;\n\t\t\tresponse_data = (char *) &pSMBr->hdr.Protocol +\n\t\t\t le16_to_cpu(pSMBr->t2.ParameterOffset);\n\t\t\tparms = (T2_FNEXT_RSP_PARMS *)response_data;\n\t\t\tresponse_data = (char *)&pSMBr->hdr.Protocol +\n\t\t\t\tle16_to_cpu(pSMBr->t2.DataOffset);\n\t\t\tif (psrch_inf->smallBuf)\n\t\t\t\tcifs_small_buf_release(\n\t\t\t\t\tpsrch_inf->ntwrk_buf_start);\n\t\t\telse\n\t\t\t\tcifs_buf_release(psrch_inf->ntwrk_buf_start);\n\t\t\tpsrch_inf->srch_entries_start = response_data;\n\t\t\tpsrch_inf->ntwrk_buf_start = (char *)pSMB;\n\t\t\tpsrch_inf->smallBuf = 0;\n\t\t\tif (parms->EndofSearch)\n\t\t\t\tpsrch_inf->endOfSearch = true;\n\t\t\telse\n\t\t\t\tpsrch_inf->endOfSearch = false;\n\t\t\tpsrch_inf->entries_in_buffer =\n\t\t\t\t\t\tle16_to_cpu(parms->SearchCount);\n\t\t\tpsrch_inf->index_of_last_entry +=\n\t\t\t\tpsrch_inf->entries_in_buffer;\n\t\t\tlnoff = le16_to_cpu(parms->LastNameOffset);\n\t\t\tif (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE <\n\t\t\t lnoff) {\n\t\t\t\tcERROR(1, \"ignoring corrupt resume name\");\n\t\t\t\tpsrch_inf->last_entry = NULL;\n\t\t\t\treturn rc;\n\t\t\t} else\n\t\t\t\tpsrch_inf->last_entry =\n\t\t\t\t\tpsrch_inf->srch_entries_start + lnoff;\n\n/* cFYI(1, \"fnxt2 entries in buf %d index_of_last %d\",\n\t psrch_inf->entries_in_buffer, psrch_inf->index_of_last_entry); */\n\n\t\t\t/* BB fixme add unlock here */\n\t\t}\n\n\t}\n\n\t/* BB On error, should we leave previous search buf (and count and\n\tlast entry fields) intact or free the previous one? */\n\n\t/* Note: On -EAGAIN error only caller can retry on handle based calls\n\tsince file handle passed in no longer valid */\nFNext2_err_exit:\n\tif (rc != 0)\n\t\tcifs_buf_release(pSMB);\n\treturn rc;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-3191", "cwe_id": "CWE-119" }, { "id": 301, "func": "TfLiteRegistration GetPassthroughOpRegistration() {\n TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr};\n reg.init = [](TfLiteContext* context, const char*, size_t) -> void* {\n auto* first_new_tensor = new int;\n context->AddTensors(context, 2, first_new_tensor);\n return first_new_tensor;\n };\n reg.free = [](TfLiteContext* context, void* buffer) {\n delete static_cast(buffer);\n };\n reg.prepare = [](TfLiteContext* context, TfLiteNode* node) {\n auto* first_new_tensor = static_cast(node->user_data);\n\n const TfLiteTensor* tensor0 = GetInput(context, node, 0);\n TfLiteTensor* tensor1 = GetOutput(context, node, 0);\n\n TfLiteIntArray* newSize = TfLiteIntArrayCopy(tensor0->dims);\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, tensor1, newSize));\n\n TfLiteIntArrayFree(node->temporaries);\n node->temporaries = TfLiteIntArrayCreate(2);\n for (int i = 0; i < 2; ++i) {\n node->temporaries->data[i] = *(first_new_tensor) + i;\n }\n\n auto setup_temporary = [&](int id) {\n TfLiteTensor* tmp = &context->tensors[id];\n tmp->type = kTfLiteFloat32;\n tmp->allocation_type = kTfLiteArenaRw;\n return context->ResizeTensor(context, tmp,\n TfLiteIntArrayCopy(tensor0->dims));\n };\n TF_LITE_ENSURE_STATUS(setup_temporary(node->temporaries->data[0]));\n TF_LITE_ENSURE_STATUS(setup_temporary(node->temporaries->data[1]));\n\n return kTfLiteOk;\n };\n reg.invoke = [](TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* a0 = GetInput(context, node, 0);\n\n auto populate = [&](int id) {\n TfLiteTensor* t = &context->tensors[id];\n int num = a0->dims->data[0];\n for (int i = 0; i < num; i++) {\n t->data.f[i] = a0->data.f[i];\n }\n };\n\n populate(node->outputs->data[0]);\n populate(node->temporaries->data[0]);\n populate(node->temporaries->data[1]);\n return kTfLiteOk;\n };\n\n return reg;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 301, "func": "TfLiteRegistration GetPassthroughOpRegistration() {\n TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr};\n reg.init = [](TfLiteContext* context, const char*, size_t) -> void* {\n auto* first_new_tensor = new int;\n context->AddTensors(context, 2, first_new_tensor);\n return first_new_tensor;\n };\n reg.free = [](TfLiteContext* context, void* buffer) {\n delete static_cast(buffer);\n };\n reg.prepare = [](TfLiteContext* context, TfLiteNode* node) {\n auto* first_new_tensor = static_cast(node->user_data);\n\n const TfLiteTensor* tensor0;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &tensor0));\n TfLiteTensor* tensor1;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &tensor1));\n\n TfLiteIntArray* newSize = TfLiteIntArrayCopy(tensor0->dims);\n TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, tensor1, newSize));\n\n TfLiteIntArrayFree(node->temporaries);\n node->temporaries = TfLiteIntArrayCreate(2);\n for (int i = 0; i < 2; ++i) {\n node->temporaries->data[i] = *(first_new_tensor) + i;\n }\n\n auto setup_temporary = [&](int id) {\n TfLiteTensor* tmp = &context->tensors[id];\n tmp->type = kTfLiteFloat32;\n tmp->allocation_type = kTfLiteArenaRw;\n return context->ResizeTensor(context, tmp,\n TfLiteIntArrayCopy(tensor0->dims));\n };\n TF_LITE_ENSURE_STATUS(setup_temporary(node->temporaries->data[0]));\n TF_LITE_ENSURE_STATUS(setup_temporary(node->temporaries->data[1]));\n\n return kTfLiteOk;\n };\n reg.invoke = [](TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* a0;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &a0));\n\n auto populate = [&](int id) {\n TfLiteTensor* t = &context->tensors[id];\n int num = a0->dims->data[0];\n for (int i = 0; i < num; i++) {\n t->data.f[i] = a0->data.f[i];\n }\n };\n\n populate(node->outputs->data[0]);\n populate(node->temporaries->data[0]);\n populate(node->temporaries->data[1]);\n return kTfLiteOk;\n };\n\n return reg;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2749, "func": " */\nstatic void re_yyensure_buffer_stack (yyscan_t yyscanner)\n{\n\tyy_size_t num_to_alloc;\n struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\tif (!yyg->yy_buffer_stack) {\n\n\t\t/* First allocation is just for 2 elements, since we don't know if this\n\t\t * scanner will even need a stack. We use 2 instead of 1 to avoid an\n\t\t * immediate realloc on the next call.\n */\n\t\tnum_to_alloc = 1; // After all that talk, this was set to 1 anyways...\n\t\tyyg->yy_buffer_stack = (struct yy_buffer_state**)re_yyalloc\n\t\t\t\t\t\t\t\t(num_to_alloc * sizeof(struct yy_buffer_state*)\n\t\t\t\t\t\t\t\t, yyscanner);\n\t\tif ( ! yyg->yy_buffer_stack )\n\t\t\tYY_FATAL_ERROR( \"out of dynamic memory in re_yyensure_buffer_stack()\" );\n\t\t\t\t\t\t\t\t \n\t\tmemset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));\n\t\t\t\t\n\t\tyyg->yy_buffer_stack_max = num_to_alloc;\n\t\tyyg->yy_buffer_stack_top = 0;\n\t\treturn;\n\t}\n\n\tif (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){\n\n\t\t/* Increase the buffer to prepare for a possible push. */\n\t\tyy_size_t grow_size = 8 /* arbitrary grow size */;\n\n\t\tnum_to_alloc = yyg->yy_buffer_stack_max + grow_size;\n\t\tyyg->yy_buffer_stack = (struct yy_buffer_state**)re_yyrealloc\n\t\t\t\t\t\t\t\t(yyg->yy_buffer_stack,\n\t\t\t\t\t\t\t\tnum_to_alloc * sizeof(struct yy_buffer_state*)\n\t\t\t\t\t\t\t\t, yyscanner);\n\t\tif ( ! yyg->yy_buffer_stack )\n\t\t\tYY_FATAL_ERROR( \"out of dynamic memory in re_yyensure_buffer_stack()\" );\n\n\t\t/* zero only the new slots.*/\n\t\tmemset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));\n\t\tyyg->yy_buffer_stack_max = num_to_alloc;\n\t}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10210", "cwe_id": "CWE-476" }, { "id": 2749, "func": " */\nstatic void re_yyensure_buffer_stack (yyscan_t yyscanner)\n{\n\tyy_size_t num_to_alloc;\n struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\tif (!yyg->yy_buffer_stack) {\n\n\t\t/* First allocation is just for 2 elements, since we don't know if this\n\t\t * scanner will even need a stack. We use 2 instead of 1 to avoid an\n\t\t * immediate realloc on the next call.\n */\n\t\tnum_to_alloc = 1; // After all that talk, this was set to 1 anyways...\n\t\tyyg->yy_buffer_stack = (struct yy_buffer_state**)re_yyalloc\n\t\t\t\t\t\t\t\t(num_to_alloc * sizeof(struct yy_buffer_state*)\n\t\t\t\t\t\t\t\t, yyscanner);\n\t\tif ( ! yyg->yy_buffer_stack )\n\t\t\tYY_FATAL_ERROR( \"out of dynamic memory in re_yyensure_buffer_stack()\" );\n\n\t\tmemset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));\n\n\t\tyyg->yy_buffer_stack_max = num_to_alloc;\n\t\tyyg->yy_buffer_stack_top = 0;\n\t\treturn;\n\t}\n\n\tif (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){\n\n\t\t/* Increase the buffer to prepare for a possible push. */\n\t\tyy_size_t grow_size = 8 /* arbitrary grow size */;\n\n\t\tnum_to_alloc = yyg->yy_buffer_stack_max + grow_size;\n\t\tyyg->yy_buffer_stack = (struct yy_buffer_state**)re_yyrealloc\n\t\t\t\t\t\t\t\t(yyg->yy_buffer_stack,\n\t\t\t\t\t\t\t\tnum_to_alloc * sizeof(struct yy_buffer_state*)\n\t\t\t\t\t\t\t\t, yyscanner);\n\t\tif ( ! yyg->yy_buffer_stack )\n\t\t\tYY_FATAL_ERROR( \"out of dynamic memory in re_yyensure_buffer_stack()\" );\n\n\t\t/* zero only the new slots.*/\n\t\tmemset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));\n\t\tyyg->yy_buffer_stack_max = num_to_alloc;\n\t}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10210", "cwe_id": "CWE-476" }, { "id": 3130, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* dims = GetInput(context, node, kDimsTensor);\n const TfLiteTensor* value = GetInput(context, node, kValueTensor);\n\n // Make sure the 1st input tensor is 1-D.\n TF_LITE_ENSURE_EQ(context, NumDimensions(dims), 1);\n\n // Make sure the 1st input tensor is int32 or int64.\n const auto dtype = dims->type;\n TF_LITE_ENSURE(context, dtype == kTfLiteInt32 || dtype == kTfLiteInt64);\n\n // Make sure the 2nd input tensor is a scalar.\n TF_LITE_ENSURE_EQ(context, NumDimensions(value), 0);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n output->type = value->type;\n\n if (IsConstantTensor(dims)) {\n TF_LITE_ENSURE_OK(context, ResizeOutput(context, dims, output));\n } else {\n SetTensorToDynamic(output);\n }\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3130, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* dims;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kDimsTensor, &dims));\n const TfLiteTensor* value;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kValueTensor, &value));\n\n // Make sure the 1st input tensor is 1-D.\n TF_LITE_ENSURE_EQ(context, NumDimensions(dims), 1);\n\n // Make sure the 1st input tensor is int32 or int64.\n const auto dtype = dims->type;\n TF_LITE_ENSURE(context, dtype == kTfLiteInt32 || dtype == kTfLiteInt64);\n\n // Make sure the 2nd input tensor is a scalar.\n TF_LITE_ENSURE_EQ(context, NumDimensions(value), 0);\n\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n output->type = value->type;\n\n if (IsConstantTensor(dims)) {\n TF_LITE_ENSURE_OK(context, ResizeOutput(context, dims, output));\n } else {\n SetTensorToDynamic(output);\n }\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 730, "func": "PHP_FUNCTION(unserialize)\n{\n\tchar *buf = NULL;\n\tsize_t buf_len;\n\tconst unsigned char *p;\n\tphp_unserialize_data_t var_hash;\n\tzval *options = NULL, *classes = NULL;\n\tHashTable *class_hash = NULL;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"s|a\", &buf, &buf_len, &options) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (buf_len == 0) {\n\t\tRETURN_FALSE;\n\t}\n\n\tp = (const unsigned char*) buf;\n\tPHP_VAR_UNSERIALIZE_INIT(var_hash);\n\tif(options != NULL) {\n\t\tclasses = zend_hash_str_find(Z_ARRVAL_P(options), \"allowed_classes\", sizeof(\"allowed_classes\")-1);\n\t\tif(classes && (Z_TYPE_P(classes) == IS_ARRAY || !zend_is_true(classes))) {\n\t\t\tALLOC_HASHTABLE(class_hash);\n\t\t\tzend_hash_init(class_hash, (Z_TYPE_P(classes) == IS_ARRAY)?zend_hash_num_elements(Z_ARRVAL_P(classes)):0, NULL, NULL, 0);\n\t\t}\n\t\tif(class_hash && Z_TYPE_P(classes) == IS_ARRAY) {\n\t\t\tzval *entry;\n\t\t\tzend_string *lcname;\n\n\t\t\tZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(classes), entry) {\n\t\t\t\tconvert_to_string_ex(entry);\n\t\t\t\tlcname = zend_string_tolower(Z_STR_P(entry));\n\t\t\t\tzend_hash_add_empty_element(class_hash, lcname);\n\t\t zend_string_release(lcname);\n\t\t\t} ZEND_HASH_FOREACH_END();\n\t\t}\n\t}\n\n\tif (!php_var_unserialize_ex(return_value, &p, p + buf_len, &var_hash, class_hash)) {\n\t\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\t\tif (class_hash) {\n\t\t\tzend_hash_destroy(class_hash);\n\t\t\tFREE_HASHTABLE(class_hash);\n\t\t}\n\t\tzval_ptr_dtor(return_value);\n\t\tif (!EG(exception)) {\n\t\t\tphp_error_docref(NULL, E_NOTICE, \"Error at offset \" ZEND_LONG_FMT \" of %zd bytes\",\n\t\t\t\t(zend_long)((char*)p - buf), buf_len);\n\t\t}\n\t\tRETURN_FALSE;\n\t}\n\t/* We should keep an reference to return_value to prevent it from being dtor\n\t in case nesting calls to unserialize */\n\tvar_push_dtor(&var_hash, return_value);\n\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\tif (class_hash) {\n\t\tzend_hash_destroy(class_hash);\n\t\tFREE_HASHTABLE(class_hash);\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9936", "cwe_id": "CWE-416" }, { "id": 730, "func": "PHP_FUNCTION(unserialize)\n{\n\tchar *buf = NULL;\n\tsize_t buf_len;\n\tconst unsigned char *p;\n\tphp_unserialize_data_t var_hash;\n\tzval *options = NULL, *classes = NULL;\n\tzval *retval;\n\tHashTable *class_hash = NULL;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS(), \"s|a\", &buf, &buf_len, &options) == FAILURE) {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (buf_len == 0) {\n\t\tRETURN_FALSE;\n\t}\n\n\tp = (const unsigned char*) buf;\n\tPHP_VAR_UNSERIALIZE_INIT(var_hash);\n\tif(options != NULL) {\n\t\tclasses = zend_hash_str_find(Z_ARRVAL_P(options), \"allowed_classes\", sizeof(\"allowed_classes\")-1);\n\t\tif(classes && (Z_TYPE_P(classes) == IS_ARRAY || !zend_is_true(classes))) {\n\t\t\tALLOC_HASHTABLE(class_hash);\n\t\t\tzend_hash_init(class_hash, (Z_TYPE_P(classes) == IS_ARRAY)?zend_hash_num_elements(Z_ARRVAL_P(classes)):0, NULL, NULL, 0);\n\t\t}\n\t\tif(class_hash && Z_TYPE_P(classes) == IS_ARRAY) {\n\t\t\tzval *entry;\n\t\t\tzend_string *lcname;\n\n\t\t\tZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(classes), entry) {\n\t\t\t\tconvert_to_string_ex(entry);\n\t\t\t\tlcname = zend_string_tolower(Z_STR_P(entry));\n\t\t\t\tzend_hash_add_empty_element(class_hash, lcname);\n\t\t zend_string_release(lcname);\n\t\t\t} ZEND_HASH_FOREACH_END();\n\t\t}\n\t}\n\n\tretval = var_tmp_var(&var_hash);\n\tif (!php_var_unserialize_ex(retval, &p, p + buf_len, &var_hash, class_hash)) {\n\t\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\t\tif (class_hash) {\n\t\t\tzend_hash_destroy(class_hash);\n\t\t\tFREE_HASHTABLE(class_hash);\n\t\t}\n\t\tif (!EG(exception)) {\n\t\t\tphp_error_docref(NULL, E_NOTICE, \"Error at offset \" ZEND_LONG_FMT \" of %zd bytes\",\n\t\t\t\t(zend_long)((char*)p - buf), buf_len);\n\t\t}\n\t\tRETURN_FALSE;\n\t}\n\n\tZVAL_COPY(return_value, retval);\n\n\tPHP_VAR_UNSERIALIZE_DESTROY(var_hash);\n\tif (class_hash) {\n\t\tzend_hash_destroy(class_hash);\n\t\tFREE_HASHTABLE(class_hash);\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9936", "cwe_id": "CWE-416" }, { "id": 2052, "func": "static void mem_cgroup_usage_unregister_event(struct cgroup *cgrp,\n\tstruct cftype *cft, struct eventfd_ctx *eventfd)\n{\n\tstruct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);\n\tstruct mem_cgroup_thresholds *thresholds;\n\tstruct mem_cgroup_threshold_ary *new;\n\tint type = MEMFILE_TYPE(cft->private);\n\tu64 usage;\n\tint i, j, size;\n\n\tmutex_lock(&memcg->thresholds_lock);\n\tif (type == _MEM)\n\t\tthresholds = &memcg->thresholds;\n\telse if (type == _MEMSWAP)\n\t\tthresholds = &memcg->memsw_thresholds;\n\telse\n\t\tBUG();\n\n\t/*\n\t * Something went wrong if we trying to unregister a threshold\n\t * if we don't have thresholds\n\t */\n\tBUG_ON(!thresholds);\n\n\tusage = mem_cgroup_usage(memcg, type == _MEMSWAP);\n\n\t/* Check if a threshold crossed before removing */\n\t__mem_cgroup_threshold(memcg, type == _MEMSWAP);\n\n\t/* Calculate new number of threshold */\n\tsize = 0;\n\tfor (i = 0; i < thresholds->primary->size; i++) {\n\t\tif (thresholds->primary->entries[i].eventfd != eventfd)\n\t\t\tsize++;\n\t}\n\n\tnew = thresholds->spare;\n\n\t/* Set thresholds array to NULL if we don't have thresholds */\n\tif (!size) {\n\t\tkfree(new);\n\t\tnew = NULL;\n\t\tgoto swap_buffers;\n\t}\n\n\tnew->size = size;\n\n\t/* Copy thresholds and find current threshold */\n\tnew->current_threshold = -1;\n\tfor (i = 0, j = 0; i < thresholds->primary->size; i++) {\n\t\tif (thresholds->primary->entries[i].eventfd == eventfd)\n\t\t\tcontinue;\n\n\t\tnew->entries[j] = thresholds->primary->entries[i];\n\t\tif (new->entries[j].threshold < usage) {\n\t\t\t/*\n\t\t\t * new->current_threshold will not be used\n\t\t\t * until rcu_assign_pointer(), so it's safe to increment\n\t\t\t * it here.\n\t\t\t */\n\t\t\t++new->current_threshold;\n\t\t}\n\t\tj++;\n\t}\n\nswap_buffers:\n\t/* Swap primary and spare array */\n\tthresholds->spare = thresholds->primary;\n\trcu_assign_pointer(thresholds->primary, new);\n\n\t/* To be sure that nobody uses thresholds */\n\tsynchronize_rcu();\n\n\tmutex_unlock(&memcg->thresholds_lock);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-1146", "cwe_id": "CWE-476" }, { "id": 2052, "func": "static void mem_cgroup_usage_unregister_event(struct cgroup *cgrp,\n\tstruct cftype *cft, struct eventfd_ctx *eventfd)\n{\n\tstruct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);\n\tstruct mem_cgroup_thresholds *thresholds;\n\tstruct mem_cgroup_threshold_ary *new;\n\tint type = MEMFILE_TYPE(cft->private);\n\tu64 usage;\n\tint i, j, size;\n\n\tmutex_lock(&memcg->thresholds_lock);\n\tif (type == _MEM)\n\t\tthresholds = &memcg->thresholds;\n\telse if (type == _MEMSWAP)\n\t\tthresholds = &memcg->memsw_thresholds;\n\telse\n\t\tBUG();\n\n\t/*\n\t * Something went wrong if we trying to unregister a threshold\n\t * if we don't have thresholds\n\t */\n\tBUG_ON(!thresholds);\n\n\tif (!thresholds->primary)\n\t\tgoto unlock;\n\n\tusage = mem_cgroup_usage(memcg, type == _MEMSWAP);\n\n\t/* Check if a threshold crossed before removing */\n\t__mem_cgroup_threshold(memcg, type == _MEMSWAP);\n\n\t/* Calculate new number of threshold */\n\tsize = 0;\n\tfor (i = 0; i < thresholds->primary->size; i++) {\n\t\tif (thresholds->primary->entries[i].eventfd != eventfd)\n\t\t\tsize++;\n\t}\n\n\tnew = thresholds->spare;\n\n\t/* Set thresholds array to NULL if we don't have thresholds */\n\tif (!size) {\n\t\tkfree(new);\n\t\tnew = NULL;\n\t\tgoto swap_buffers;\n\t}\n\n\tnew->size = size;\n\n\t/* Copy thresholds and find current threshold */\n\tnew->current_threshold = -1;\n\tfor (i = 0, j = 0; i < thresholds->primary->size; i++) {\n\t\tif (thresholds->primary->entries[i].eventfd == eventfd)\n\t\t\tcontinue;\n\n\t\tnew->entries[j] = thresholds->primary->entries[i];\n\t\tif (new->entries[j].threshold < usage) {\n\t\t\t/*\n\t\t\t * new->current_threshold will not be used\n\t\t\t * until rcu_assign_pointer(), so it's safe to increment\n\t\t\t * it here.\n\t\t\t */\n\t\t\t++new->current_threshold;\n\t\t}\n\t\tj++;\n\t}\n\nswap_buffers:\n\t/* Swap primary and spare array */\n\tthresholds->spare = thresholds->primary;\n\trcu_assign_pointer(thresholds->primary, new);\n\n\t/* To be sure that nobody uses thresholds */\n\tsynchronize_rcu();\nunlock:\n\tmutex_unlock(&memcg->thresholds_lock);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-1146", "cwe_id": "CWE-476" }, { "id": 2195, "func": "static int udf_load_logicalvol(struct super_block *sb, sector_t block,\n\t\t\t struct kernel_lb_addr *fileset)\n{\n\tstruct logicalVolDesc *lvd;\n\tint i, j, offset;\n\tuint8_t type;\n\tstruct udf_sb_info *sbi = UDF_SB(sb);\n\tstruct genericPartitionMap *gpm;\n\tuint16_t ident;\n\tstruct buffer_head *bh;\n\tint ret = 0;\n\n\tbh = udf_read_tagged(sb, block, block, &ident);\n\tif (!bh)\n\t\treturn 1;\n\tBUG_ON(ident != TAG_IDENT_LVD);\n\tlvd = (struct logicalVolDesc *)bh->b_data;\n\n\tret = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps));\n\tif (ret)\n\t\tgoto out_bh;\n\n\tfor (i = 0, offset = 0;\n\t i < sbi->s_partitions && offset < le32_to_cpu(lvd->mapTableLength);\n\t i++, offset += gpm->partitionMapLength) {\n\t\tstruct udf_part_map *map = &sbi->s_partmaps[i];\n\t\tgpm = (struct genericPartitionMap *)\n\t\t\t\t&(lvd->partitionMaps[offset]);\n\t\ttype = gpm->partitionMapType;\n\t\tif (type == 1) {\n\t\t\tstruct genericPartitionMap1 *gpm1 =\n\t\t\t\t(struct genericPartitionMap1 *)gpm;\n\t\t\tmap->s_partition_type = UDF_TYPE1_MAP15;\n\t\t\tmap->s_volumeseqnum = le16_to_cpu(gpm1->volSeqNum);\n\t\t\tmap->s_partition_num = le16_to_cpu(gpm1->partitionNum);\n\t\t\tmap->s_partition_func = NULL;\n\t\t} else if (type == 2) {\n\t\t\tstruct udfPartitionMap2 *upm2 =\n\t\t\t\t\t\t(struct udfPartitionMap2 *)gpm;\n\t\t\tif (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL,\n\t\t\t\t\t\tstrlen(UDF_ID_VIRTUAL))) {\n\t\t\t\tu16 suf =\n\t\t\t\t\tle16_to_cpu(((__le16 *)upm2->partIdent.\n\t\t\t\t\t\t\tidentSuffix)[0]);\n\t\t\t\tif (suf < 0x0200) {\n\t\t\t\t\tmap->s_partition_type =\n\t\t\t\t\t\t\tUDF_VIRTUAL_MAP15;\n\t\t\t\t\tmap->s_partition_func =\n\t\t\t\t\t\t\tudf_get_pblock_virt15;\n\t\t\t\t} else {\n\t\t\t\t\tmap->s_partition_type =\n\t\t\t\t\t\t\tUDF_VIRTUAL_MAP20;\n\t\t\t\t\tmap->s_partition_func =\n\t\t\t\t\t\t\tudf_get_pblock_virt20;\n\t\t\t\t}\n\t\t\t} else if (!strncmp(upm2->partIdent.ident,\n\t\t\t\t\t\tUDF_ID_SPARABLE,\n\t\t\t\t\t\tstrlen(UDF_ID_SPARABLE))) {\n\t\t\t\tuint32_t loc;\n\t\t\t\tstruct sparingTable *st;\n\t\t\t\tstruct sparablePartitionMap *spm =\n\t\t\t\t\t(struct sparablePartitionMap *)gpm;\n\n\t\t\t\tmap->s_partition_type = UDF_SPARABLE_MAP15;\n\t\t\t\tmap->s_type_specific.s_sparing.s_packet_len =\n\t\t\t\t\t\tle16_to_cpu(spm->packetLength);\n\t\t\t\tfor (j = 0; j < spm->numSparingTables; j++) {\n\t\t\t\t\tstruct buffer_head *bh2;\n\n\t\t\t\t\tloc = le32_to_cpu(\n\t\t\t\t\t\tspm->locSparingTable[j]);\n\t\t\t\t\tbh2 = udf_read_tagged(sb, loc, loc,\n\t\t\t\t\t\t\t &ident);\n\t\t\t\t\tmap->s_type_specific.s_sparing.\n\t\t\t\t\t\t\ts_spar_map[j] = bh2;\n\n\t\t\t\t\tif (bh2 == NULL)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tst = (struct sparingTable *)bh2->b_data;\n\t\t\t\t\tif (ident != 0 || strncmp(\n\t\t\t\t\t\tst->sparingIdent.ident,\n\t\t\t\t\t\tUDF_ID_SPARING,\n\t\t\t\t\t\tstrlen(UDF_ID_SPARING))) {\n\t\t\t\t\t\tbrelse(bh2);\n\t\t\t\t\t\tmap->s_type_specific.s_sparing.\n\t\t\t\t\t\t\ts_spar_map[j] = NULL;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmap->s_partition_func = udf_get_pblock_spar15;\n\t\t\t} else if (!strncmp(upm2->partIdent.ident,\n\t\t\t\t\t\tUDF_ID_METADATA,\n\t\t\t\t\t\tstrlen(UDF_ID_METADATA))) {\n\t\t\t\tstruct udf_meta_data *mdata =\n\t\t\t\t\t&map->s_type_specific.s_metadata;\n\t\t\t\tstruct metadataPartitionMap *mdm =\n\t\t\t\t\t\t(struct metadataPartitionMap *)\n\t\t\t\t\t\t&(lvd->partitionMaps[offset]);\n\t\t\t\tudf_debug(\"Parsing Logical vol part %d type %d id=%s\\n\",\n\t\t\t\t\t i, type, UDF_ID_METADATA);\n\n\t\t\t\tmap->s_partition_type = UDF_METADATA_MAP25;\n\t\t\t\tmap->s_partition_func = udf_get_pblock_meta25;\n\n\t\t\t\tmdata->s_meta_file_loc =\n\t\t\t\t\tle32_to_cpu(mdm->metadataFileLoc);\n\t\t\t\tmdata->s_mirror_file_loc =\n\t\t\t\t\tle32_to_cpu(mdm->metadataMirrorFileLoc);\n\t\t\t\tmdata->s_bitmap_file_loc =\n\t\t\t\t\tle32_to_cpu(mdm->metadataBitmapFileLoc);\n\t\t\t\tmdata->s_alloc_unit_size =\n\t\t\t\t\tle32_to_cpu(mdm->allocUnitSize);\n\t\t\t\tmdata->s_align_unit_size =\n\t\t\t\t\tle16_to_cpu(mdm->alignUnitSize);\n\t\t\t\tif (mdm->flags & 0x01)\n\t\t\t\t\tmdata->s_flags |= MF_DUPLICATE_MD;\n\n\t\t\t\tudf_debug(\"Metadata Ident suffix=0x%x\\n\",\n\t\t\t\t\t le16_to_cpu(*(__le16 *)\n\t\t\t\t\t\t mdm->partIdent.identSuffix));\n\t\t\t\tudf_debug(\"Metadata part num=%d\\n\",\n\t\t\t\t\t le16_to_cpu(mdm->partitionNum));\n\t\t\t\tudf_debug(\"Metadata part alloc unit size=%d\\n\",\n\t\t\t\t\t le32_to_cpu(mdm->allocUnitSize));\n\t\t\t\tudf_debug(\"Metadata file loc=%d\\n\",\n\t\t\t\t\t le32_to_cpu(mdm->metadataFileLoc));\n\t\t\t\tudf_debug(\"Mirror file loc=%d\\n\",\n\t\t\t\t\t le32_to_cpu(mdm->metadataMirrorFileLoc));\n\t\t\t\tudf_debug(\"Bitmap file loc=%d\\n\",\n\t\t\t\t\t le32_to_cpu(mdm->metadataBitmapFileLoc));\n\t\t\t\tudf_debug(\"Flags: %d %d\\n\",\n\t\t\t\t\t mdata->s_flags, mdm->flags);\n\t\t\t} else {\n\t\t\t\tudf_debug(\"Unknown ident: %s\\n\",\n\t\t\t\t\t upm2->partIdent.ident);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmap->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum);\n\t\t\tmap->s_partition_num = le16_to_cpu(upm2->partitionNum);\n\t\t}\n\t\tudf_debug(\"Partition (%d:%d) type %d on volume %d\\n\",\n\t\t\t i, map->s_partition_num, type, map->s_volumeseqnum);\n\t}\n\n\tif (fileset) {\n\t\tstruct long_ad *la = (struct long_ad *)&(lvd->logicalVolContentsUse[0]);\n\n\t\t*fileset = lelb_to_cpu(la->extLocation);\n\t\tudf_debug(\"FileSet found in LogicalVolDesc at block=%d, partition=%d\\n\",\n\t\t\t fileset->logicalBlockNum,\n\t\t\t fileset->partitionReferenceNum);\n\t}\n\tif (lvd->integritySeqExt.extLength)\n\t\tudf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt));\n\nout_bh:\n\tbrelse(bh);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-3400", "cwe_id": "CWE-119" }, { "id": 2195, "func": "static int udf_load_logicalvol(struct super_block *sb, sector_t block,\n\t\t\t struct kernel_lb_addr *fileset)\n{\n\tstruct logicalVolDesc *lvd;\n\tint i, j, offset;\n\tuint8_t type;\n\tstruct udf_sb_info *sbi = UDF_SB(sb);\n\tstruct genericPartitionMap *gpm;\n\tuint16_t ident;\n\tstruct buffer_head *bh;\n\tunsigned int table_len;\n\tint ret = 0;\n\n\tbh = udf_read_tagged(sb, block, block, &ident);\n\tif (!bh)\n\t\treturn 1;\n\tBUG_ON(ident != TAG_IDENT_LVD);\n\tlvd = (struct logicalVolDesc *)bh->b_data;\n\ttable_len = le32_to_cpu(lvd->mapTableLength);\n\tif (sizeof(*lvd) + table_len > sb->s_blocksize) {\n\t\tudf_err(sb, \"error loading logical volume descriptor: \"\n\t\t\t\"Partition table too long (%u > %lu)\\n\", table_len,\n\t\t\tsb->s_blocksize - sizeof(*lvd));\n\t\tgoto out_bh;\n\t}\n\n\tret = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps));\n\tif (ret)\n\t\tgoto out_bh;\n\n\tfor (i = 0, offset = 0;\n\t i < sbi->s_partitions && offset < table_len;\n\t i++, offset += gpm->partitionMapLength) {\n\t\tstruct udf_part_map *map = &sbi->s_partmaps[i];\n\t\tgpm = (struct genericPartitionMap *)\n\t\t\t\t&(lvd->partitionMaps[offset]);\n\t\ttype = gpm->partitionMapType;\n\t\tif (type == 1) {\n\t\t\tstruct genericPartitionMap1 *gpm1 =\n\t\t\t\t(struct genericPartitionMap1 *)gpm;\n\t\t\tmap->s_partition_type = UDF_TYPE1_MAP15;\n\t\t\tmap->s_volumeseqnum = le16_to_cpu(gpm1->volSeqNum);\n\t\t\tmap->s_partition_num = le16_to_cpu(gpm1->partitionNum);\n\t\t\tmap->s_partition_func = NULL;\n\t\t} else if (type == 2) {\n\t\t\tstruct udfPartitionMap2 *upm2 =\n\t\t\t\t\t\t(struct udfPartitionMap2 *)gpm;\n\t\t\tif (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL,\n\t\t\t\t\t\tstrlen(UDF_ID_VIRTUAL))) {\n\t\t\t\tu16 suf =\n\t\t\t\t\tle16_to_cpu(((__le16 *)upm2->partIdent.\n\t\t\t\t\t\t\tidentSuffix)[0]);\n\t\t\t\tif (suf < 0x0200) {\n\t\t\t\t\tmap->s_partition_type =\n\t\t\t\t\t\t\tUDF_VIRTUAL_MAP15;\n\t\t\t\t\tmap->s_partition_func =\n\t\t\t\t\t\t\tudf_get_pblock_virt15;\n\t\t\t\t} else {\n\t\t\t\t\tmap->s_partition_type =\n\t\t\t\t\t\t\tUDF_VIRTUAL_MAP20;\n\t\t\t\t\tmap->s_partition_func =\n\t\t\t\t\t\t\tudf_get_pblock_virt20;\n\t\t\t\t}\n\t\t\t} else if (!strncmp(upm2->partIdent.ident,\n\t\t\t\t\t\tUDF_ID_SPARABLE,\n\t\t\t\t\t\tstrlen(UDF_ID_SPARABLE))) {\n\t\t\t\tuint32_t loc;\n\t\t\t\tstruct sparingTable *st;\n\t\t\t\tstruct sparablePartitionMap *spm =\n\t\t\t\t\t(struct sparablePartitionMap *)gpm;\n\n\t\t\t\tmap->s_partition_type = UDF_SPARABLE_MAP15;\n\t\t\t\tmap->s_type_specific.s_sparing.s_packet_len =\n\t\t\t\t\t\tle16_to_cpu(spm->packetLength);\n\t\t\t\tfor (j = 0; j < spm->numSparingTables; j++) {\n\t\t\t\t\tstruct buffer_head *bh2;\n\n\t\t\t\t\tloc = le32_to_cpu(\n\t\t\t\t\t\tspm->locSparingTable[j]);\n\t\t\t\t\tbh2 = udf_read_tagged(sb, loc, loc,\n\t\t\t\t\t\t\t &ident);\n\t\t\t\t\tmap->s_type_specific.s_sparing.\n\t\t\t\t\t\t\ts_spar_map[j] = bh2;\n\n\t\t\t\t\tif (bh2 == NULL)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tst = (struct sparingTable *)bh2->b_data;\n\t\t\t\t\tif (ident != 0 || strncmp(\n\t\t\t\t\t\tst->sparingIdent.ident,\n\t\t\t\t\t\tUDF_ID_SPARING,\n\t\t\t\t\t\tstrlen(UDF_ID_SPARING))) {\n\t\t\t\t\t\tbrelse(bh2);\n\t\t\t\t\t\tmap->s_type_specific.s_sparing.\n\t\t\t\t\t\t\ts_spar_map[j] = NULL;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmap->s_partition_func = udf_get_pblock_spar15;\n\t\t\t} else if (!strncmp(upm2->partIdent.ident,\n\t\t\t\t\t\tUDF_ID_METADATA,\n\t\t\t\t\t\tstrlen(UDF_ID_METADATA))) {\n\t\t\t\tstruct udf_meta_data *mdata =\n\t\t\t\t\t&map->s_type_specific.s_metadata;\n\t\t\t\tstruct metadataPartitionMap *mdm =\n\t\t\t\t\t\t(struct metadataPartitionMap *)\n\t\t\t\t\t\t&(lvd->partitionMaps[offset]);\n\t\t\t\tudf_debug(\"Parsing Logical vol part %d type %d id=%s\\n\",\n\t\t\t\t\t i, type, UDF_ID_METADATA);\n\n\t\t\t\tmap->s_partition_type = UDF_METADATA_MAP25;\n\t\t\t\tmap->s_partition_func = udf_get_pblock_meta25;\n\n\t\t\t\tmdata->s_meta_file_loc =\n\t\t\t\t\tle32_to_cpu(mdm->metadataFileLoc);\n\t\t\t\tmdata->s_mirror_file_loc =\n\t\t\t\t\tle32_to_cpu(mdm->metadataMirrorFileLoc);\n\t\t\t\tmdata->s_bitmap_file_loc =\n\t\t\t\t\tle32_to_cpu(mdm->metadataBitmapFileLoc);\n\t\t\t\tmdata->s_alloc_unit_size =\n\t\t\t\t\tle32_to_cpu(mdm->allocUnitSize);\n\t\t\t\tmdata->s_align_unit_size =\n\t\t\t\t\tle16_to_cpu(mdm->alignUnitSize);\n\t\t\t\tif (mdm->flags & 0x01)\n\t\t\t\t\tmdata->s_flags |= MF_DUPLICATE_MD;\n\n\t\t\t\tudf_debug(\"Metadata Ident suffix=0x%x\\n\",\n\t\t\t\t\t le16_to_cpu(*(__le16 *)\n\t\t\t\t\t\t mdm->partIdent.identSuffix));\n\t\t\t\tudf_debug(\"Metadata part num=%d\\n\",\n\t\t\t\t\t le16_to_cpu(mdm->partitionNum));\n\t\t\t\tudf_debug(\"Metadata part alloc unit size=%d\\n\",\n\t\t\t\t\t le32_to_cpu(mdm->allocUnitSize));\n\t\t\t\tudf_debug(\"Metadata file loc=%d\\n\",\n\t\t\t\t\t le32_to_cpu(mdm->metadataFileLoc));\n\t\t\t\tudf_debug(\"Mirror file loc=%d\\n\",\n\t\t\t\t\t le32_to_cpu(mdm->metadataMirrorFileLoc));\n\t\t\t\tudf_debug(\"Bitmap file loc=%d\\n\",\n\t\t\t\t\t le32_to_cpu(mdm->metadataBitmapFileLoc));\n\t\t\t\tudf_debug(\"Flags: %d %d\\n\",\n\t\t\t\t\t mdata->s_flags, mdm->flags);\n\t\t\t} else {\n\t\t\t\tudf_debug(\"Unknown ident: %s\\n\",\n\t\t\t\t\t upm2->partIdent.ident);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmap->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum);\n\t\t\tmap->s_partition_num = le16_to_cpu(upm2->partitionNum);\n\t\t}\n\t\tudf_debug(\"Partition (%d:%d) type %d on volume %d\\n\",\n\t\t\t i, map->s_partition_num, type, map->s_volumeseqnum);\n\t}\n\n\tif (fileset) {\n\t\tstruct long_ad *la = (struct long_ad *)&(lvd->logicalVolContentsUse[0]);\n\n\t\t*fileset = lelb_to_cpu(la->extLocation);\n\t\tudf_debug(\"FileSet found in LogicalVolDesc at block=%d, partition=%d\\n\",\n\t\t\t fileset->logicalBlockNum,\n\t\t\t fileset->partitionReferenceNum);\n\t}\n\tif (lvd->integritySeqExt.extLength)\n\t\tudf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt));\n\nout_bh:\n\tbrelse(bh);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-3400", "cwe_id": "CWE-119" }, { "id": 2349, "func": " inline void pad(int bytes) {\n while (bytes-- > 0) writeU8(0);\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 2349, "func": " inline void pad(size_t bytes) {\n while (bytes-- > 0) writeU8(0);\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15694", "cwe_id": "CWE-787" }, { "id": 1349, "func": "void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv)\n{\n\tstruct nci_dev *ndev = priv->ndev;\n\n\tif (priv->ndev->nfc_dev->fw_download_in_progress)\n\t\tnfcmrvl_fw_dnld_abort(priv);\n\n\tnfcmrvl_fw_dnld_deinit(priv);\n\n\tif (gpio_is_valid(priv->config.reset_n_io))\n\t\tgpio_free(priv->config.reset_n_io);\n\n\tnci_unregister_device(ndev);\n\tnci_free_device(ndev);\n\tkfree(priv);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-1734", "cwe_id": "CWE-416" }, { "id": 1349, "func": "void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv)\n{\n\tstruct nci_dev *ndev = priv->ndev;\n\n\tnci_unregister_device(ndev);\n\tif (priv->ndev->nfc_dev->fw_download_in_progress)\n\t\tnfcmrvl_fw_dnld_abort(priv);\n\n\tnfcmrvl_fw_dnld_deinit(priv);\n\n\tif (gpio_is_valid(priv->config.reset_n_io))\n\t\tgpio_free(priv->config.reset_n_io);\n\n\tnci_free_device(ndev);\n\tkfree(priv);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-1734", "cwe_id": "CWE-416" }, { "id": 925, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* cond_tensor =\n GetInput(context, node, kInputConditionTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n if (IsDynamicTensor(output)) {\n TF_LITE_ENSURE_OK(context,\n ResizeOutputTensor(context, cond_tensor, output));\n }\n\n TfLiteIntArray* dims = cond_tensor->dims;\n if (dims->size == 0) {\n // Scalar tensors are not supported.\n TF_LITE_KERNEL_LOG(context, \"Where op requires condition w/ rank > 0\");\n return kTfLiteError;\n }\n\n reference_ops::SelectTrueCoords(GetTensorShape(cond_tensor),\n GetTensorData(cond_tensor),\n GetTensorData(output));\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 925, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n const TfLiteTensor* cond_tensor;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputConditionTensor,\n &cond_tensor));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n if (IsDynamicTensor(output)) {\n TF_LITE_ENSURE_OK(context,\n ResizeOutputTensor(context, cond_tensor, output));\n }\n\n TfLiteIntArray* dims = cond_tensor->dims;\n if (dims->size == 0) {\n // Scalar tensors are not supported.\n TF_LITE_KERNEL_LOG(context, \"Where op requires condition w/ rank > 0\");\n return kTfLiteError;\n }\n\n reference_ops::SelectTrueCoords(GetTensorShape(cond_tensor),\n GetTensorData(cond_tensor),\n GetTensorData(output));\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2740, "func": "void CNB::DoIPHdrCSO(PVOID IpHeader, ULONG EthPayloadLength) const\n{\n ParaNdis_CheckSumVerifyFlat(IpHeader,\n EthPayloadLength,\n pcrIpChecksum | pcrFixIPChecksum,\n __FUNCTION__);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-3215", "cwe_id": "CWE-20" }, { "id": 2740, "func": "void CNB::DoIPHdrCSO(PVOID IpHeader, ULONG EthPayloadLength) const\n{\n ParaNdis_CheckSumVerifyFlat(IpHeader,\n EthPayloadLength,\n pcrIpChecksum | pcrFixIPChecksum, FALSE,\n __FUNCTION__);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-3215", "cwe_id": "CWE-20" }, { "id": 1514, "func": "static int jp2_pclr_putdata(jp2_box_t *box, jas_stream_t *out)\n{\n#if 0\n\tjp2_pclr_t *pclr = &box->data.pclr;\n#endif\n/* Eliminate warning about unused variable. */\nbox = 0;\nout = 0;\n\treturn -1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-6850", "cwe_id": "CWE-476" }, { "id": 1514, "func": "static int jp2_pclr_putdata(jp2_box_t *box, jas_stream_t *out)\n{\n#if 0\n\tjp2_pclr_t *pclr = &box->data.pclr;\n#endif\n\t/* Eliminate warning about unused variable. */\n\tbox = 0;\n\tout = 0;\n\treturn -1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-6850", "cwe_id": "CWE-476" }, { "id": 2023, "func": "pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)\n{\n\tInitializeCriticalSection(mutex);\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-25048", "cwe_id": "CWE-125" }, { "id": 2023, "func": "pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)\n{\n\tif ((mutex->lock = malloc(sizeof(CRITICAL_SECTION))) == NULL)\n\t\texit(ENOMEM);\n\tInitializeCriticalSection(mutex->lock);\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-25048", "cwe_id": "CWE-125" }, { "id": 1189, "func": "SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,\n\t unsigned int *nbytes, struct kvec *iov, int n_vec)\n{\n\tstruct smb_rqst rqst;\n\tint rc = 0;\n\tstruct smb2_write_req *req = NULL;\n\tstruct smb2_write_rsp *rsp = NULL;\n\tint resp_buftype;\n\tstruct kvec rsp_iov;\n\tint flags = 0;\n\tunsigned int total_len;\n\n\t*nbytes = 0;\n\n\tif (n_vec < 1)\n\t\treturn rc;\n\n\trc = smb2_plain_req_init(SMB2_WRITE, io_parms->tcon, (void **) &req,\n\t\t\t &total_len);\n\tif (rc)\n\t\treturn rc;\n\n\tif (io_parms->tcon->ses->server == NULL)\n\t\treturn -ECONNABORTED;\n\n\tif (smb3_encryption_required(io_parms->tcon))\n\t\tflags |= CIFS_TRANSFORM_REQ;\n\n\treq->sync_hdr.ProcessId = cpu_to_le32(io_parms->pid);\n\n\treq->PersistentFileId = io_parms->persistent_fid;\n\treq->VolatileFileId = io_parms->volatile_fid;\n\treq->WriteChannelInfoOffset = 0;\n\treq->WriteChannelInfoLength = 0;\n\treq->Channel = 0;\n\treq->Length = cpu_to_le32(io_parms->length);\n\treq->Offset = cpu_to_le64(io_parms->offset);\n\treq->DataOffset = cpu_to_le16(\n\t\t\t\toffsetof(struct smb2_write_req, Buffer));\n\treq->RemainingBytes = 0;\n\n\ttrace_smb3_write_enter(xid, io_parms->persistent_fid,\n\t\tio_parms->tcon->tid, io_parms->tcon->ses->Suid,\n\t\tio_parms->offset, io_parms->length);\n\n\tiov[0].iov_base = (char *)req;\n\t/* 1 for Buffer */\n\tiov[0].iov_len = total_len - 1;\n\n\tmemset(&rqst, 0, sizeof(struct smb_rqst));\n\trqst.rq_iov = iov;\n\trqst.rq_nvec = n_vec + 1;\n\n\trc = cifs_send_recv(xid, io_parms->tcon->ses, &rqst,\n\t\t\t &resp_buftype, flags, &rsp_iov);\n\tcifs_small_buf_release(req);\n\trsp = (struct smb2_write_rsp *)rsp_iov.iov_base;\n\n\tif (rc) {\n\t\ttrace_smb3_write_err(xid, req->PersistentFileId,\n\t\t\t\t io_parms->tcon->tid,\n\t\t\t\t io_parms->tcon->ses->Suid,\n\t\t\t\t io_parms->offset, io_parms->length, rc);\n\t\tcifs_stats_fail_inc(io_parms->tcon, SMB2_WRITE_HE);\n\t\tcifs_dbg(VFS, \"Send error in write = %d\\n\", rc);\n\t} else {\n\t\t*nbytes = le32_to_cpu(rsp->DataLength);\n\t\ttrace_smb3_write_done(xid, req->PersistentFileId,\n\t\t\t\t io_parms->tcon->tid,\n\t\t\t\t io_parms->tcon->ses->Suid,\n\t\t\t\t io_parms->offset, *nbytes);\n\t}\n\n\tfree_rsp_buf(resp_buftype, rsp);\n\treturn rc;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-15919", "cwe_id": "CWE-416" }, { "id": 1189, "func": "SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,\n\t unsigned int *nbytes, struct kvec *iov, int n_vec)\n{\n\tstruct smb_rqst rqst;\n\tint rc = 0;\n\tstruct smb2_write_req *req = NULL;\n\tstruct smb2_write_rsp *rsp = NULL;\n\tint resp_buftype;\n\tstruct kvec rsp_iov;\n\tint flags = 0;\n\tunsigned int total_len;\n\n\t*nbytes = 0;\n\n\tif (n_vec < 1)\n\t\treturn rc;\n\n\trc = smb2_plain_req_init(SMB2_WRITE, io_parms->tcon, (void **) &req,\n\t\t\t &total_len);\n\tif (rc)\n\t\treturn rc;\n\n\tif (io_parms->tcon->ses->server == NULL)\n\t\treturn -ECONNABORTED;\n\n\tif (smb3_encryption_required(io_parms->tcon))\n\t\tflags |= CIFS_TRANSFORM_REQ;\n\n\treq->sync_hdr.ProcessId = cpu_to_le32(io_parms->pid);\n\n\treq->PersistentFileId = io_parms->persistent_fid;\n\treq->VolatileFileId = io_parms->volatile_fid;\n\treq->WriteChannelInfoOffset = 0;\n\treq->WriteChannelInfoLength = 0;\n\treq->Channel = 0;\n\treq->Length = cpu_to_le32(io_parms->length);\n\treq->Offset = cpu_to_le64(io_parms->offset);\n\treq->DataOffset = cpu_to_le16(\n\t\t\t\toffsetof(struct smb2_write_req, Buffer));\n\treq->RemainingBytes = 0;\n\n\ttrace_smb3_write_enter(xid, io_parms->persistent_fid,\n\t\tio_parms->tcon->tid, io_parms->tcon->ses->Suid,\n\t\tio_parms->offset, io_parms->length);\n\n\tiov[0].iov_base = (char *)req;\n\t/* 1 for Buffer */\n\tiov[0].iov_len = total_len - 1;\n\n\tmemset(&rqst, 0, sizeof(struct smb_rqst));\n\trqst.rq_iov = iov;\n\trqst.rq_nvec = n_vec + 1;\n\n\trc = cifs_send_recv(xid, io_parms->tcon->ses, &rqst,\n\t\t\t &resp_buftype, flags, &rsp_iov);\n\trsp = (struct smb2_write_rsp *)rsp_iov.iov_base;\n\n\tif (rc) {\n\t\ttrace_smb3_write_err(xid, req->PersistentFileId,\n\t\t\t\t io_parms->tcon->tid,\n\t\t\t\t io_parms->tcon->ses->Suid,\n\t\t\t\t io_parms->offset, io_parms->length, rc);\n\t\tcifs_stats_fail_inc(io_parms->tcon, SMB2_WRITE_HE);\n\t\tcifs_dbg(VFS, \"Send error in write = %d\\n\", rc);\n\t} else {\n\t\t*nbytes = le32_to_cpu(rsp->DataLength);\n\t\ttrace_smb3_write_done(xid, req->PersistentFileId,\n\t\t\t\t io_parms->tcon->tid,\n\t\t\t\t io_parms->tcon->ses->Suid,\n\t\t\t\t io_parms->offset, *nbytes);\n\t}\n\n\tcifs_small_buf_release(req);\n\tfree_rsp_buf(resp_buftype, rsp);\n\treturn rc;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-15919", "cwe_id": "CWE-416" }, { "id": 1152, "func": "compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env)\n{\n int r, len;\n\n switch (node->type) {\n case BAG_MEMORY:\n r = compile_bag_memory_node(node, reg, env);\n break;\n\n case BAG_OPTION:\n r = compile_option_node(node, reg, env);\n break;\n\n case BAG_STOP_BACKTRACK:\n if (NODE_IS_STOP_BT_SIMPLE_REPEAT(node)) {\n QuantNode* qn = QUANT_(NODE_BAG_BODY(node));\n r = compile_tree_n_times(NODE_QUANT_BODY(qn), qn->lower, reg, env);\n if (r != 0) return r;\n\n len = compile_length_tree(NODE_QUANT_BODY(qn), reg);\n if (len < 0) return len;\n\n r = add_op(reg, OP_PUSH);\n if (r != 0) return r;\n COP(reg)->push.addr = SIZE_INC_OP + len + SIZE_OP_POP_OUT + SIZE_OP_JUMP;\n\n r = compile_tree(NODE_QUANT_BODY(qn), reg, env);\n if (r != 0) return r;\n r = add_op(reg, OP_POP_OUT);\n if (r != 0) return r;\n\n r = add_op(reg, OP_JUMP);\n if (r != 0) return r;\n COP(reg)->jump.addr = -((int )SIZE_OP_PUSH + len + (int )SIZE_OP_POP_OUT);\n }\n else {\n r = add_op(reg, OP_ATOMIC_START);\n if (r != 0) return r;\n r = compile_tree(NODE_BAG_BODY(node), reg, env);\n if (r != 0) return r;\n r = add_op(reg, OP_ATOMIC_END);\n }\n break;\n\n case BAG_IF_ELSE:\n {\n int cond_len, then_len, jump_len;\n Node* cond = NODE_BAG_BODY(node);\n Node* Then = node->te.Then;\n Node* Else = node->te.Else;\n\n r = add_op(reg, OP_ATOMIC_START);\n if (r != 0) return r;\n\n cond_len = compile_length_tree(cond, reg);\n if (cond_len < 0) return cond_len;\n if (IS_NOT_NULL(Then)) {\n then_len = compile_length_tree(Then, reg);\n if (then_len < 0) return then_len;\n }\n else\n then_len = 0;\n\n jump_len = cond_len + then_len + SIZE_OP_ATOMIC_END;\n if (IS_NOT_NULL(Else)) jump_len += SIZE_OP_JUMP;\n\n r = add_op(reg, OP_PUSH);\n if (r != 0) return r;\n COP(reg)->push.addr = SIZE_INC_OP + jump_len;\n\n r = compile_tree(cond, reg, env);\n if (r != 0) return r;\n r = add_op(reg, OP_ATOMIC_END);\n if (r != 0) return r;\n\n if (IS_NOT_NULL(Then)) {\n r = compile_tree(Then, reg, env);\n if (r != 0) return r;\n }\n\n if (IS_NOT_NULL(Else)) {\n int else_len = compile_length_tree(Else, reg);\n r = add_op(reg, OP_JUMP);\n if (r != 0) return r;\n COP(reg)->jump.addr = else_len + SIZE_INC_OP;\n\n r = compile_tree(Else, reg, env);\n }\n }\n break;\n }\n\n return r;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-13225", "cwe_id": "CWE-476" }, { "id": 1152, "func": "compile_bag_node(BagNode* node, regex_t* reg, ScanEnv* env)\n{\n int r, len;\n\n switch (node->type) {\n case BAG_MEMORY:\n r = compile_bag_memory_node(node, reg, env);\n break;\n\n case BAG_OPTION:\n r = compile_option_node(node, reg, env);\n break;\n\n case BAG_STOP_BACKTRACK:\n if (NODE_IS_STOP_BT_SIMPLE_REPEAT(node)) {\n QuantNode* qn = QUANT_(NODE_BAG_BODY(node));\n r = compile_tree_n_times(NODE_QUANT_BODY(qn), qn->lower, reg, env);\n if (r != 0) return r;\n\n len = compile_length_tree(NODE_QUANT_BODY(qn), reg);\n if (len < 0) return len;\n\n r = add_op(reg, OP_PUSH);\n if (r != 0) return r;\n COP(reg)->push.addr = SIZE_INC_OP + len + SIZE_OP_POP_OUT + SIZE_OP_JUMP;\n\n r = compile_tree(NODE_QUANT_BODY(qn), reg, env);\n if (r != 0) return r;\n r = add_op(reg, OP_POP_OUT);\n if (r != 0) return r;\n\n r = add_op(reg, OP_JUMP);\n if (r != 0) return r;\n COP(reg)->jump.addr = -((int )SIZE_OP_PUSH + len + (int )SIZE_OP_POP_OUT);\n }\n else {\n r = add_op(reg, OP_ATOMIC_START);\n if (r != 0) return r;\n r = compile_tree(NODE_BAG_BODY(node), reg, env);\n if (r != 0) return r;\n r = add_op(reg, OP_ATOMIC_END);\n }\n break;\n\n case BAG_IF_ELSE:\n {\n int cond_len, then_len, else_len, jump_len;\n Node* cond = NODE_BAG_BODY(node);\n Node* Then = node->te.Then;\n Node* Else = node->te.Else;\n\n r = add_op(reg, OP_ATOMIC_START);\n if (r != 0) return r;\n\n cond_len = compile_length_tree(cond, reg);\n if (cond_len < 0) return cond_len;\n if (IS_NOT_NULL(Then)) {\n then_len = compile_length_tree(Then, reg);\n if (then_len < 0) return then_len;\n }\n else\n then_len = 0;\n\n jump_len = cond_len + then_len + SIZE_OP_ATOMIC_END + SIZE_OP_JUMP;\n\n r = add_op(reg, OP_PUSH);\n if (r != 0) return r;\n COP(reg)->push.addr = SIZE_INC_OP + jump_len;\n\n r = compile_tree(cond, reg, env);\n if (r != 0) return r;\n r = add_op(reg, OP_ATOMIC_END);\n if (r != 0) return r;\n\n if (IS_NOT_NULL(Then)) {\n r = compile_tree(Then, reg, env);\n if (r != 0) return r;\n }\n\n if (IS_NOT_NULL(Else)) {\n else_len = compile_length_tree(Else, reg);\n if (else_len < 0) return else_len;\n }\n else\n else_len = 0;\n\n r = add_op(reg, OP_JUMP);\n if (r != 0) return r;\n COP(reg)->jump.addr = SIZE_OP_ATOMIC_END + else_len + SIZE_INC_OP;\n\n r = add_op(reg, OP_ATOMIC_END);\n if (r != 0) return r;\n\n if (IS_NOT_NULL(Else)) {\n r = compile_tree(Else, reg, env);\n }\n }\n break;\n }\n\n return r;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-13225", "cwe_id": "CWE-476" }, { "id": 100, "func": "static int serdes_probe(struct platform_device *pdev)\n{\n\tstruct phy_provider *provider;\n\tstruct serdes_ctrl *ctrl;\n\tunsigned int i;\n\tint ret;\n\n\tctrl = devm_kzalloc(&pdev->dev, sizeof(*ctrl), GFP_KERNEL);\n\tif (!ctrl)\n\t\treturn -ENOMEM;\n\n\tctrl->dev = &pdev->dev;\n\tctrl->regs = syscon_node_to_regmap(pdev->dev.parent->of_node);\n\tif (IS_ERR(ctrl->regs))\n\t\treturn PTR_ERR(ctrl->regs);\n\n\tfor (i = 0; i <= SERDES_MAX; i++) {\n\t\tret = serdes_phy_create(ctrl, i, &ctrl->phys[i]);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tdev_set_drvdata(&pdev->dev, ctrl);\n\n\tprovider = devm_of_phy_provider_register(ctrl->dev,\n\t\t\t\t\t\t serdes_simple_xlate);\n\n\treturn PTR_ERR_OR_ZERO(provider);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20854", "cwe_id": "CWE-125" }, { "id": 100, "func": "static int serdes_probe(struct platform_device *pdev)\n{\n\tstruct phy_provider *provider;\n\tstruct serdes_ctrl *ctrl;\n\tunsigned int i;\n\tint ret;\n\n\tctrl = devm_kzalloc(&pdev->dev, sizeof(*ctrl), GFP_KERNEL);\n\tif (!ctrl)\n\t\treturn -ENOMEM;\n\n\tctrl->dev = &pdev->dev;\n\tctrl->regs = syscon_node_to_regmap(pdev->dev.parent->of_node);\n\tif (IS_ERR(ctrl->regs))\n\t\treturn PTR_ERR(ctrl->regs);\n\n\tfor (i = 0; i < SERDES_MAX; i++) {\n\t\tret = serdes_phy_create(ctrl, i, &ctrl->phys[i]);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tdev_set_drvdata(&pdev->dev, ctrl);\n\n\tprovider = devm_of_phy_provider_register(ctrl->dev,\n\t\t\t\t\t\t serdes_simple_xlate);\n\n\treturn PTR_ERR_OR_ZERO(provider);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20854", "cwe_id": "CWE-125" }, { "id": 2698, "func": "static void bson_append( bson *b, const void *data, int len ) {\n memcpy( b->cur , data , len );\n b->cur += len;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 2698, "func": "static void bson_append( bson *b, const void *data, size_t len ) {\n memcpy( b->cur , data , len );\n b->cur += len;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12135", "cwe_id": "CWE-190" }, { "id": 1747, "func": "test_string_matching (xd3_stream *stream, int ignore)\n{\n usize_t i;\n int ret;\n xd3_config config;\n char rbuf[TESTBUFSIZE];\n\n for (i = 0; i < SIZEOF_ARRAY (match_tests); i += 1)\n {\n const string_match_test *test = & match_tests[i];\n char *rptr = rbuf;\n usize_t len = (usize_t) strlen (test->input);\n\n xd3_free_stream (stream);\n xd3_init_config (& config, 0);\n\n config.smatch_cfg = XD3_SMATCH_SOFT;\n config.smatcher_soft.large_look = 4;\n config.smatcher_soft.large_step = 4;\n config.smatcher_soft.small_look = 4;\n config.smatcher_soft.small_chain = 10;\n config.smatcher_soft.small_lchain = 10;\n config.smatcher_soft.max_lazy = (test->flags & SM_LAZY) ? 10 : 0;\n config.smatcher_soft.long_enough = 10;\n\n if ((ret = xd3_config_stream (stream, & config))) { return ret; }\n if ((ret = xd3_encode_init_full (stream))) { return ret; }\n\n xd3_avail_input (stream, (uint8_t*)test->input, len);\n\n if ((ret = stream->smatcher.string_match (stream))) { return ret; }\n\n *rptr = 0;\n while (! xd3_rlist_empty (& stream->iopt_used))\n\t{\n\t xd3_rinst *inst = xd3_rlist_pop_front (& stream->iopt_used);\n\n\t switch (inst->type)\n\t {\n\t case XD3_RUN: *rptr++ = 'R'; break;\n\t case XD3_CPY: *rptr++ = 'C'; break;\n\t default: CHECK(0);\n\t }\n\n\t snprintf_func (rptr, rbuf+TESTBUFSIZE-rptr, \"%d/%d\", \n\t\t\t inst->pos, inst->size);\n\t rptr += strlen (rptr);\n\n\t if (inst->type == XD3_CPY)\n\t {\n\t *rptr++ = '@';\n\t snprintf_func (rptr, rbuf+TESTBUFSIZE-rptr, \"%\"Q\"d\", inst->addr);\n\t rptr += strlen (rptr);\n\t }\n\n\t *rptr++ = ' ';\n\n\t xd3_rlist_push_back (& stream->iopt_free, inst);\n\t}\n\n if (rptr != rbuf)\n\t{\n\t rptr -= 1; *rptr = 0;\n\t}\n\n if (strcmp (rbuf, test->result) != 0)\n\t{\n\t XPR(NT \"test %u: expected %s: got %s\", i, test->result, rbuf);\n\t stream->msg = \"wrong result\";\n\t return XD3_INTERNAL;\n\t}\n }\n\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-9765", "cwe_id": "CWE-119" }, { "id": 1747, "func": "test_string_matching (xd3_stream *stream, int ignore)\n{\n usize_t i;\n int ret;\n xd3_config config;\n char rbuf[TESTBUFSIZE];\n\n for (i = 0; i < SIZEOF_ARRAY (match_tests); i += 1)\n {\n const string_match_test *test = & match_tests[i];\n char *rptr = rbuf;\n usize_t len = (usize_t) strlen (test->input);\n\n xd3_free_stream (stream);\n xd3_init_config (& config, 0);\n\n config.smatch_cfg = XD3_SMATCH_SOFT;\n config.smatcher_soft.large_look = 4;\n config.smatcher_soft.large_step = 4;\n config.smatcher_soft.small_look = 4;\n config.smatcher_soft.small_chain = 10;\n config.smatcher_soft.small_lchain = 10;\n config.smatcher_soft.max_lazy = (test->flags & SM_LAZY) ? 10 : 0;\n config.smatcher_soft.long_enough = 10;\n\n if ((ret = xd3_config_stream (stream, & config))) { return ret; }\n if ((ret = xd3_encode_init_full (stream))) { return ret; }\n\n xd3_avail_input (stream, (uint8_t*)test->input, len);\n\n if ((ret = stream->smatcher.string_match (stream))) { return ret; }\n\n *rptr = 0;\n while (! xd3_rlist_empty (& stream->iopt_used))\n\t{\n\t xd3_rinst *inst = xd3_rlist_pop_front (& stream->iopt_used);\n\n\t switch (inst->type)\n\t {\n\t case XD3_RUN: *rptr++ = 'R'; break;\n\t case XD3_CPY: *rptr++ = 'C'; break;\n\t default: CHECK(0);\n\t }\n\n\t snprintf_func (rptr, rbuf+TESTBUFSIZE-rptr, \"%d/%d\",\n\t\t\t inst->pos, inst->size);\n\t rptr += strlen (rptr);\n\n\t if (inst->type == XD3_CPY)\n\t {\n\t *rptr++ = '@';\n\t snprintf_func (rptr, rbuf+TESTBUFSIZE-rptr, \"%\"Q\"d\", inst->addr);\n\t rptr += strlen (rptr);\n\t }\n\n\t *rptr++ = ' ';\n\n\t xd3_rlist_push_back (& stream->iopt_free, inst);\n\t}\n\n if (rptr != rbuf)\n\t{\n\t rptr -= 1; *rptr = 0;\n\t}\n\n if (strcmp (rbuf, test->result) != 0)\n\t{\n\t XPR(NT \"test %u: expected %s: got %s\", i, test->result, rbuf);\n\t stream->msg = \"wrong result\";\n\t return XD3_INTERNAL;\n\t}\n }\n\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-9765", "cwe_id": "CWE-119" }, { "id": 2081, "func": "TfLiteStatus NonMaxSuppressionMultiClass(TfLiteContext* context,\n TfLiteNode* node, OpData* op_data) {\n // Get the input tensors\n const TfLiteTensor* input_box_encodings =\n GetInput(context, node, kInputTensorBoxEncodings);\n const TfLiteTensor* input_class_predictions =\n GetInput(context, node, kInputTensorClassPredictions);\n const int num_boxes = input_box_encodings->dims->data[1];\n const int num_classes = op_data->num_classes;\n TF_LITE_ENSURE_EQ(context, input_class_predictions->dims->data[0],\n kBatchSize);\n TF_LITE_ENSURE_EQ(context, input_class_predictions->dims->data[1], num_boxes);\n const int num_classes_with_background =\n input_class_predictions->dims->data[2];\n\n TF_LITE_ENSURE(context, (num_classes_with_background - num_classes <= 1));\n TF_LITE_ENSURE(context, (num_classes_with_background >= num_classes));\n\n const TfLiteTensor* scores;\n switch (input_class_predictions->type) {\n case kTfLiteUInt8: {\n TfLiteTensor* temporary_scores = &context->tensors[op_data->scores_index];\n DequantizeClassPredictions(input_class_predictions, num_boxes,\n num_classes_with_background, temporary_scores);\n scores = temporary_scores;\n } break;\n case kTfLiteFloat32:\n scores = input_class_predictions;\n break;\n default:\n // Unsupported type.\n return kTfLiteError;\n }\n if (op_data->use_regular_non_max_suppression)\n TF_LITE_ENSURE_STATUS(NonMaxSuppressionMultiClassRegularHelper(\n context, node, op_data, GetTensorData(scores)));\n else\n TF_LITE_ENSURE_STATUS(NonMaxSuppressionMultiClassFastHelper(\n context, node, op_data, GetTensorData(scores)));\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2081, "func": "TfLiteStatus NonMaxSuppressionMultiClass(TfLiteContext* context,\n TfLiteNode* node, OpData* op_data) {\n // Get the input tensors\n const TfLiteTensor* input_box_encodings;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensorBoxEncodings,\n &input_box_encodings));\n const TfLiteTensor* input_class_predictions;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensorClassPredictions,\n &input_class_predictions));\n const int num_boxes = input_box_encodings->dims->data[1];\n const int num_classes = op_data->num_classes;\n TF_LITE_ENSURE_EQ(context, input_class_predictions->dims->data[0],\n kBatchSize);\n TF_LITE_ENSURE_EQ(context, input_class_predictions->dims->data[1], num_boxes);\n const int num_classes_with_background =\n input_class_predictions->dims->data[2];\n\n TF_LITE_ENSURE(context, (num_classes_with_background - num_classes <= 1));\n TF_LITE_ENSURE(context, (num_classes_with_background >= num_classes));\n\n const TfLiteTensor* scores;\n switch (input_class_predictions->type) {\n case kTfLiteUInt8: {\n TfLiteTensor* temporary_scores = &context->tensors[op_data->scores_index];\n DequantizeClassPredictions(input_class_predictions, num_boxes,\n num_classes_with_background, temporary_scores);\n scores = temporary_scores;\n } break;\n case kTfLiteFloat32:\n scores = input_class_predictions;\n break;\n default:\n // Unsupported type.\n return kTfLiteError;\n }\n if (op_data->use_regular_non_max_suppression)\n TF_LITE_ENSURE_STATUS(NonMaxSuppressionMultiClassRegularHelper(\n context, node, op_data, GetTensorData(scores)));\n else\n TF_LITE_ENSURE_STATUS(NonMaxSuppressionMultiClassFastHelper(\n context, node, op_data, GetTensorData(scores)));\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2783, "func": "static Jsi_RC jsi_ArrayPopCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,\n Jsi_Value **ret, Jsi_Func *funcPtr)\n{\n if (_this->vt != JSI_VT_OBJECT || !Jsi_ObjIsArray(interp, _this->d.obj)) {\n Jsi_ValueMakeNumber(interp, ret, 0);\n return JSI_OK;\n }\n Jsi_Value *v;\n Jsi_Obj *obj;\n obj = _this->d.obj;\n int i = Jsi_ObjGetLength(interp, obj) - 1;\n\n if (i < 0) {\n Jsi_ValueMakeUndef(interp, ret);\n return JSI_OK;\n }\n \n if (obj->arr) {\n if ((v = obj->arr[i])) {\n obj->arr[i] = NULL;\n obj->arrCnt--;\n }\n } else {\n v = Jsi_ValueArrayIndex(interp, _this, i);\n }\n if (v) {\n Jsi_DecrRefCount(interp, *ret);\n *ret = v;\n }\n Jsi_ObjSetLength(interp, obj, i);\n return JSI_OK;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-22875", "cwe_id": "CWE-190" }, { "id": 2783, "func": "static Jsi_RC jsi_ArrayPopCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,\n Jsi_Value **ret, Jsi_Func *funcPtr)\n{\n if (_this->vt != JSI_VT_OBJECT || !Jsi_ObjIsArray(interp, _this->d.obj)) {\n Jsi_ValueMakeNumber(interp, ret, 0);\n return JSI_OK;\n }\n Jsi_Value *v;\n Jsi_Obj *obj;\n obj = _this->d.obj;\n int i = jsi_SizeOfArray(interp, obj) - 1;\n\n if (i < 0) {\n Jsi_ValueMakeUndef(interp, ret);\n return JSI_OK;\n }\n \n if (obj->arr) {\n if ((v = obj->arr[i])) {\n obj->arr[i] = NULL;\n obj->arrCnt--;\n }\n } else {\n v = Jsi_ValueArrayIndex(interp, _this, i);\n }\n if (v) {\n Jsi_DecrRefCount(interp, *ret);\n *ret = v;\n }\n Jsi_ObjSetLength(interp, obj, i);\n return JSI_OK;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-22875", "cwe_id": "CWE-190" }, { "id": 1641, "func": "Http::FilterMetadataStatus Context::onResponseMetadata() {\n if (!wasm_->onResponseMetadata_) {\n return Http::FilterMetadataStatus::Continue;\n }\n if (wasm_->onResponseMetadata_(this, id_).u64_ == 0) {\n return Http::FilterMetadataStatus::Continue;\n }\n return Http::FilterMetadataStatus::Continue; // This is currently the only return code.\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-10739", "cwe_id": "CWE-476" }, { "id": 1641, "func": "Http::FilterMetadataStatus Context::onResponseMetadata() {\n if (!in_vm_context_created_ || !wasm_->onResponseMetadata_) {\n return Http::FilterMetadataStatus::Continue;\n }\n if (wasm_->onResponseMetadata_(this, id_).u64_ == 0) {\n return Http::FilterMetadataStatus::Continue;\n }\n return Http::FilterMetadataStatus::Continue; // This is currently the only return code.\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-10739", "cwe_id": "CWE-476" }, { "id": 1370, "func": "void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, int x0, int y0, int w0, int h0)\n{\n int x,y,w,v,z;\n int x1, y1, w1, h1;\n int bitsPerPixel, bytesPerPixel, bytesPerLine, areaX, areaY, area2;\n unsigned char *srcptr, *dstptr;\n\n /* Nothing to do!!! */\n if (screen==ptr) return;\n\n x1 = x0;\n y1 = y0;\n w1 = w0;\n h1 = h0;\n\n rfbScaledCorrection(screen, ptr, &x1, &y1, &w1, &h1, \"rfbScaledScreenUpdateRect\");\n x0 = ScaleX(ptr, screen, x1);\n y0 = ScaleY(ptr, screen, y1);\n w0 = ScaleX(ptr, screen, w1);\n h0 = ScaleY(ptr, screen, h1);\n\n bitsPerPixel = screen->bitsPerPixel;\n bytesPerPixel = bitsPerPixel / 8;\n bytesPerLine = w1 * bytesPerPixel;\n srcptr = (unsigned char *)(screen->frameBuffer +\n (y0 * screen->paddedWidthInBytes + x0 * bytesPerPixel));\n dstptr = (unsigned char *)(ptr->frameBuffer +\n ( y1 * ptr->paddedWidthInBytes + x1 * bytesPerPixel));\n /* The area of the source framebuffer for each destination pixel */\n areaX = ScaleX(ptr,screen,1);\n areaY = ScaleY(ptr,screen,1);\n area2 = areaX*areaY;\n\n\n /* Ensure that we do not go out of bounds */\n if ((x1+w1) > (ptr->width))\n {\n if (x1==0) w1=ptr->width; else x1 = ptr->width - w1;\n }\n if ((y1+h1) > (ptr->height))\n {\n if (y1==0) h1=ptr->height; else y1 = ptr->height - h1;\n }\n /*\n * rfbLog(\"rfbScaledScreenUpdateRect(%dXx%dY-%dWx%dH -> %dXx%dY-%dWx%dH <%dx%d>) {%dWx%dH -> %dWx%dH} 0x%p\\n\",\n * x0, y0, w0, h0, x1, y1, w1, h1, areaX, areaY,\n * screen->width, screen->height, ptr->width, ptr->height, ptr->frameBuffer);\n */\n\n if (screen->serverFormat.trueColour) { /* Blend neighbouring pixels together */\n unsigned char *srcptr2;\n unsigned long pixel_value, red, green, blue;\n unsigned int redShift = screen->serverFormat.redShift;\n unsigned int greenShift = screen->serverFormat.greenShift;\n unsigned int blueShift = screen->serverFormat.blueShift;\n unsigned long redMax = screen->serverFormat.redMax;\n unsigned long greenMax = screen->serverFormat.greenMax;\n unsigned long blueMax = screen->serverFormat.blueMax;\n\n /* for each *destination* pixel... */\n for (y = 0; y < h1; y++) {\n for (x = 0; x < w1; x++) {\n red = green = blue = 0;\n /* Get the totals for rgb from the source grid... */\n for (w = 0; w < areaX; w++) {\n for (v = 0; v < areaY; v++) {\n srcptr2 = &srcptr[(((x * areaX) + w) * bytesPerPixel) +\n (v * screen->paddedWidthInBytes)];\n pixel_value = 0;\n\n\n switch (bytesPerPixel) {\n case 4: pixel_value = *((unsigned int *)srcptr2); break;\n case 2: pixel_value = *((unsigned short *)srcptr2); break;\n case 1: pixel_value = *((unsigned char *)srcptr2); break;\n default:\n /* fixme: endianness problem? */\n for (z = 0; z < bytesPerPixel; z++)\n pixel_value += (srcptr2[z] << (8 * z));\n break;\n }\n /*\n srcptr2 += bytesPerPixel;\n */\n\n red += ((pixel_value >> redShift) & redMax);\n green += ((pixel_value >> greenShift) & greenMax);\n blue += ((pixel_value >> blueShift) & blueMax);\n\n }\n }\n /* We now have a total for all of the colors, find the average! */\n red /= area2;\n green /= area2;\n blue /= area2;\n /* Stuff the new value back into memory */\n pixel_value = ((red & redMax) << redShift) | ((green & greenMax) << greenShift) | ((blue & blueMax) << blueShift);\n\n switch (bytesPerPixel) {\n case 4: *((unsigned int *)dstptr) = (unsigned int) pixel_value; break;\n case 2: *((unsigned short *)dstptr) = (unsigned short) pixel_value; break;\n case 1: *((unsigned char *)dstptr) = (unsigned char) pixel_value; break;\n default:\n /* fixme: endianness problem? */\n for (z = 0; z < bytesPerPixel; z++)\n dstptr[z]=(pixel_value >> (8 * z)) & 0xff;\n break;\n }\n dstptr += bytesPerPixel;\n }\n srcptr += (screen->paddedWidthInBytes * areaY);\n dstptr += (ptr->paddedWidthInBytes - bytesPerLine);\n }\n } else\n { /* Not truecolour, so we can't blend. Just use the top-left pixel instead */\n for (y = y1; y < (y1+h1); y++) {\n for (x = x1; x < (x1+w1); x++)\n memcpy (&ptr->frameBuffer[(y *ptr->paddedWidthInBytes) + (x * bytesPerPixel)],\n &screen->frameBuffer[(y * areaY * screen->paddedWidthInBytes) + (x *areaX * bytesPerPixel)], bytesPerPixel);\n }\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-14401", "cwe_id": "CWE-190" }, { "id": 1370, "func": "void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, int x0, int y0, int w0, int h0)\n{\n int x,y,w,v,z;\n int x1, y1, w1, h1;\n int bitsPerPixel, bytesPerPixel, bytesPerLine, areaX, areaY, area2;\n unsigned char *srcptr, *dstptr;\n\n /* Nothing to do!!! */\n if (screen==ptr) return;\n\n x1 = x0;\n y1 = y0;\n w1 = w0;\n h1 = h0;\n\n rfbScaledCorrection(screen, ptr, &x1, &y1, &w1, &h1, \"rfbScaledScreenUpdateRect\");\n x0 = ScaleX(ptr, screen, x1);\n y0 = ScaleY(ptr, screen, y1);\n w0 = ScaleX(ptr, screen, w1);\n h0 = ScaleY(ptr, screen, h1);\n\n bitsPerPixel = screen->bitsPerPixel;\n bytesPerPixel = bitsPerPixel / 8;\n bytesPerLine = w1 * bytesPerPixel;\n srcptr = (unsigned char *)(screen->frameBuffer +\n (y0 * screen->paddedWidthInBytes + x0 * bytesPerPixel));\n dstptr = (unsigned char *)(ptr->frameBuffer +\n ( y1 * ptr->paddedWidthInBytes + x1 * bytesPerPixel));\n /* The area of the source framebuffer for each destination pixel */\n areaX = ScaleX(ptr,screen,1);\n areaY = ScaleY(ptr,screen,1);\n area2 = areaX*areaY;\n\n\n /* Ensure that we do not go out of bounds */\n if ((x1+w1) > (ptr->width))\n {\n if (x1==0) w1=ptr->width; else x1 = ptr->width - w1;\n }\n if ((y1+h1) > (ptr->height))\n {\n if (y1==0) h1=ptr->height; else y1 = ptr->height - h1;\n }\n /*\n * rfbLog(\"rfbScaledScreenUpdateRect(%dXx%dY-%dWx%dH -> %dXx%dY-%dWx%dH <%dx%d>) {%dWx%dH -> %dWx%dH} 0x%p\\n\",\n * x0, y0, w0, h0, x1, y1, w1, h1, areaX, areaY,\n * screen->width, screen->height, ptr->width, ptr->height, ptr->frameBuffer);\n */\n\n if (screen->serverFormat.trueColour) { /* Blend neighbouring pixels together */\n unsigned char *srcptr2;\n unsigned long pixel_value, red, green, blue;\n unsigned int redShift = screen->serverFormat.redShift;\n unsigned int greenShift = screen->serverFormat.greenShift;\n unsigned int blueShift = screen->serverFormat.blueShift;\n unsigned long redMax = screen->serverFormat.redMax;\n unsigned long greenMax = screen->serverFormat.greenMax;\n unsigned long blueMax = screen->serverFormat.blueMax;\n\n /* for each *destination* pixel... */\n for (y = 0; y < h1; y++) {\n for (x = 0; x < w1; x++) {\n red = green = blue = 0;\n /* Get the totals for rgb from the source grid... */\n for (w = 0; w < areaX; w++) {\n for (v = 0; v < areaY; v++) {\n srcptr2 = &srcptr[(((x * areaX) + w) * bytesPerPixel) +\n (v * screen->paddedWidthInBytes)];\n pixel_value = 0;\n\n\n switch (bytesPerPixel) {\n case 4: pixel_value = *((unsigned int *)srcptr2); break;\n case 2: pixel_value = *((unsigned short *)srcptr2); break;\n case 1: pixel_value = *((unsigned char *)srcptr2); break;\n default:\n /* fixme: endianness problem? */\n for (z = 0; z < bytesPerPixel; z++)\n pixel_value += ((unsigned long)srcptr2[z] << (8 * z));\n break;\n }\n /*\n srcptr2 += bytesPerPixel;\n */\n\n red += ((pixel_value >> redShift) & redMax);\n green += ((pixel_value >> greenShift) & greenMax);\n blue += ((pixel_value >> blueShift) & blueMax);\n\n }\n }\n /* We now have a total for all of the colors, find the average! */\n red /= area2;\n green /= area2;\n blue /= area2;\n /* Stuff the new value back into memory */\n pixel_value = ((red & redMax) << redShift) | ((green & greenMax) << greenShift) | ((blue & blueMax) << blueShift);\n\n switch (bytesPerPixel) {\n case 4: *((unsigned int *)dstptr) = (unsigned int) pixel_value; break;\n case 2: *((unsigned short *)dstptr) = (unsigned short) pixel_value; break;\n case 1: *((unsigned char *)dstptr) = (unsigned char) pixel_value; break;\n default:\n /* fixme: endianness problem? */\n for (z = 0; z < bytesPerPixel; z++)\n dstptr[z]=(pixel_value >> (8 * z)) & 0xff;\n break;\n }\n dstptr += bytesPerPixel;\n }\n srcptr += (screen->paddedWidthInBytes * areaY);\n dstptr += (ptr->paddedWidthInBytes - bytesPerLine);\n }\n } else\n { /* Not truecolour, so we can't blend. Just use the top-left pixel instead */\n for (y = y1; y < (y1+h1); y++) {\n for (x = x1; x < (x1+w1); x++)\n memcpy (&ptr->frameBuffer[(y *ptr->paddedWidthInBytes) + (x * bytesPerPixel)],\n &screen->frameBuffer[(y * areaY * screen->paddedWidthInBytes) + (x *areaX * bytesPerPixel)], bytesPerPixel);\n }\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-14401", "cwe_id": "CWE-190" }, { "id": 716, "func": "int jpc_tsfb_synthesize(jpc_tsfb_t *tsfb, jas_seq2d_t *a)\n{\n\treturn (tsfb->numlvls > 0) ? jpc_tsfb_synthesize2(tsfb,\n\t jas_seq2d_getref(a, jas_seq2d_xstart(a), jas_seq2d_ystart(a)),\n\t jas_seq2d_xstart(a), jas_seq2d_ystart(a), jas_seq2d_width(a),\n\t jas_seq2d_height(a), jas_seq2d_rowstep(a), tsfb->numlvls - 1) : 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10248", "cwe_id": "CWE-476" }, { "id": 716, "func": "int jpc_tsfb_synthesize(jpc_tsfb_t *tsfb, jas_seq2d_t *a)\n{\n\treturn (tsfb->numlvls > 0 && jas_seq2d_size(a)) ?\n\t jpc_tsfb_synthesize2(tsfb,\n\t jas_seq2d_getref(a, jas_seq2d_xstart(a), jas_seq2d_ystart(a)),\n\t jas_seq2d_xstart(a), jas_seq2d_ystart(a), jas_seq2d_width(a),\n\t jas_seq2d_height(a), jas_seq2d_rowstep(a), tsfb->numlvls - 1) : 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10248", "cwe_id": "CWE-476" }, { "id": 1915, "func": "static bool check_underflow(const struct ipt_entry *e)\n{\n\tconst struct xt_entry_target *t;\n\tunsigned int verdict;\n\n\tif (!unconditional(&e->ip))\n\t\treturn false;\n\tt = ipt_get_target_c(e);\n\tif (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0)\n\t\treturn false;\n\tverdict = ((struct xt_standard_target *)t)->verdict;\n\tverdict = -verdict - 1;\n\treturn verdict == NF_DROP || verdict == NF_ACCEPT;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-3134", "cwe_id": "CWE-119" }, { "id": 1915, "func": "static bool check_underflow(const struct ipt_entry *e)\n{\n\tconst struct xt_entry_target *t;\n\tunsigned int verdict;\n\n\tif (!unconditional(e))\n\t\treturn false;\n\tt = ipt_get_target_c(e);\n\tif (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0)\n\t\treturn false;\n\tverdict = ((struct xt_standard_target *)t)->verdict;\n\tverdict = -verdict - 1;\n\treturn verdict == NF_DROP || verdict == NF_ACCEPT;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-3134", "cwe_id": "CWE-119" }, { "id": 903, "func": "static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, size_t len)\n{\n\tstruct sk_buff *skb;\n\tint rc;\n\tstruct l2tp_ip_sock *lsa = l2tp_ip_sk(sk);\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct ip_options *opt = inet->opt;\n\tstruct rtable *rt = NULL;\n\tint connected = 0;\n\t__be32 daddr;\n\n\tif (sock_flag(sk, SOCK_DEAD))\n\t\treturn -ENOTCONN;\n\n\t/* Get and verify the address. */\n\tif (msg->msg_name) {\n\t\tstruct sockaddr_l2tpip *lip = (struct sockaddr_l2tpip *) msg->msg_name;\n\t\tif (msg->msg_namelen < sizeof(*lip))\n\t\t\treturn -EINVAL;\n\n\t\tif (lip->l2tp_family != AF_INET) {\n\t\t\tif (lip->l2tp_family != AF_UNSPEC)\n\t\t\t\treturn -EAFNOSUPPORT;\n\t\t}\n\n\t\tdaddr = lip->l2tp_addr.s_addr;\n\t} else {\n\t\tif (sk->sk_state != TCP_ESTABLISHED)\n\t\t\treturn -EDESTADDRREQ;\n\n\t\tdaddr = inet->inet_daddr;\n\t\tconnected = 1;\n\t}\n\n\t/* Allocate a socket buffer */\n\trc = -ENOMEM;\n\tskb = sock_wmalloc(sk, 2 + NET_SKB_PAD + sizeof(struct iphdr) +\n\t\t\t 4 + len, 0, GFP_KERNEL);\n\tif (!skb)\n\t\tgoto error;\n\n\t/* Reserve space for headers, putting IP header on 4-byte boundary. */\n\tskb_reserve(skb, 2 + NET_SKB_PAD);\n\tskb_reset_network_header(skb);\n\tskb_reserve(skb, sizeof(struct iphdr));\n\tskb_reset_transport_header(skb);\n\n\t/* Insert 0 session_id */\n\t*((__be32 *) skb_put(skb, 4)) = 0;\n\n\t/* Copy user data into skb */\n\trc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);\n\tif (rc < 0) {\n\t\tkfree_skb(skb);\n\t\tgoto error;\n\t}\n\n\tif (connected)\n\t\trt = (struct rtable *) __sk_dst_check(sk, 0);\n\n\tif (rt == NULL) {\n\t\t/* Use correct destination address if we have options. */\n\t\tif (opt && opt->srr)\n\t\t\tdaddr = opt->faddr;\n\n\t\t/* If this fails, retransmit mechanism of transport layer will\n\t\t * keep trying until route appears or the connection times\n\t\t * itself out.\n\t\t */\n\t\trt = ip_route_output_ports(sock_net(sk), sk,\n\t\t\t\t\t daddr, inet->inet_saddr,\n\t\t\t\t\t inet->inet_dport, inet->inet_sport,\n\t\t\t\t\t sk->sk_protocol, RT_CONN_FLAGS(sk),\n\t\t\t\t\t sk->sk_bound_dev_if);\n\t\tif (IS_ERR(rt))\n\t\t\tgoto no_route;\n\t\tsk_setup_caps(sk, &rt->dst);\n\t}\n\tskb_dst_set(skb, dst_clone(&rt->dst));\n\n\t/* Queue the packet to IP for output */\n\trc = ip_queue_xmit(skb);\n\nerror:\n\t/* Update stats */\n\tif (rc >= 0) {\n\t\tlsa->tx_packets++;\n\t\tlsa->tx_bytes += len;\n\t\trc = len;\n\t} else {\n\t\tlsa->tx_errors++;\n\t}\n\n\treturn rc;\n\nno_route:\n\tIP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);\n\tkfree_skb(skb);\n\treturn -EHOSTUNREACH;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 903, "func": "static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, size_t len)\n{\n\tstruct sk_buff *skb;\n\tint rc;\n\tstruct l2tp_ip_sock *lsa = l2tp_ip_sk(sk);\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct rtable *rt = NULL;\n\tint connected = 0;\n\t__be32 daddr;\n\n\tif (sock_flag(sk, SOCK_DEAD))\n\t\treturn -ENOTCONN;\n\n\t/* Get and verify the address. */\n\tif (msg->msg_name) {\n\t\tstruct sockaddr_l2tpip *lip = (struct sockaddr_l2tpip *) msg->msg_name;\n\t\tif (msg->msg_namelen < sizeof(*lip))\n\t\t\treturn -EINVAL;\n\n\t\tif (lip->l2tp_family != AF_INET) {\n\t\t\tif (lip->l2tp_family != AF_UNSPEC)\n\t\t\t\treturn -EAFNOSUPPORT;\n\t\t}\n\n\t\tdaddr = lip->l2tp_addr.s_addr;\n\t} else {\n\t\tif (sk->sk_state != TCP_ESTABLISHED)\n\t\t\treturn -EDESTADDRREQ;\n\n\t\tdaddr = inet->inet_daddr;\n\t\tconnected = 1;\n\t}\n\n\t/* Allocate a socket buffer */\n\trc = -ENOMEM;\n\tskb = sock_wmalloc(sk, 2 + NET_SKB_PAD + sizeof(struct iphdr) +\n\t\t\t 4 + len, 0, GFP_KERNEL);\n\tif (!skb)\n\t\tgoto error;\n\n\t/* Reserve space for headers, putting IP header on 4-byte boundary. */\n\tskb_reserve(skb, 2 + NET_SKB_PAD);\n\tskb_reset_network_header(skb);\n\tskb_reserve(skb, sizeof(struct iphdr));\n\tskb_reset_transport_header(skb);\n\n\t/* Insert 0 session_id */\n\t*((__be32 *) skb_put(skb, 4)) = 0;\n\n\t/* Copy user data into skb */\n\trc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);\n\tif (rc < 0) {\n\t\tkfree_skb(skb);\n\t\tgoto error;\n\t}\n\n\tif (connected)\n\t\trt = (struct rtable *) __sk_dst_check(sk, 0);\n\n\tif (rt == NULL) {\n\t\tstruct ip_options_rcu *inet_opt;\n\n\t\tinet_opt = rcu_dereference_protected(inet->inet_opt,\n\t\t\t\t\t\t sock_owned_by_user(sk));\n\n\t\t/* Use correct destination address if we have options. */\n\t\tif (inet_opt && inet_opt->opt.srr)\n\t\t\tdaddr = inet_opt->opt.faddr;\n\n\t\t/* If this fails, retransmit mechanism of transport layer will\n\t\t * keep trying until route appears or the connection times\n\t\t * itself out.\n\t\t */\n\t\trt = ip_route_output_ports(sock_net(sk), sk,\n\t\t\t\t\t daddr, inet->inet_saddr,\n\t\t\t\t\t inet->inet_dport, inet->inet_sport,\n\t\t\t\t\t sk->sk_protocol, RT_CONN_FLAGS(sk),\n\t\t\t\t\t sk->sk_bound_dev_if);\n\t\tif (IS_ERR(rt))\n\t\t\tgoto no_route;\n\t\tsk_setup_caps(sk, &rt->dst);\n\t}\n\tskb_dst_set(skb, dst_clone(&rt->dst));\n\n\t/* Queue the packet to IP for output */\n\trc = ip_queue_xmit(skb);\n\nerror:\n\t/* Update stats */\n\tif (rc >= 0) {\n\t\tlsa->tx_packets++;\n\t\tlsa->tx_bytes += len;\n\t\trc = len;\n\t} else {\n\t\tlsa->tx_errors++;\n\t}\n\n\treturn rc;\n\nno_route:\n\tIP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);\n\tkfree_skb(skb);\n\treturn -EHOSTUNREACH;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 222, "func": "static int do_last(struct nameidata *nd,\n\t\t struct file *file, const struct open_flags *op)\n{\n\tstruct dentry *dir = nd->path.dentry;\n\tint open_flag = op->open_flag;\n\tbool will_truncate = (open_flag & O_TRUNC) != 0;\n\tbool got_write = false;\n\tint acc_mode = op->acc_mode;\n\tunsigned seq;\n\tstruct inode *inode;\n\tstruct path path;\n\tint error;\n\n\tnd->flags &= ~LOOKUP_PARENT;\n\tnd->flags |= op->intent;\n\n\tif (nd->last_type != LAST_NORM) {\n\t\terror = handle_dots(nd, nd->last_type);\n\t\tif (unlikely(error))\n\t\t\treturn error;\n\t\tgoto finish_open;\n\t}\n\n\tif (!(open_flag & O_CREAT)) {\n\t\tif (nd->last.name[nd->last.len])\n\t\t\tnd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;\n\t\t/* we _can_ be in RCU mode here */\n\t\terror = lookup_fast(nd, &path, &inode, &seq);\n\t\tif (likely(error > 0))\n\t\t\tgoto finish_lookup;\n\n\t\tif (error < 0)\n\t\t\treturn error;\n\n\t\tBUG_ON(nd->inode != dir->d_inode);\n\t\tBUG_ON(nd->flags & LOOKUP_RCU);\n\t} else {\n\t\t/* create side of things */\n\t\t/*\n\t\t * This will *only* deal with leaving RCU mode - LOOKUP_JUMPED\n\t\t * has been cleared when we got to the last component we are\n\t\t * about to look up\n\t\t */\n\t\terror = complete_walk(nd);\n\t\tif (error)\n\t\t\treturn error;\n\n\t\taudit_inode(nd->name, dir, AUDIT_INODE_PARENT);\n\t\t/* trailing slashes? */\n\t\tif (unlikely(nd->last.name[nd->last.len]))\n\t\t\treturn -EISDIR;\n\t}\n\n\tif (open_flag & (O_CREAT | O_TRUNC | O_WRONLY | O_RDWR)) {\n\t\terror = mnt_want_write(nd->path.mnt);\n\t\tif (!error)\n\t\t\tgot_write = true;\n\t\t/*\n\t\t * do _not_ fail yet - we might not need that or fail with\n\t\t * a different error; let lookup_open() decide; we'll be\n\t\t * dropping this one anyway.\n\t\t */\n\t}\n\tif (open_flag & O_CREAT)\n\t\tinode_lock(dir->d_inode);\n\telse\n\t\tinode_lock_shared(dir->d_inode);\n\terror = lookup_open(nd, &path, file, op, got_write);\n\tif (open_flag & O_CREAT)\n\t\tinode_unlock(dir->d_inode);\n\telse\n\t\tinode_unlock_shared(dir->d_inode);\n\n\tif (error)\n\t\tgoto out;\n\n\tif (file->f_mode & FMODE_OPENED) {\n\t\tif ((file->f_mode & FMODE_CREATED) ||\n\t\t !S_ISREG(file_inode(file)->i_mode))\n\t\t\twill_truncate = false;\n\n\t\taudit_inode(nd->name, file->f_path.dentry, 0);\n\t\tgoto opened;\n\t}\n\n\tif (file->f_mode & FMODE_CREATED) {\n\t\t/* Don't check for write permission, don't truncate */\n\t\topen_flag &= ~O_TRUNC;\n\t\twill_truncate = false;\n\t\tacc_mode = 0;\n\t\tpath_to_nameidata(&path, nd);\n\t\tgoto finish_open_created;\n\t}\n\n\t/*\n\t * If atomic_open() acquired write access it is dropped now due to\n\t * possible mount and symlink following (this might be optimized away if\n\t * necessary...)\n\t */\n\tif (got_write) {\n\t\tmnt_drop_write(nd->path.mnt);\n\t\tgot_write = false;\n\t}\n\n\terror = follow_managed(&path, nd);\n\tif (unlikely(error < 0))\n\t\treturn error;\n\n\t/*\n\t * create/update audit record if it already exists.\n\t */\n\taudit_inode(nd->name, path.dentry, 0);\n\n\tif (unlikely((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT))) {\n\t\tpath_to_nameidata(&path, nd);\n\t\treturn -EEXIST;\n\t}\n\n\tseq = 0;\t/* out of RCU mode, so the value doesn't matter */\n\tinode = d_backing_inode(path.dentry);\nfinish_lookup:\n\terror = step_into(nd, &path, 0, inode, seq);\n\tif (unlikely(error))\n\t\treturn error;\nfinish_open:\n\t/* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */\n\terror = complete_walk(nd);\n\tif (error)\n\t\treturn error;\n\taudit_inode(nd->name, nd->path.dentry, 0);\n\tif (open_flag & O_CREAT) {\n\t\terror = -EISDIR;\n\t\tif (d_is_dir(nd->path.dentry))\n\t\t\tgoto out;\n\t\terror = may_create_in_sticky(dir,\n\t\t\t\t\t d_backing_inode(nd->path.dentry));\n\t\tif (unlikely(error))\n\t\t\tgoto out;\n\t}\n\terror = -ENOTDIR;\n\tif ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry))\n\t\tgoto out;\n\tif (!d_is_reg(nd->path.dentry))\n\t\twill_truncate = false;\n\n\tif (will_truncate) {\n\t\terror = mnt_want_write(nd->path.mnt);\n\t\tif (error)\n\t\t\tgoto out;\n\t\tgot_write = true;\n\t}\nfinish_open_created:\n\terror = may_open(&nd->path, acc_mode, open_flag);\n\tif (error)\n\t\tgoto out;\n\tBUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */\n\terror = vfs_open(&nd->path, file);\n\tif (error)\n\t\tgoto out;\nopened:\n\terror = ima_file_check(file, op->acc_mode);\n\tif (!error && will_truncate)\n\t\terror = handle_truncate(file);\nout:\n\tif (unlikely(error > 0)) {\n\t\tWARN_ON(1);\n\t\terror = -EINVAL;\n\t}\n\tif (got_write)\n\t\tmnt_drop_write(nd->path.mnt);\n\treturn error;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-8428", "cwe_id": "CWE-416" }, { "id": 222, "func": "static int do_last(struct nameidata *nd,\n\t\t struct file *file, const struct open_flags *op)\n{\n\tstruct dentry *dir = nd->path.dentry;\n\tkuid_t dir_uid = dir->d_inode->i_uid;\n\tumode_t dir_mode = dir->d_inode->i_mode;\n\tint open_flag = op->open_flag;\n\tbool will_truncate = (open_flag & O_TRUNC) != 0;\n\tbool got_write = false;\n\tint acc_mode = op->acc_mode;\n\tunsigned seq;\n\tstruct inode *inode;\n\tstruct path path;\n\tint error;\n\n\tnd->flags &= ~LOOKUP_PARENT;\n\tnd->flags |= op->intent;\n\n\tif (nd->last_type != LAST_NORM) {\n\t\terror = handle_dots(nd, nd->last_type);\n\t\tif (unlikely(error))\n\t\t\treturn error;\n\t\tgoto finish_open;\n\t}\n\n\tif (!(open_flag & O_CREAT)) {\n\t\tif (nd->last.name[nd->last.len])\n\t\t\tnd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;\n\t\t/* we _can_ be in RCU mode here */\n\t\terror = lookup_fast(nd, &path, &inode, &seq);\n\t\tif (likely(error > 0))\n\t\t\tgoto finish_lookup;\n\n\t\tif (error < 0)\n\t\t\treturn error;\n\n\t\tBUG_ON(nd->inode != dir->d_inode);\n\t\tBUG_ON(nd->flags & LOOKUP_RCU);\n\t} else {\n\t\t/* create side of things */\n\t\t/*\n\t\t * This will *only* deal with leaving RCU mode - LOOKUP_JUMPED\n\t\t * has been cleared when we got to the last component we are\n\t\t * about to look up\n\t\t */\n\t\terror = complete_walk(nd);\n\t\tif (error)\n\t\t\treturn error;\n\n\t\taudit_inode(nd->name, dir, AUDIT_INODE_PARENT);\n\t\t/* trailing slashes? */\n\t\tif (unlikely(nd->last.name[nd->last.len]))\n\t\t\treturn -EISDIR;\n\t}\n\n\tif (open_flag & (O_CREAT | O_TRUNC | O_WRONLY | O_RDWR)) {\n\t\terror = mnt_want_write(nd->path.mnt);\n\t\tif (!error)\n\t\t\tgot_write = true;\n\t\t/*\n\t\t * do _not_ fail yet - we might not need that or fail with\n\t\t * a different error; let lookup_open() decide; we'll be\n\t\t * dropping this one anyway.\n\t\t */\n\t}\n\tif (open_flag & O_CREAT)\n\t\tinode_lock(dir->d_inode);\n\telse\n\t\tinode_lock_shared(dir->d_inode);\n\terror = lookup_open(nd, &path, file, op, got_write);\n\tif (open_flag & O_CREAT)\n\t\tinode_unlock(dir->d_inode);\n\telse\n\t\tinode_unlock_shared(dir->d_inode);\n\n\tif (error)\n\t\tgoto out;\n\n\tif (file->f_mode & FMODE_OPENED) {\n\t\tif ((file->f_mode & FMODE_CREATED) ||\n\t\t !S_ISREG(file_inode(file)->i_mode))\n\t\t\twill_truncate = false;\n\n\t\taudit_inode(nd->name, file->f_path.dentry, 0);\n\t\tgoto opened;\n\t}\n\n\tif (file->f_mode & FMODE_CREATED) {\n\t\t/* Don't check for write permission, don't truncate */\n\t\topen_flag &= ~O_TRUNC;\n\t\twill_truncate = false;\n\t\tacc_mode = 0;\n\t\tpath_to_nameidata(&path, nd);\n\t\tgoto finish_open_created;\n\t}\n\n\t/*\n\t * If atomic_open() acquired write access it is dropped now due to\n\t * possible mount and symlink following (this might be optimized away if\n\t * necessary...)\n\t */\n\tif (got_write) {\n\t\tmnt_drop_write(nd->path.mnt);\n\t\tgot_write = false;\n\t}\n\n\terror = follow_managed(&path, nd);\n\tif (unlikely(error < 0))\n\t\treturn error;\n\n\t/*\n\t * create/update audit record if it already exists.\n\t */\n\taudit_inode(nd->name, path.dentry, 0);\n\n\tif (unlikely((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT))) {\n\t\tpath_to_nameidata(&path, nd);\n\t\treturn -EEXIST;\n\t}\n\n\tseq = 0;\t/* out of RCU mode, so the value doesn't matter */\n\tinode = d_backing_inode(path.dentry);\nfinish_lookup:\n\terror = step_into(nd, &path, 0, inode, seq);\n\tif (unlikely(error))\n\t\treturn error;\nfinish_open:\n\t/* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */\n\terror = complete_walk(nd);\n\tif (error)\n\t\treturn error;\n\taudit_inode(nd->name, nd->path.dentry, 0);\n\tif (open_flag & O_CREAT) {\n\t\terror = -EISDIR;\n\t\tif (d_is_dir(nd->path.dentry))\n\t\t\tgoto out;\n\t\terror = may_create_in_sticky(dir_mode, dir_uid,\n\t\t\t\t\t d_backing_inode(nd->path.dentry));\n\t\tif (unlikely(error))\n\t\t\tgoto out;\n\t}\n\terror = -ENOTDIR;\n\tif ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry))\n\t\tgoto out;\n\tif (!d_is_reg(nd->path.dentry))\n\t\twill_truncate = false;\n\n\tif (will_truncate) {\n\t\terror = mnt_want_write(nd->path.mnt);\n\t\tif (error)\n\t\t\tgoto out;\n\t\tgot_write = true;\n\t}\nfinish_open_created:\n\terror = may_open(&nd->path, acc_mode, open_flag);\n\tif (error)\n\t\tgoto out;\n\tBUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */\n\terror = vfs_open(&nd->path, file);\n\tif (error)\n\t\tgoto out;\nopened:\n\terror = ima_file_check(file, op->acc_mode);\n\tif (!error && will_truncate)\n\t\terror = handle_truncate(file);\nout:\n\tif (unlikely(error > 0)) {\n\t\tWARN_ON(1);\n\t\terror = -EINVAL;\n\t}\n\tif (got_write)\n\t\tmnt_drop_write(nd->path.mnt);\n\treturn error;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-8428", "cwe_id": "CWE-416" }, { "id": 671, "func": "sc_oberthur_read_file(struct sc_pkcs15_card *p15card, const char *in_path,\n\t\tunsigned char **out, size_t *out_len,\n\t\tint verify_pin)\n{\n\tstruct sc_context *ctx = p15card->card->ctx;\n\tstruct sc_card *card = p15card->card;\n\tstruct sc_file *file = NULL;\n\tstruct sc_path path;\n\tsize_t sz;\n\tint rv;\n\n\tLOG_FUNC_CALLED(ctx);\n\tif (!in_path || !out || !out_len)\n\t\tLOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, \"Cannot read oberthur file\");\n\n\tsc_log(ctx, \"read file '%s'; verify_pin:%i\", in_path, verify_pin);\n\n\t*out = NULL;\n\t*out_len = 0;\n\n\tsc_format_path(in_path, &path);\n\trv = sc_select_file(card, &path, &file);\n\tif (rv != SC_SUCCESS) {\n\t\tsc_file_free(file);\n\t\tLOG_TEST_RET(ctx, rv, \"Cannot select oberthur file to read\");\n\t}\n\n\tif (file->ef_structure == SC_FILE_EF_TRANSPARENT)\n\t\tsz = file->size;\n\telse\n\t\tsz = (file->record_length + 2) * file->record_count;\n\n\t*out = calloc(sz, 1);\n\tif (*out == NULL) {\n\t\tsc_file_free(file);\n\t\tLOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, \"Cannot read oberthur file\");\n\t}\n\n\tif (file->ef_structure == SC_FILE_EF_TRANSPARENT) {\n\t\trv = sc_read_binary(card, 0, *out, sz, 0);\n\t}\n\telse\t{\n\t\tint rec;\n\t\tint offs = 0;\n\t\tint rec_len = file->record_length;\n\n\t\tfor (rec = 1; ; rec++) {\n\t\t\trv = sc_read_record(card, rec, *out + offs + 2, rec_len, SC_RECORD_BY_REC_NR);\n\t\t\tif (rv == SC_ERROR_RECORD_NOT_FOUND) {\n\t\t\t\trv = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (rv < 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\trec_len = rv;\n\n\t\t\t*(*out + offs) = 'R';\n\t\t\t*(*out + offs + 1) = rv;\n\n\t\t\toffs += rv + 2;\n\t\t}\n\n\t\tsz = offs;\n\t}\n\n\tsc_log(ctx, \"read oberthur file result %i\", rv);\n\tif (verify_pin && rv == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {\n\t\tstruct sc_pkcs15_object *objs[0x10], *pin_obj = NULL;\n\t\tconst struct sc_acl_entry *acl = sc_file_get_acl_entry(file, SC_AC_OP_READ);\n\t\tint ii;\n\n\t\trv = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 0x10);\n\t\tif (rv != SC_SUCCESS) {\n\t\t\tsc_file_free(file);\n\t\t\tLOG_TEST_RET(ctx, rv, \"Cannot read oberthur file: get AUTH objects error\");\n\t\t}\n\n\t\tfor (ii=0; iidata;\n\t\t\tsc_log(ctx, \"compare PIN/ACL refs:%i/%i, method:%i/%i\",\n\t\t\t\t\tauth_info->attrs.pin.reference, acl->key_ref, auth_info->auth_method, acl->method);\n\t\t\tif (auth_info->attrs.pin.reference == (int)acl->key_ref && auth_info->auth_method == (unsigned)acl->method) {\n\t\t\t\tpin_obj = objs[ii];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!pin_obj || !pin_obj->content.value) {\n\t\t\trv = SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;\n\t\t}\n\t\telse {\n\t\t\trv = sc_pkcs15_verify_pin(p15card, pin_obj, pin_obj->content.value, pin_obj->content.len);\n\t\t\tif (!rv)\n\t\t\t\trv = sc_oberthur_read_file(p15card, in_path, out, out_len, 0);\n\t\t}\n\t};\n\n\tsc_file_free(file);\n\n\tif (rv < 0) {\n\t\tfree(*out);\n\t\t*out = NULL;\n\t\t*out_len = 0;\n\t}\n\n\t*out_len = sz;\n\n\tLOG_FUNC_RETURN(ctx, rv);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-26570", "cwe_id": "CWE-787" }, { "id": 671, "func": "sc_oberthur_read_file(struct sc_pkcs15_card *p15card, const char *in_path,\n\t\tunsigned char **out, size_t *out_len,\n\t\tint verify_pin)\n{\n\tstruct sc_context *ctx = p15card->card->ctx;\n\tstruct sc_card *card = p15card->card;\n\tstruct sc_file *file = NULL;\n\tstruct sc_path path;\n\tsize_t sz;\n\tint rv;\n\n\tLOG_FUNC_CALLED(ctx);\n\tif (!in_path || !out || !out_len)\n\t\tLOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, \"Cannot read oberthur file\");\n\n\tsc_log(ctx, \"read file '%s'; verify_pin:%i\", in_path, verify_pin);\n\n\t*out = NULL;\n\t*out_len = 0;\n\n\tsc_format_path(in_path, &path);\n\trv = sc_select_file(card, &path, &file);\n\tif (rv != SC_SUCCESS) {\n\t\tsc_file_free(file);\n\t\tLOG_TEST_RET(ctx, rv, \"Cannot select oberthur file to read\");\n\t}\n\n\tif (file->ef_structure == SC_FILE_EF_TRANSPARENT)\n\t\tsz = file->size;\n\telse\n\t\tsz = (file->record_length + 2) * file->record_count;\n\n\t*out = calloc(sz, 1);\n\tif (*out == NULL) {\n\t\tsc_file_free(file);\n\t\tLOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, \"Cannot read oberthur file\");\n\t}\n\n\tif (file->ef_structure == SC_FILE_EF_TRANSPARENT) {\n\t\trv = sc_read_binary(card, 0, *out, sz, 0);\n\t}\n\telse\t{\n\t\tsize_t rec;\n\t\tsize_t offs = 0;\n\t\tsize_t rec_len = file->record_length;\n\n\t\tfor (rec = 1; ; rec++) {\n\t\t\tif (rec > file->record_count) {\n\t\t\t\trv = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\trv = sc_read_record(card, rec, *out + offs + 2, rec_len, SC_RECORD_BY_REC_NR);\n\t\t\tif (rv == SC_ERROR_RECORD_NOT_FOUND) {\n\t\t\t\trv = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (rv < 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\trec_len = rv;\n\n\t\t\t*(*out + offs) = 'R';\n\t\t\t*(*out + offs + 1) = rv;\n\n\t\t\toffs += rv + 2;\n\t\t}\n\n\t\tsz = offs;\n\t}\n\n\tsc_log(ctx, \"read oberthur file result %i\", rv);\n\tif (verify_pin && rv == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {\n\t\tstruct sc_pkcs15_object *objs[0x10], *pin_obj = NULL;\n\t\tconst struct sc_acl_entry *acl = sc_file_get_acl_entry(file, SC_AC_OP_READ);\n\t\tint ii;\n\n\t\trv = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 0x10);\n\t\tif (rv != SC_SUCCESS) {\n\t\t\tsc_file_free(file);\n\t\t\tLOG_TEST_RET(ctx, rv, \"Cannot read oberthur file: get AUTH objects error\");\n\t\t}\n\n\t\tfor (ii=0; iidata;\n\t\t\tsc_log(ctx, \"compare PIN/ACL refs:%i/%i, method:%i/%i\",\n\t\t\t\t\tauth_info->attrs.pin.reference, acl->key_ref, auth_info->auth_method, acl->method);\n\t\t\tif (auth_info->attrs.pin.reference == (int)acl->key_ref && auth_info->auth_method == (unsigned)acl->method) {\n\t\t\t\tpin_obj = objs[ii];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!pin_obj || !pin_obj->content.value) {\n\t\t\trv = SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;\n\t\t}\n\t\telse {\n\t\t\trv = sc_pkcs15_verify_pin(p15card, pin_obj, pin_obj->content.value, pin_obj->content.len);\n\t\t\tif (!rv)\n\t\t\t\trv = sc_oberthur_read_file(p15card, in_path, out, out_len, 0);\n\t\t}\n\t};\n\n\tsc_file_free(file);\n\n\tif (rv < 0) {\n\t\tfree(*out);\n\t\t*out = NULL;\n\t\t*out_len = 0;\n\t}\n\n\t*out_len = sz;\n\n\tLOG_FUNC_RETURN(ctx, rv);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-26570", "cwe_id": "CWE-787" }, { "id": 494, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n auto* params =\n reinterpret_cast(node->builtin_data);\n\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n#define TF_LITE_SPACE_TO_DEPTH(type, scalar) \\\n tflite::SpaceToDepthParams op_params; \\\n op_params.block_size = params->block_size; \\\n type::SpaceToDepth(op_params, GetTensorShape(input), \\\n GetTensorData(input), GetTensorShape(output), \\\n GetTensorData(output))\n switch (input->type) { // Already know in/out types are same.\n case kTfLiteFloat32:\n if (kernel_type == kReference) {\n TF_LITE_SPACE_TO_DEPTH(reference_ops, float);\n } else {\n TF_LITE_SPACE_TO_DEPTH(optimized_ops, float);\n }\n break;\n case kTfLiteUInt8:\n if (kernel_type == kReference) {\n TF_LITE_SPACE_TO_DEPTH(reference_ops, uint8_t);\n } else {\n TF_LITE_SPACE_TO_DEPTH(optimized_ops, uint8_t);\n }\n break;\n case kTfLiteInt8:\n if (kernel_type == kReference) {\n TF_LITE_SPACE_TO_DEPTH(reference_ops, int8_t);\n } else {\n TF_LITE_SPACE_TO_DEPTH(optimized_ops, int8_t);\n }\n break;\n case kTfLiteInt32:\n if (kernel_type == kReference) {\n TF_LITE_SPACE_TO_DEPTH(reference_ops, int32_t);\n } else {\n TF_LITE_SPACE_TO_DEPTH(optimized_ops, int32_t);\n }\n break;\n case kTfLiteInt64:\n if (kernel_type == kReference) {\n TF_LITE_SPACE_TO_DEPTH(reference_ops, int64_t);\n } else {\n TF_LITE_SPACE_TO_DEPTH(optimized_ops, int64_t);\n }\n break;\n default:\n context->ReportError(context, \"Type '%s' not currently supported.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n#undef TF_LITE_SPACE_TO_DEPTH\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 494, "func": "TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {\n auto* params =\n reinterpret_cast(node->builtin_data);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n#define TF_LITE_SPACE_TO_DEPTH(type, scalar) \\\n tflite::SpaceToDepthParams op_params; \\\n op_params.block_size = params->block_size; \\\n type::SpaceToDepth(op_params, GetTensorShape(input), \\\n GetTensorData(input), GetTensorShape(output), \\\n GetTensorData(output))\n switch (input->type) { // Already know in/out types are same.\n case kTfLiteFloat32:\n if (kernel_type == kReference) {\n TF_LITE_SPACE_TO_DEPTH(reference_ops, float);\n } else {\n TF_LITE_SPACE_TO_DEPTH(optimized_ops, float);\n }\n break;\n case kTfLiteUInt8:\n if (kernel_type == kReference) {\n TF_LITE_SPACE_TO_DEPTH(reference_ops, uint8_t);\n } else {\n TF_LITE_SPACE_TO_DEPTH(optimized_ops, uint8_t);\n }\n break;\n case kTfLiteInt8:\n if (kernel_type == kReference) {\n TF_LITE_SPACE_TO_DEPTH(reference_ops, int8_t);\n } else {\n TF_LITE_SPACE_TO_DEPTH(optimized_ops, int8_t);\n }\n break;\n case kTfLiteInt32:\n if (kernel_type == kReference) {\n TF_LITE_SPACE_TO_DEPTH(reference_ops, int32_t);\n } else {\n TF_LITE_SPACE_TO_DEPTH(optimized_ops, int32_t);\n }\n break;\n case kTfLiteInt64:\n if (kernel_type == kReference) {\n TF_LITE_SPACE_TO_DEPTH(reference_ops, int64_t);\n } else {\n TF_LITE_SPACE_TO_DEPTH(optimized_ops, int64_t);\n }\n break;\n default:\n context->ReportError(context, \"Type '%s' not currently supported.\",\n TfLiteTypeGetName(input->type));\n return kTfLiteError;\n }\n#undef TF_LITE_SPACE_TO_DEPTH\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3091, "func": "static int encrypted_update(struct key *key, struct key_preparsed_payload *prep)\n{\n\tstruct encrypted_key_payload *epayload = key->payload.data[0];\n\tstruct encrypted_key_payload *new_epayload;\n\tchar *buf;\n\tchar *new_master_desc = NULL;\n\tconst char *format = NULL;\n\tsize_t datalen = prep->datalen;\n\tint ret = 0;\n\n\tif (test_bit(KEY_FLAG_NEGATIVE, &key->flags))\n\t\treturn -ENOKEY;\n\tif (datalen <= 0 || datalen > 32767 || !prep->data)\n\t\treturn -EINVAL;\n\n\tbuf = kmalloc(datalen + 1, GFP_KERNEL);\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\tbuf[datalen] = 0;\n\tmemcpy(buf, prep->data, datalen);\n\tret = datablob_parse(buf, &format, &new_master_desc, NULL, NULL);\n\tif (ret < 0)\n\t\tgoto out;\n\n\tret = valid_master_desc(new_master_desc, epayload->master_desc);\n\tif (ret < 0)\n\t\tgoto out;\n\n\tnew_epayload = encrypted_key_alloc(key, epayload->format,\n\t\t\t\t\t new_master_desc, epayload->datalen);\n\tif (IS_ERR(new_epayload)) {\n\t\tret = PTR_ERR(new_epayload);\n\t\tgoto out;\n\t}\n\n\t__ekey_init(new_epayload, epayload->format, new_master_desc,\n\t\t epayload->datalen);\n\n\tmemcpy(new_epayload->iv, epayload->iv, ivsize);\n\tmemcpy(new_epayload->payload_data, epayload->payload_data,\n\t epayload->payload_datalen);\n\n\trcu_assign_keypointer(key, new_epayload);\n\tcall_rcu(&epayload->rcu, encrypted_rcu_free);\nout:\n\tkzfree(buf);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-15951", "cwe_id": "CWE-20" }, { "id": 3091, "func": "static int encrypted_update(struct key *key, struct key_preparsed_payload *prep)\n{\n\tstruct encrypted_key_payload *epayload = key->payload.data[0];\n\tstruct encrypted_key_payload *new_epayload;\n\tchar *buf;\n\tchar *new_master_desc = NULL;\n\tconst char *format = NULL;\n\tsize_t datalen = prep->datalen;\n\tint ret = 0;\n\n\tif (key_is_negative(key))\n\t\treturn -ENOKEY;\n\tif (datalen <= 0 || datalen > 32767 || !prep->data)\n\t\treturn -EINVAL;\n\n\tbuf = kmalloc(datalen + 1, GFP_KERNEL);\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\tbuf[datalen] = 0;\n\tmemcpy(buf, prep->data, datalen);\n\tret = datablob_parse(buf, &format, &new_master_desc, NULL, NULL);\n\tif (ret < 0)\n\t\tgoto out;\n\n\tret = valid_master_desc(new_master_desc, epayload->master_desc);\n\tif (ret < 0)\n\t\tgoto out;\n\n\tnew_epayload = encrypted_key_alloc(key, epayload->format,\n\t\t\t\t\t new_master_desc, epayload->datalen);\n\tif (IS_ERR(new_epayload)) {\n\t\tret = PTR_ERR(new_epayload);\n\t\tgoto out;\n\t}\n\n\t__ekey_init(new_epayload, epayload->format, new_master_desc,\n\t\t epayload->datalen);\n\n\tmemcpy(new_epayload->iv, epayload->iv, ivsize);\n\tmemcpy(new_epayload->payload_data, epayload->payload_data,\n\t epayload->payload_datalen);\n\n\trcu_assign_keypointer(key, new_epayload);\n\tcall_rcu(&epayload->rcu, encrypted_rcu_free);\nout:\n\tkzfree(buf);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-15951", "cwe_id": "CWE-20" }, { "id": 2685, "func": "snmp_engine_get(snmp_header_t *header, snmp_varbind_t *varbinds, uint32_t varbinds_length)\n{\n snmp_mib_resource_t *resource;\n uint32_t i;\n\n for(i = 0; i < varbinds_length; i++) {\n resource = snmp_mib_find(varbinds[i].oid);\n if(!resource) {\n switch(header->version) {\n case SNMP_VERSION_1:\n header->error_status_non_repeaters.error_status = SNMP_STATUS_NO_SUCH_NAME;\n /*\n * Varbinds are 1 indexed\n */\n header->error_index_max_repetitions.error_index = i + 1;\n break;\n case SNMP_VERSION_2C:\n (&varbinds[i])->value_type = SNMP_DATA_TYPE_NO_SUCH_INSTANCE;\n break;\n default:\n header->error_status_non_repeaters.error_status = SNMP_STATUS_NO_SUCH_NAME;\n header->error_index_max_repetitions.error_index = 0;\n }\n } else {\n resource->handler(&varbinds[i], resource->oid);\n }\n }\n\n return 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12141", "cwe_id": "CWE-125" }, { "id": 2685, "func": "snmp_engine_get(snmp_header_t *header, snmp_varbind_t *varbinds)\n{\n snmp_mib_resource_t *resource;\n uint8_t i;\n\n i = 0;\n while(varbinds[i].value_type != BER_DATA_TYPE_EOC && i < SNMP_MAX_NR_VALUES) {\n resource = snmp_mib_find(&varbinds[i].oid);\n if(!resource) {\n switch(header->version) {\n case SNMP_VERSION_1:\n header->error_status = SNMP_STATUS_NO_SUCH_NAME;\n /*\n * Varbinds are 1 indexed\n */\n header->error_index = i + 1;\n break;\n case SNMP_VERSION_2C:\n (&varbinds[i])->value_type = BER_DATA_TYPE_NO_SUCH_INSTANCE;\n break;\n default:\n header->error_status = SNMP_STATUS_NO_SUCH_NAME;\n header->error_index = 0;\n }\n } else {\n resource->handler(&varbinds[i], &resource->oid);\n }\n\n i++;\n }\n\n return 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12141", "cwe_id": "CWE-125" }, { "id": 356, "func": "static bool r_bin_mdmp_init_directory(struct r_bin_mdmp_obj *obj) {\n\tint i;\n\tut8 *directory_base;\n\tstruct minidump_directory *entry;\n\n\tdirectory_base = obj->b->buf + obj->hdr->stream_directory_rva;\n\n\tsdb_num_set (obj->kv, \"mdmp_directory.offset\",\n\t\t\tobj->hdr->stream_directory_rva, 0);\n\tsdb_set (obj->kv, \"mdmp_directory.format\", \"[4]E? \"\n\t\t\t\"(mdmp_stream_type)StreamType \"\n\t\t\t\"(mdmp_location_descriptor)Location\", 0);\n\n\t/* Parse each entry in the directory */\n\tfor (i = 0; i < (int)obj->hdr->number_of_streams; i++) {\n\t\tentry = (struct minidump_directory *)(directory_base + (i * sizeof (struct minidump_directory)));\n\t\tr_bin_mdmp_init_directory_entry (obj, entry);\n\t}\n\n\treturn true;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-14016", "cwe_id": "CWE-125" }, { "id": 356, "func": "static bool r_bin_mdmp_init_directory(struct r_bin_mdmp_obj *obj) {\n\tint i;\n\tstruct minidump_directory entry;\n\n\tsdb_num_set (obj->kv, \"mdmp_directory.offset\",\n\t\t\tobj->hdr->stream_directory_rva, 0);\n\tsdb_set (obj->kv, \"mdmp_directory.format\", \"[4]E? \"\n\t\t\t\"(mdmp_stream_type)StreamType \"\n\t\t\t\"(mdmp_location_descriptor)Location\", 0);\n\n\t/* Parse each entry in the directory */\n\tut64 rvadir = obj->hdr->stream_directory_rva;\n\tfor (i = 0; i < (int)obj->hdr->number_of_streams; i++) {\n\t\tut32 delta = i * sizeof (struct minidump_directory);\n\t\tint r = r_buf_read_at (obj->b, rvadir + delta, (ut8*) &entry, sizeof (struct minidump_directory));\n\t\tif (r) {\n\t\t\tr_bin_mdmp_init_directory_entry (obj, &entry);\n\t\t}\n\t}\n\n\treturn true;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-14016", "cwe_id": "CWE-125" }, { "id": 2405, "func": "static bool regsafe(struct bpf_reg_state *rold, struct bpf_reg_state *rcur,\n\t\t struct idpair *idmap)\n{\n\tif (!(rold->live & REG_LIVE_READ))\n\t\t/* explored state didn't use this */\n\t\treturn true;\n\n\tif (memcmp(rold, rcur, offsetof(struct bpf_reg_state, live)) == 0)\n\t\treturn true;\n\n\tif (rold->type == NOT_INIT)\n\t\t/* explored state can't have used this */\n\t\treturn true;\n\tif (rcur->type == NOT_INIT)\n\t\treturn false;\n\tswitch (rold->type) {\n\tcase SCALAR_VALUE:\n\t\tif (rcur->type == SCALAR_VALUE) {\n\t\t\t/* new val must satisfy old val knowledge */\n\t\t\treturn range_within(rold, rcur) &&\n\t\t\t tnum_in(rold->var_off, rcur->var_off);\n\t\t} else {\n\t\t\t/* if we knew anything about the old value, we're not\n\t\t\t * equal, because we can't know anything about the\n\t\t\t * scalar value of the pointer in the new value.\n\t\t\t */\n\t\t\treturn rold->umin_value == 0 &&\n\t\t\t rold->umax_value == U64_MAX &&\n\t\t\t rold->smin_value == S64_MIN &&\n\t\t\t rold->smax_value == S64_MAX &&\n\t\t\t tnum_is_unknown(rold->var_off);\n\t\t}\n\tcase PTR_TO_MAP_VALUE:\n\t\t/* If the new min/max/var_off satisfy the old ones and\n\t\t * everything else matches, we are OK.\n\t\t * We don't care about the 'id' value, because nothing\n\t\t * uses it for PTR_TO_MAP_VALUE (only for ..._OR_NULL)\n\t\t */\n\t\treturn memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)) == 0 &&\n\t\t range_within(rold, rcur) &&\n\t\t tnum_in(rold->var_off, rcur->var_off);\n\tcase PTR_TO_MAP_VALUE_OR_NULL:\n\t\t/* a PTR_TO_MAP_VALUE could be safe to use as a\n\t\t * PTR_TO_MAP_VALUE_OR_NULL into the same map.\n\t\t * However, if the old PTR_TO_MAP_VALUE_OR_NULL then got NULL-\n\t\t * checked, doing so could have affected others with the same\n\t\t * id, and we can't check for that because we lost the id when\n\t\t * we converted to a PTR_TO_MAP_VALUE.\n\t\t */\n\t\tif (rcur->type != PTR_TO_MAP_VALUE_OR_NULL)\n\t\t\treturn false;\n\t\tif (memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)))\n\t\t\treturn false;\n\t\t/* Check our ids match any regs they're supposed to */\n\t\treturn check_ids(rold->id, rcur->id, idmap);\n\tcase PTR_TO_PACKET_META:\n\tcase PTR_TO_PACKET:\n\t\tif (rcur->type != rold->type)\n\t\t\treturn false;\n\t\t/* We must have at least as much range as the old ptr\n\t\t * did, so that any accesses which were safe before are\n\t\t * still safe. This is true even if old range < old off,\n\t\t * since someone could have accessed through (ptr - k), or\n\t\t * even done ptr -= k in a register, to get a safe access.\n\t\t */\n\t\tif (rold->range > rcur->range)\n\t\t\treturn false;\n\t\t/* If the offsets don't match, we can't trust our alignment;\n\t\t * nor can we be sure that we won't fall out of range.\n\t\t */\n\t\tif (rold->off != rcur->off)\n\t\t\treturn false;\n\t\t/* id relations must be preserved */\n\t\tif (rold->id && !check_ids(rold->id, rcur->id, idmap))\n\t\t\treturn false;\n\t\t/* new val must satisfy old val knowledge */\n\t\treturn range_within(rold, rcur) &&\n\t\t tnum_in(rold->var_off, rcur->var_off);\n\tcase PTR_TO_CTX:\n\tcase CONST_PTR_TO_MAP:\n\tcase PTR_TO_STACK:\n\tcase PTR_TO_PACKET_END:\n\t\t/* Only valid matches are exact, which memcmp() above\n\t\t * would have accepted\n\t\t */\n\tdefault:\n\t\t/* Don't know what's going on, just say it's not safe */\n\t\treturn false;\n\t}\n\n\t/* Shouldn't get here; if we do, say it's not safe */\n\tWARN_ON_ONCE(1);\n\treturn false;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-17855", "cwe_id": "CWE-119" }, { "id": 2405, "func": "static bool regsafe(struct bpf_reg_state *rold, struct bpf_reg_state *rcur,\n\t\t struct idpair *idmap)\n{\n\tif (!(rold->live & REG_LIVE_READ))\n\t\t/* explored state didn't use this */\n\t\treturn true;\n\n\tif (memcmp(rold, rcur, offsetof(struct bpf_reg_state, live)) == 0)\n\t\treturn true;\n\n\tif (rold->type == NOT_INIT)\n\t\t/* explored state can't have used this */\n\t\treturn true;\n\tif (rcur->type == NOT_INIT)\n\t\treturn false;\n\tswitch (rold->type) {\n\tcase SCALAR_VALUE:\n\t\tif (rcur->type == SCALAR_VALUE) {\n\t\t\t/* new val must satisfy old val knowledge */\n\t\t\treturn range_within(rold, rcur) &&\n\t\t\t tnum_in(rold->var_off, rcur->var_off);\n\t\t} else {\n\t\t\t/* We're trying to use a pointer in place of a scalar.\n\t\t\t * Even if the scalar was unbounded, this could lead to\n\t\t\t * pointer leaks because scalars are allowed to leak\n\t\t\t * while pointers are not. We could make this safe in\n\t\t\t * special cases if root is calling us, but it's\n\t\t\t * probably not worth the hassle.\n\t\t\t */\n\t\t\treturn false;\n\t\t}\n\tcase PTR_TO_MAP_VALUE:\n\t\t/* If the new min/max/var_off satisfy the old ones and\n\t\t * everything else matches, we are OK.\n\t\t * We don't care about the 'id' value, because nothing\n\t\t * uses it for PTR_TO_MAP_VALUE (only for ..._OR_NULL)\n\t\t */\n\t\treturn memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)) == 0 &&\n\t\t range_within(rold, rcur) &&\n\t\t tnum_in(rold->var_off, rcur->var_off);\n\tcase PTR_TO_MAP_VALUE_OR_NULL:\n\t\t/* a PTR_TO_MAP_VALUE could be safe to use as a\n\t\t * PTR_TO_MAP_VALUE_OR_NULL into the same map.\n\t\t * However, if the old PTR_TO_MAP_VALUE_OR_NULL then got NULL-\n\t\t * checked, doing so could have affected others with the same\n\t\t * id, and we can't check for that because we lost the id when\n\t\t * we converted to a PTR_TO_MAP_VALUE.\n\t\t */\n\t\tif (rcur->type != PTR_TO_MAP_VALUE_OR_NULL)\n\t\t\treturn false;\n\t\tif (memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)))\n\t\t\treturn false;\n\t\t/* Check our ids match any regs they're supposed to */\n\t\treturn check_ids(rold->id, rcur->id, idmap);\n\tcase PTR_TO_PACKET_META:\n\tcase PTR_TO_PACKET:\n\t\tif (rcur->type != rold->type)\n\t\t\treturn false;\n\t\t/* We must have at least as much range as the old ptr\n\t\t * did, so that any accesses which were safe before are\n\t\t * still safe. This is true even if old range < old off,\n\t\t * since someone could have accessed through (ptr - k), or\n\t\t * even done ptr -= k in a register, to get a safe access.\n\t\t */\n\t\tif (rold->range > rcur->range)\n\t\t\treturn false;\n\t\t/* If the offsets don't match, we can't trust our alignment;\n\t\t * nor can we be sure that we won't fall out of range.\n\t\t */\n\t\tif (rold->off != rcur->off)\n\t\t\treturn false;\n\t\t/* id relations must be preserved */\n\t\tif (rold->id && !check_ids(rold->id, rcur->id, idmap))\n\t\t\treturn false;\n\t\t/* new val must satisfy old val knowledge */\n\t\treturn range_within(rold, rcur) &&\n\t\t tnum_in(rold->var_off, rcur->var_off);\n\tcase PTR_TO_CTX:\n\tcase CONST_PTR_TO_MAP:\n\tcase PTR_TO_STACK:\n\tcase PTR_TO_PACKET_END:\n\t\t/* Only valid matches are exact, which memcmp() above\n\t\t * would have accepted\n\t\t */\n\tdefault:\n\t\t/* Don't know what's going on, just say it's not safe */\n\t\treturn false;\n\t}\n\n\t/* Shouldn't get here; if we do, say it's not safe */\n\tWARN_ON_ONCE(1);\n\treturn false;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-17855", "cwe_id": "CWE-119" }, { "id": 37, "func": "sraSpanInsertAfter(sraSpan *newspan, sraSpan *after) {\n newspan->_next = after->_next;\n newspan->_prev = after;\n after->_next->_prev = newspan;\n after->_next = newspan;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-14397", "cwe_id": "CWE-476" }, { "id": 37, "func": "sraSpanInsertAfter(sraSpan *newspan, sraSpan *after) {\n if(newspan && after) {\n newspan->_next = after->_next;\n newspan->_prev = after;\n after->_next->_prev = newspan;\n after->_next = newspan;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-14397", "cwe_id": "CWE-476" }, { "id": 1351, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n const OpData* op_data = reinterpret_cast(node->user_data);\n\n TF_LITE_ENSURE(context, node->inputs->size > 0);\n\n // The first input is the condition.\n const TfLiteTensor* cond = GetInput(context, node, 0);\n // Currently only bool is supported.\n // TODO(ycling): Support other types since TensorFlow also support\n // non-bool types as condition.\n TF_LITE_ENSURE_EQ(context, cond->type, kTfLiteBool);\n TF_LITE_ENSURE_EQ(context, NumElements(cond), 1);\n\n // The first input of the node is the condition. The rest of inputs are\n // passed to the branch subgraphs. Therefore, the number of subgraph inputs\n // will be the number of node inputs - 1.\n int num_inputs = node->inputs->size - 1;\n int num_outputs = node->outputs->size;\n\n Subgraph* this_subgraph = reinterpret_cast(context->impl_);\n auto* subgraphs = this_subgraph->GetSubgraphs();\n TF_LITE_ENSURE(context, op_data->then_subgraph_index < subgraphs->size());\n TF_LITE_ENSURE(context, op_data->else_subgraph_index < subgraphs->size());\n\n Subgraph* then_subgraph = (*subgraphs)[op_data->then_subgraph_index].get();\n Subgraph* else_subgraph = (*subgraphs)[op_data->else_subgraph_index].get();\n\n for (auto* subgraph : {then_subgraph, else_subgraph}) {\n TF_LITE_ENSURE_EQ(context, num_inputs, subgraph->inputs().size());\n TF_LITE_ENSURE_EQ(context, num_outputs, subgraph->outputs().size());\n }\n\n bool has_dynamic_output_tensors = false;\n for (auto* subgraph : {then_subgraph, else_subgraph}) {\n for (int i = 0; i < num_inputs; ++i) {\n // The first input of the node is the condition. The indices of the inputs\n // passed to the subgraphs are offset by 1.\n const TfLiteTensor* input = GetInput(context, node, i + 1);\n std::vector dims(input->dims->data,\n input->dims->data + input->dims->size);\n subgraph->ResizeInputTensor(i, dims);\n TfLiteTensor* subgraph_input = subgraph->tensor(subgraph->inputs()[i]);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, subgraph_input->type);\n }\n // Note: The `Prepare` function is responsible to run `AllocateTensors` on\n // both subgraphs. It's intentionally not to break out of the loop when\n // finding a dynamic output tensor.\n TF_LITE_ENSURE_OK(context, subgraph->AllocateTensors());\n has_dynamic_output_tensors |= subgraph->HasDynamicTensors();\n }\n\n if (!has_dynamic_output_tensors) {\n for (int i = 0; i < num_outputs; ++i) {\n TfLiteTensor* then_output =\n then_subgraph->tensor(then_subgraph->outputs()[i]);\n TfLiteTensor* else_output =\n else_subgraph->tensor(else_subgraph->outputs()[i]);\n // If the 2 subgraphs have static but different output shapes, the output\n // tensors of the IF op have dynamic sizes.\n if (!TfLiteIntArrayEqual(then_output->dims, else_output->dims)) {\n has_dynamic_output_tensors = true;\n break;\n }\n }\n }\n\n for (int i = 0; i < num_outputs; ++i) {\n TfLiteTensor* output = GetOutput(context, node, i);\n if (has_dynamic_output_tensors) {\n SetTensorToDynamic(output);\n } else {\n // When there's no dynamic output tensors, the 2 subgraph has exactly\n // the same static sized outputs.\n TfLiteTensor* then_output =\n then_subgraph->tensor(then_subgraph->outputs()[i]);\n TfLiteIntArray* output_size = TfLiteIntArrayCopy(then_output->dims);\n TF_LITE_ENSURE_OK(context,\n context->ResizeTensor(context, output, output_size));\n }\n }\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1351, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n const OpData* op_data = reinterpret_cast(node->user_data);\n\n TF_LITE_ENSURE(context, node->inputs->size > 0);\n\n // The first input is the condition.\n const TfLiteTensor* cond;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &cond));\n // Currently only bool is supported.\n // TODO(ycling): Support other types since TensorFlow also support\n // non-bool types as condition.\n TF_LITE_ENSURE_EQ(context, cond->type, kTfLiteBool);\n TF_LITE_ENSURE_EQ(context, NumElements(cond), 1);\n\n // The first input of the node is the condition. The rest of inputs are\n // passed to the branch subgraphs. Therefore, the number of subgraph inputs\n // will be the number of node inputs - 1.\n int num_inputs = node->inputs->size - 1;\n int num_outputs = node->outputs->size;\n\n Subgraph* this_subgraph = reinterpret_cast(context->impl_);\n auto* subgraphs = this_subgraph->GetSubgraphs();\n TF_LITE_ENSURE(context, op_data->then_subgraph_index < subgraphs->size());\n TF_LITE_ENSURE(context, op_data->else_subgraph_index < subgraphs->size());\n\n Subgraph* then_subgraph = (*subgraphs)[op_data->then_subgraph_index].get();\n Subgraph* else_subgraph = (*subgraphs)[op_data->else_subgraph_index].get();\n\n for (auto* subgraph : {then_subgraph, else_subgraph}) {\n TF_LITE_ENSURE_EQ(context, num_inputs, subgraph->inputs().size());\n TF_LITE_ENSURE_EQ(context, num_outputs, subgraph->outputs().size());\n }\n\n bool has_dynamic_output_tensors = false;\n for (auto* subgraph : {then_subgraph, else_subgraph}) {\n for (int i = 0; i < num_inputs; ++i) {\n // The first input of the node is the condition. The indices of the inputs\n // passed to the subgraphs are offset by 1.\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, i + 1, &input));\n std::vector dims(input->dims->data,\n input->dims->data + input->dims->size);\n subgraph->ResizeInputTensor(i, dims);\n TfLiteTensor* subgraph_input = subgraph->tensor(subgraph->inputs()[i]);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, subgraph_input->type);\n }\n // Note: The `Prepare` function is responsible to run `AllocateTensors` on\n // both subgraphs. It's intentionally not to break out of the loop when\n // finding a dynamic output tensor.\n TF_LITE_ENSURE_OK(context, subgraph->AllocateTensors());\n has_dynamic_output_tensors |= subgraph->HasDynamicTensors();\n }\n\n if (!has_dynamic_output_tensors) {\n for (int i = 0; i < num_outputs; ++i) {\n TfLiteTensor* then_output =\n then_subgraph->tensor(then_subgraph->outputs()[i]);\n TfLiteTensor* else_output =\n else_subgraph->tensor(else_subgraph->outputs()[i]);\n // If the 2 subgraphs have static but different output shapes, the output\n // tensors of the IF op have dynamic sizes.\n if (!TfLiteIntArrayEqual(then_output->dims, else_output->dims)) {\n has_dynamic_output_tensors = true;\n break;\n }\n }\n }\n\n for (int i = 0; i < num_outputs; ++i) {\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, i, &output));\n if (has_dynamic_output_tensors) {\n SetTensorToDynamic(output);\n } else {\n // When there's no dynamic output tensors, the 2 subgraph has exactly\n // the same static sized outputs.\n TfLiteTensor* then_output =\n then_subgraph->tensor(then_subgraph->outputs()[i]);\n TfLiteIntArray* output_size = TfLiteIntArrayCopy(then_output->dims);\n TF_LITE_ENSURE_OK(context,\n context->ResizeTensor(context, output, output_size));\n }\n }\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3010, "func": "static UINT32 nsc_rle_encode(BYTE* in, BYTE* out, UINT32 originalSize)\n{\n\tUINT32 left;\n\tUINT32 runlength = 1;\n\tUINT32 planeSize = 0;\n\tleft = originalSize;\n\n\t/**\n\t * We quit the loop if the running compressed size is larger than the original.\n\t * In such cases data will be sent uncompressed.\n\t */\n\twhile (left > 4 && planeSize < originalSize - 4)\n\t{\n\t\tif (left > 5 && *in == *(in + 1))\n\t\t{\n\t\t\trunlength++;\n\t\t}\n\t\telse if (runlength == 1)\n\t\t{\n\t\t\t*out++ = *in;\n\t\t\tplaneSize++;\n\t\t}\n\t\telse if (runlength < 256)\n\t\t{\n\t\t\t*out++ = *in;\n\t\t\t*out++ = *in;\n\t\t\t*out++ = runlength - 2;\n\t\t\trunlength = 1;\n\t\t\tplaneSize += 3;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t*out++ = *in;\n\t\t\t*out++ = *in;\n\t\t\t*out++ = 0xFF;\n\t\t\t*out++ = (runlength & 0x000000FF);\n\t\t\t*out++ = (runlength & 0x0000FF00) >> 8;\n\t\t\t*out++ = (runlength & 0x00FF0000) >> 16;\n\t\t\t*out++ = (runlength & 0xFF000000) >> 24;\n\t\t\trunlength = 1;\n\t\t\tplaneSize += 7;\n\t\t}\n\n\t\tin++;\n\t\tleft--;\n\t}\n\n\tif (planeSize < originalSize - 4)\n\t\tCopyMemory(out, in, 4);\n\n\tplaneSize += 4;\n\treturn planeSize;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-8788", "cwe_id": "CWE-787" }, { "id": 3010, "func": "static UINT32 nsc_rle_encode(const BYTE* in, BYTE* out, UINT32 originalSize)\n{\n\tUINT32 left;\n\tUINT32 runlength = 1;\n\tUINT32 planeSize = 0;\n\tleft = originalSize;\n\n\t/**\n\t * We quit the loop if the running compressed size is larger than the original.\n\t * In such cases data will be sent uncompressed.\n\t */\n\twhile (left > 4 && planeSize < originalSize - 4)\n\t{\n\t\tif (left > 5 && *in == *(in + 1))\n\t\t{\n\t\t\trunlength++;\n\t\t}\n\t\telse if (runlength == 1)\n\t\t{\n\t\t\t*out++ = *in;\n\t\t\tplaneSize++;\n\t\t}\n\t\telse if (runlength < 256)\n\t\t{\n\t\t\t*out++ = *in;\n\t\t\t*out++ = *in;\n\t\t\t*out++ = runlength - 2;\n\t\t\trunlength = 1;\n\t\t\tplaneSize += 3;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t*out++ = *in;\n\t\t\t*out++ = *in;\n\t\t\t*out++ = 0xFF;\n\t\t\t*out++ = (runlength & 0x000000FF);\n\t\t\t*out++ = (runlength & 0x0000FF00) >> 8;\n\t\t\t*out++ = (runlength & 0x00FF0000) >> 16;\n\t\t\t*out++ = (runlength & 0xFF000000) >> 24;\n\t\t\trunlength = 1;\n\t\t\tplaneSize += 7;\n\t\t}\n\n\t\tin++;\n\t\tleft--;\n\t}\n\n\tif (planeSize < originalSize - 4)\n\t\tCopyMemory(out, in, 4);\n\n\tplaneSize += 4;\n\treturn planeSize;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-8788", "cwe_id": "CWE-787" }, { "id": 31, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n // Reinterprete the opaque data provided by user.\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);\n const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type);\n\n const TfLiteType type = input1->type;\n switch (type) {\n case kTfLiteFloat32:\n case kTfLiteInt32:\n break;\n default:\n context->ReportError(context, \"Type '%s' is not supported by floor_div.\",\n TfLiteTypeGetName(type));\n return kTfLiteError;\n }\n output->type = type;\n\n data->requires_broadcast = !HaveSameShapes(input1, input2);\n\n TfLiteIntArray* output_size = nullptr;\n if (data->requires_broadcast) {\n TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(\n context, input1, input2, &output_size));\n } else {\n output_size = TfLiteIntArrayCopy(input1->dims);\n }\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 31, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n // Reinterprete the opaque data provided by user.\n OpData* data = reinterpret_cast(node->user_data);\n\n const TfLiteTensor* input1;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor1, &input1));\n const TfLiteTensor* input2;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputTensor2, &input2));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type);\n\n const TfLiteType type = input1->type;\n switch (type) {\n case kTfLiteFloat32:\n case kTfLiteInt32:\n break;\n default:\n context->ReportError(context, \"Type '%s' is not supported by floor_div.\",\n TfLiteTypeGetName(type));\n return kTfLiteError;\n }\n output->type = type;\n\n data->requires_broadcast = !HaveSameShapes(input1, input2);\n\n TfLiteIntArray* output_size = nullptr;\n if (data->requires_broadcast) {\n TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(\n context, input1, input2, &output_size));\n } else {\n output_size = TfLiteIntArrayCopy(input1->dims);\n }\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1889, "func": "static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct net *net = sock_net(sk);\n\tstruct ipcm_cookie ipc;\n\tstruct rtable *rt = NULL;\n\tstruct flowi4 fl4;\n\tint free = 0;\n\t__be32 daddr;\n\t__be32 saddr;\n\tu8 tos;\n\tint err;\n\tstruct ip_options_data opt_copy;\n\tstruct raw_frag_vec rfv;\n\n\terr = -EMSGSIZE;\n\tif (len > 0xFFFF)\n\t\tgoto out;\n\n\t/*\n\t *\tCheck the flags.\n\t */\n\n\terr = -EOPNOTSUPP;\n\tif (msg->msg_flags & MSG_OOB)\t/* Mirror BSD error message */\n\t\tgoto out; /* compatibility */\n\n\t/*\n\t *\tGet and verify the address.\n\t */\n\n\tif (msg->msg_namelen) {\n\t\tDECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name);\n\t\terr = -EINVAL;\n\t\tif (msg->msg_namelen < sizeof(*usin))\n\t\t\tgoto out;\n\t\tif (usin->sin_family != AF_INET) {\n\t\t\tpr_info_once(\"%s: %s forgot to set AF_INET. Fix it!\\n\",\n\t\t\t\t __func__, current->comm);\n\t\t\terr = -EAFNOSUPPORT;\n\t\t\tif (usin->sin_family)\n\t\t\t\tgoto out;\n\t\t}\n\t\tdaddr = usin->sin_addr.s_addr;\n\t\t/* ANK: I did not forget to get protocol from port field.\n\t\t * I just do not know, who uses this weirdness.\n\t\t * IP_HDRINCL is much more convenient.\n\t\t */\n\t} else {\n\t\terr = -EDESTADDRREQ;\n\t\tif (sk->sk_state != TCP_ESTABLISHED)\n\t\t\tgoto out;\n\t\tdaddr = inet->inet_daddr;\n\t}\n\n\tipc.sockc.tsflags = sk->sk_tsflags;\n\tipc.addr = inet->inet_saddr;\n\tipc.opt = NULL;\n\tipc.tx_flags = 0;\n\tipc.ttl = 0;\n\tipc.tos = -1;\n\tipc.oif = sk->sk_bound_dev_if;\n\n\tif (msg->msg_controllen) {\n\t\terr = ip_cmsg_send(sk, msg, &ipc, false);\n\t\tif (unlikely(err)) {\n\t\t\tkfree(ipc.opt);\n\t\t\tgoto out;\n\t\t}\n\t\tif (ipc.opt)\n\t\t\tfree = 1;\n\t}\n\n\tsaddr = ipc.addr;\n\tipc.addr = daddr;\n\n\tif (!ipc.opt) {\n\t\tstruct ip_options_rcu *inet_opt;\n\n\t\trcu_read_lock();\n\t\tinet_opt = rcu_dereference(inet->inet_opt);\n\t\tif (inet_opt) {\n\t\t\tmemcpy(&opt_copy, inet_opt,\n\t\t\t sizeof(*inet_opt) + inet_opt->opt.optlen);\n\t\t\tipc.opt = &opt_copy.opt;\n\t\t}\n\t\trcu_read_unlock();\n\t}\n\n\tif (ipc.opt) {\n\t\terr = -EINVAL;\n\t\t/* Linux does not mangle headers on raw sockets,\n\t\t * so that IP options + IP_HDRINCL is non-sense.\n\t\t */\n\t\tif (inet->hdrincl)\n\t\t\tgoto done;\n\t\tif (ipc.opt->opt.srr) {\n\t\t\tif (!daddr)\n\t\t\t\tgoto done;\n\t\t\tdaddr = ipc.opt->opt.faddr;\n\t\t}\n\t}\n\ttos = get_rtconn_flags(&ipc, sk);\n\tif (msg->msg_flags & MSG_DONTROUTE)\n\t\ttos |= RTO_ONLINK;\n\n\tif (ipv4_is_multicast(daddr)) {\n\t\tif (!ipc.oif)\n\t\t\tipc.oif = inet->mc_index;\n\t\tif (!saddr)\n\t\t\tsaddr = inet->mc_addr;\n\t} else if (!ipc.oif)\n\t\tipc.oif = inet->uc_index;\n\n\tflowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,\n\t\t\t RT_SCOPE_UNIVERSE,\n\t\t\t inet->hdrincl ? IPPROTO_RAW : sk->sk_protocol,\n\t\t\t inet_sk_flowi_flags(sk) |\n\t\t\t (inet->hdrincl ? FLOWI_FLAG_KNOWN_NH : 0),\n\t\t\t daddr, saddr, 0, 0, sk->sk_uid);\n\n\tif (!inet->hdrincl) {\n\t\trfv.msg = msg;\n\t\trfv.hlen = 0;\n\n\t\terr = raw_probe_proto_opt(&rfv, &fl4);\n\t\tif (err)\n\t\t\tgoto done;\n\t}\n\n\tsecurity_sk_classify_flow(sk, flowi4_to_flowi(&fl4));\n\trt = ip_route_output_flow(net, &fl4, sk);\n\tif (IS_ERR(rt)) {\n\t\terr = PTR_ERR(rt);\n\t\trt = NULL;\n\t\tgoto done;\n\t}\n\n\terr = -EACCES;\n\tif (rt->rt_flags & RTCF_BROADCAST && !sock_flag(sk, SOCK_BROADCAST))\n\t\tgoto done;\n\n\tif (msg->msg_flags & MSG_CONFIRM)\n\t\tgoto do_confirm;\nback_from_confirm:\n\n\tif (inet->hdrincl)\n\t\terr = raw_send_hdrinc(sk, &fl4, msg, len,\n\t\t\t\t &rt, msg->msg_flags, &ipc.sockc);\n\n\t else {\n\t\tsock_tx_timestamp(sk, ipc.sockc.tsflags, &ipc.tx_flags);\n\n\t\tif (!ipc.addr)\n\t\t\tipc.addr = fl4.daddr;\n\t\tlock_sock(sk);\n\t\terr = ip_append_data(sk, &fl4, raw_getfrag,\n\t\t\t\t &rfv, len, 0,\n\t\t\t\t &ipc, &rt, msg->msg_flags);\n\t\tif (err)\n\t\t\tip_flush_pending_frames(sk);\n\t\telse if (!(msg->msg_flags & MSG_MORE)) {\n\t\t\terr = ip_push_pending_frames(sk, &fl4);\n\t\t\tif (err == -ENOBUFS && !inet->recverr)\n\t\t\t\terr = 0;\n\t\t}\n\t\trelease_sock(sk);\n\t}\ndone:\n\tif (free)\n\t\tkfree(ipc.opt);\n\tip_rt_put(rt);\n\nout:\n\tif (err < 0)\n\t\treturn err;\n\treturn len;\n\ndo_confirm:\n\tif (msg->msg_flags & MSG_PROBE)\n\t\tdst_confirm_neigh(&rt->dst, &fl4.daddr);\n\tif (!(msg->msg_flags & MSG_PROBE) || len)\n\t\tgoto back_from_confirm;\n\terr = 0;\n\tgoto done;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-17712", "cwe_id": "CWE-362" }, { "id": 1889, "func": "static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct net *net = sock_net(sk);\n\tstruct ipcm_cookie ipc;\n\tstruct rtable *rt = NULL;\n\tstruct flowi4 fl4;\n\tint free = 0;\n\t__be32 daddr;\n\t__be32 saddr;\n\tu8 tos;\n\tint err;\n\tstruct ip_options_data opt_copy;\n\tstruct raw_frag_vec rfv;\n\tint hdrincl;\n\n\terr = -EMSGSIZE;\n\tif (len > 0xFFFF)\n\t\tgoto out;\n\n\t/* hdrincl should be READ_ONCE(inet->hdrincl)\n\t * but READ_ONCE() doesn't work with bit fields\n\t */\n\thdrincl = inet->hdrincl;\n\t/*\n\t *\tCheck the flags.\n\t */\n\n\terr = -EOPNOTSUPP;\n\tif (msg->msg_flags & MSG_OOB)\t/* Mirror BSD error message */\n\t\tgoto out; /* compatibility */\n\n\t/*\n\t *\tGet and verify the address.\n\t */\n\n\tif (msg->msg_namelen) {\n\t\tDECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name);\n\t\terr = -EINVAL;\n\t\tif (msg->msg_namelen < sizeof(*usin))\n\t\t\tgoto out;\n\t\tif (usin->sin_family != AF_INET) {\n\t\t\tpr_info_once(\"%s: %s forgot to set AF_INET. Fix it!\\n\",\n\t\t\t\t __func__, current->comm);\n\t\t\terr = -EAFNOSUPPORT;\n\t\t\tif (usin->sin_family)\n\t\t\t\tgoto out;\n\t\t}\n\t\tdaddr = usin->sin_addr.s_addr;\n\t\t/* ANK: I did not forget to get protocol from port field.\n\t\t * I just do not know, who uses this weirdness.\n\t\t * IP_HDRINCL is much more convenient.\n\t\t */\n\t} else {\n\t\terr = -EDESTADDRREQ;\n\t\tif (sk->sk_state != TCP_ESTABLISHED)\n\t\t\tgoto out;\n\t\tdaddr = inet->inet_daddr;\n\t}\n\n\tipc.sockc.tsflags = sk->sk_tsflags;\n\tipc.addr = inet->inet_saddr;\n\tipc.opt = NULL;\n\tipc.tx_flags = 0;\n\tipc.ttl = 0;\n\tipc.tos = -1;\n\tipc.oif = sk->sk_bound_dev_if;\n\n\tif (msg->msg_controllen) {\n\t\terr = ip_cmsg_send(sk, msg, &ipc, false);\n\t\tif (unlikely(err)) {\n\t\t\tkfree(ipc.opt);\n\t\t\tgoto out;\n\t\t}\n\t\tif (ipc.opt)\n\t\t\tfree = 1;\n\t}\n\n\tsaddr = ipc.addr;\n\tipc.addr = daddr;\n\n\tif (!ipc.opt) {\n\t\tstruct ip_options_rcu *inet_opt;\n\n\t\trcu_read_lock();\n\t\tinet_opt = rcu_dereference(inet->inet_opt);\n\t\tif (inet_opt) {\n\t\t\tmemcpy(&opt_copy, inet_opt,\n\t\t\t sizeof(*inet_opt) + inet_opt->opt.optlen);\n\t\t\tipc.opt = &opt_copy.opt;\n\t\t}\n\t\trcu_read_unlock();\n\t}\n\n\tif (ipc.opt) {\n\t\terr = -EINVAL;\n\t\t/* Linux does not mangle headers on raw sockets,\n\t\t * so that IP options + IP_HDRINCL is non-sense.\n\t\t */\n\t\tif (hdrincl)\n\t\t\tgoto done;\n\t\tif (ipc.opt->opt.srr) {\n\t\t\tif (!daddr)\n\t\t\t\tgoto done;\n\t\t\tdaddr = ipc.opt->opt.faddr;\n\t\t}\n\t}\n\ttos = get_rtconn_flags(&ipc, sk);\n\tif (msg->msg_flags & MSG_DONTROUTE)\n\t\ttos |= RTO_ONLINK;\n\n\tif (ipv4_is_multicast(daddr)) {\n\t\tif (!ipc.oif)\n\t\t\tipc.oif = inet->mc_index;\n\t\tif (!saddr)\n\t\t\tsaddr = inet->mc_addr;\n\t} else if (!ipc.oif)\n\t\tipc.oif = inet->uc_index;\n\n\tflowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,\n\t\t\t RT_SCOPE_UNIVERSE,\n\t\t\t hdrincl ? IPPROTO_RAW : sk->sk_protocol,\n\t\t\t inet_sk_flowi_flags(sk) |\n\t\t\t (hdrincl ? FLOWI_FLAG_KNOWN_NH : 0),\n\t\t\t daddr, saddr, 0, 0, sk->sk_uid);\n\n\tif (!hdrincl) {\n\t\trfv.msg = msg;\n\t\trfv.hlen = 0;\n\n\t\terr = raw_probe_proto_opt(&rfv, &fl4);\n\t\tif (err)\n\t\t\tgoto done;\n\t}\n\n\tsecurity_sk_classify_flow(sk, flowi4_to_flowi(&fl4));\n\trt = ip_route_output_flow(net, &fl4, sk);\n\tif (IS_ERR(rt)) {\n\t\terr = PTR_ERR(rt);\n\t\trt = NULL;\n\t\tgoto done;\n\t}\n\n\terr = -EACCES;\n\tif (rt->rt_flags & RTCF_BROADCAST && !sock_flag(sk, SOCK_BROADCAST))\n\t\tgoto done;\n\n\tif (msg->msg_flags & MSG_CONFIRM)\n\t\tgoto do_confirm;\nback_from_confirm:\n\n\tif (hdrincl)\n\t\terr = raw_send_hdrinc(sk, &fl4, msg, len,\n\t\t\t\t &rt, msg->msg_flags, &ipc.sockc);\n\n\t else {\n\t\tsock_tx_timestamp(sk, ipc.sockc.tsflags, &ipc.tx_flags);\n\n\t\tif (!ipc.addr)\n\t\t\tipc.addr = fl4.daddr;\n\t\tlock_sock(sk);\n\t\terr = ip_append_data(sk, &fl4, raw_getfrag,\n\t\t\t\t &rfv, len, 0,\n\t\t\t\t &ipc, &rt, msg->msg_flags);\n\t\tif (err)\n\t\t\tip_flush_pending_frames(sk);\n\t\telse if (!(msg->msg_flags & MSG_MORE)) {\n\t\t\terr = ip_push_pending_frames(sk, &fl4);\n\t\t\tif (err == -ENOBUFS && !inet->recverr)\n\t\t\t\terr = 0;\n\t\t}\n\t\trelease_sock(sk);\n\t}\ndone:\n\tif (free)\n\t\tkfree(ipc.opt);\n\tip_rt_put(rt);\n\nout:\n\tif (err < 0)\n\t\treturn err;\n\treturn len;\n\ndo_confirm:\n\tif (msg->msg_flags & MSG_PROBE)\n\t\tdst_confirm_neigh(&rt->dst, &fl4.daddr);\n\tif (!(msg->msg_flags & MSG_PROBE) || len)\n\t\tgoto back_from_confirm;\n\terr = 0;\n\tgoto done;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-17712", "cwe_id": "CWE-362" }, { "id": 2343, "func": "static void smp_task_timedout(struct timer_list *t)\n{\n\tstruct sas_task_slow *slow = from_timer(slow, t, timer);\n\tstruct sas_task *task = slow->task;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&task->task_state_lock, flags);\n\tif (!(task->task_state_flags & SAS_TASK_STATE_DONE))\n\t\ttask->task_state_flags |= SAS_TASK_STATE_ABORTED;\n\tspin_unlock_irqrestore(&task->task_state_lock, flags);\n\n\tcomplete(&task->slow_task->completion);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20836", "cwe_id": "CWE-362" }, { "id": 2343, "func": "static void smp_task_timedout(struct timer_list *t)\n{\n\tstruct sas_task_slow *slow = from_timer(slow, t, timer);\n\tstruct sas_task *task = slow->task;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&task->task_state_lock, flags);\n\tif (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {\n\t\ttask->task_state_flags |= SAS_TASK_STATE_ABORTED;\n\t\tcomplete(&task->slow_task->completion);\n\t}\n\tspin_unlock_irqrestore(&task->task_state_lock, flags);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20836", "cwe_id": "CWE-362" }, { "id": 2834, "func": "\nvoid skb_complete_tx_timestamp(struct sk_buff *skb,\n\t\t\t struct skb_shared_hwtstamps *hwtstamps)\n{\n\tstruct sock *sk = skb->sk;\n\n\tif (!skb_may_tx_timestamp(sk, false))\n\t\treturn;\n\n\t/* Take a reference to prevent skb_orphan() from freeing the socket,\n\t * but only if the socket refcount is not zero.\n\t */\n\tif (likely(atomic_inc_not_zero(&sk->sk_refcnt))) {\n\t\t*skb_hwtstamps(skb) = *hwtstamps;\n\t\t__skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND);\n\t\tsock_put(sk);\n\t}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7277", "cwe_id": "CWE-125" }, { "id": 2834, "func": "\nvoid skb_complete_tx_timestamp(struct sk_buff *skb,\n\t\t\t struct skb_shared_hwtstamps *hwtstamps)\n{\n\tstruct sock *sk = skb->sk;\n\n\tif (!skb_may_tx_timestamp(sk, false))\n\t\treturn;\n\n\t/* Take a reference to prevent skb_orphan() from freeing the socket,\n\t * but only if the socket refcount is not zero.\n\t */\n\tif (likely(atomic_inc_not_zero(&sk->sk_refcnt))) {\n\t\t*skb_hwtstamps(skb) = *hwtstamps;\n\t\t__skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND, false);\n\t\tsock_put(sk);\n\t}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7277", "cwe_id": "CWE-125" }, { "id": 1121, "func": "bool MemoryManager::validate_user_write(const Process& process, VirtualAddress vaddr) const\n{\n auto* region = region_from_vaddr(process, vaddr);\n return region && region->is_writable();\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-20172", "cwe_id": "CWE-119" }, { "id": 1121, "func": "bool MemoryManager::validate_user_write(const Process& process, VirtualAddress vaddr) const\n{\n auto* region = user_region_from_vaddr(const_cast(process), vaddr);\n return region && region->is_user_accessible() && region->is_writable();\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-20172", "cwe_id": "CWE-119" }, { "id": 669, "func": "static int ptrace_check_attach(struct task_struct *child, bool ignore_state)\n{\n\tint ret = -ESRCH;\n\n\t/*\n\t * We take the read lock around doing both checks to close a\n\t * possible race where someone else was tracing our child and\n\t * detached between these two checks. After this locked check,\n\t * we are sure that this is our traced child and that can only\n\t * be changed by us so it's not changing right after this.\n\t */\n\tread_lock(&tasklist_lock);\n\tif ((child->ptrace & PT_PTRACED) && child->parent == current) {\n\t\t/*\n\t\t * child->sighand can't be NULL, release_task()\n\t\t * does ptrace_unlink() before __exit_signal().\n\t\t */\n\t\tspin_lock_irq(&child->sighand->siglock);\n\t\tWARN_ON_ONCE(task_is_stopped(child));\n\t\tif (ignore_state || (task_is_traced(child) &&\n\t\t\t\t !(child->jobctl & JOBCTL_LISTENING)))\n\t\t\tret = 0;\n\t\tspin_unlock_irq(&child->sighand->siglock);\n\t}\n\tread_unlock(&tasklist_lock);\n\n\tif (!ret && !ignore_state)\n\t\tret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH;\n\n\t/* All systems go.. */\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-0871", "cwe_id": "CWE-362" }, { "id": 669, "func": "static int ptrace_check_attach(struct task_struct *child, bool ignore_state)\n{\n\tint ret = -ESRCH;\n\n\t/*\n\t * We take the read lock around doing both checks to close a\n\t * possible race where someone else was tracing our child and\n\t * detached between these two checks. After this locked check,\n\t * we are sure that this is our traced child and that can only\n\t * be changed by us so it's not changing right after this.\n\t */\n\tread_lock(&tasklist_lock);\n\tif (child->ptrace && child->parent == current) {\n\t\tWARN_ON(child->state == __TASK_TRACED);\n\t\t/*\n\t\t * child->sighand can't be NULL, release_task()\n\t\t * does ptrace_unlink() before __exit_signal().\n\t\t */\n\t\tif (ignore_state || ptrace_freeze_traced(child))\n\t\t\tret = 0;\n\t}\n\tread_unlock(&tasklist_lock);\n\n\tif (!ret && !ignore_state) {\n\t\tif (!wait_task_inactive(child, __TASK_TRACED)) {\n\t\t\t/*\n\t\t\t * This can only happen if may_ptrace_stop() fails and\n\t\t\t * ptrace_stop() changes ->state back to TASK_RUNNING,\n\t\t\t * so we should not worry about leaking __TASK_TRACED.\n\t\t\t */\n\t\t\tWARN_ON(child->state == __TASK_TRACED);\n\t\t\tret = -ESRCH;\n\t\t}\n\t}\n\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-0871", "cwe_id": "CWE-362" }, { "id": 802, "func": "compat_mpt_command(struct file *filp, unsigned int cmd,\n\t\t\tunsigned long arg)\n{\n\tstruct mpt_ioctl_command32 karg32;\n\tstruct mpt_ioctl_command32 __user *uarg = (struct mpt_ioctl_command32 __user *) arg;\n\tstruct mpt_ioctl_command karg;\n\tMPT_ADAPTER *iocp = NULL;\n\tint iocnum, iocnumX;\n\tint nonblock = (filp->f_flags & O_NONBLOCK);\n\tint ret;\n\n\tif (copy_from_user(&karg32, (char __user *)arg, sizeof(karg32)))\n\t\treturn -EFAULT;\n\n\t/* Verify intended MPT adapter */\n\tiocnumX = karg32.hdr.iocnum & 0xFF;\n\tif (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||\n\t (iocp == NULL)) {\n\t\tprintk(KERN_DEBUG MYNAM \"::compat_mpt_command @%d - ioc%d not found!\\n\",\n\t\t\t__LINE__, iocnumX);\n\t\treturn -ENODEV;\n\t}\n\n\tif ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)\n\t\treturn ret;\n\n\tdctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT \"compat_mpt_command() called\\n\",\n\t iocp->name));\n\t/* Copy data to karg */\n\tkarg.hdr.iocnum = karg32.hdr.iocnum;\n\tkarg.hdr.port = karg32.hdr.port;\n\tkarg.timeout = karg32.timeout;\n\tkarg.maxReplyBytes = karg32.maxReplyBytes;\n\n\tkarg.dataInSize = karg32.dataInSize;\n\tkarg.dataOutSize = karg32.dataOutSize;\n\tkarg.maxSenseBytes = karg32.maxSenseBytes;\n\tkarg.dataSgeOffset = karg32.dataSgeOffset;\n\n\tkarg.replyFrameBufPtr = (char __user *)(unsigned long)karg32.replyFrameBufPtr;\n\tkarg.dataInBufPtr = (char __user *)(unsigned long)karg32.dataInBufPtr;\n\tkarg.dataOutBufPtr = (char __user *)(unsigned long)karg32.dataOutBufPtr;\n\tkarg.senseDataPtr = (char __user *)(unsigned long)karg32.senseDataPtr;\n\n\t/* Pass new structure to do_mpt_command\n\t */\n\tret = mptctl_do_mpt_command (karg, &uarg->MF);\n\n\tmutex_unlock(&iocp->ioctl_cmds.mutex);\n\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-12652", "cwe_id": "CWE-362" }, { "id": 802, "func": "compat_mpt_command(struct file *filp, unsigned int cmd,\n\t\t\tunsigned long arg)\n{\n\tstruct mpt_ioctl_command32 karg32;\n\tstruct mpt_ioctl_command32 __user *uarg = (struct mpt_ioctl_command32 __user *) arg;\n\tstruct mpt_ioctl_command karg;\n\tMPT_ADAPTER *iocp = NULL;\n\tint iocnum, iocnumX;\n\tint nonblock = (filp->f_flags & O_NONBLOCK);\n\tint ret;\n\n\tif (copy_from_user(&karg32, (char __user *)arg, sizeof(karg32)))\n\t\treturn -EFAULT;\n\n\t/* Verify intended MPT adapter */\n\tiocnumX = karg32.hdr.iocnum & 0xFF;\n\tif (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||\n\t (iocp == NULL)) {\n\t\tprintk(KERN_DEBUG MYNAM \"::compat_mpt_command @%d - ioc%d not found!\\n\",\n\t\t\t__LINE__, iocnumX);\n\t\treturn -ENODEV;\n\t}\n\n\tif ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)\n\t\treturn ret;\n\n\tdctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT \"compat_mpt_command() called\\n\",\n\t iocp->name));\n\t/* Copy data to karg */\n\tkarg.hdr.iocnum = karg32.hdr.iocnum;\n\tkarg.hdr.port = karg32.hdr.port;\n\tkarg.timeout = karg32.timeout;\n\tkarg.maxReplyBytes = karg32.maxReplyBytes;\n\n\tkarg.dataInSize = karg32.dataInSize;\n\tkarg.dataOutSize = karg32.dataOutSize;\n\tkarg.maxSenseBytes = karg32.maxSenseBytes;\n\tkarg.dataSgeOffset = karg32.dataSgeOffset;\n\n\tkarg.replyFrameBufPtr = (char __user *)(unsigned long)karg32.replyFrameBufPtr;\n\tkarg.dataInBufPtr = (char __user *)(unsigned long)karg32.dataInBufPtr;\n\tkarg.dataOutBufPtr = (char __user *)(unsigned long)karg32.dataOutBufPtr;\n\tkarg.senseDataPtr = (char __user *)(unsigned long)karg32.senseDataPtr;\n\n\t/* Pass new structure to do_mpt_command\n\t */\n\tret = mptctl_do_mpt_command (iocp, karg, &uarg->MF);\n\n\tmutex_unlock(&iocp->ioctl_cmds.mutex);\n\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-12652", "cwe_id": "CWE-362" }, { "id": 3158, "func": "void luaV_concat (lua_State *L, int total) {\n if (total == 1)\n return; /* \"all\" values already concatenated */\n do {\n StkId top = L->top;\n int n = 2; /* number of elements handled in this pass (at least 2) */\n if (!(ttisstring(s2v(top - 2)) || cvt2str(s2v(top - 2))) ||\n !tostring(L, s2v(top - 1)))\n luaT_tryconcatTM(L);\n else if (isemptystr(s2v(top - 1))) /* second operand is empty? */\n cast_void(tostring(L, s2v(top - 2))); /* result is first operand */\n else if (isemptystr(s2v(top - 2))) { /* first operand is empty string? */\n setobjs2s(L, top - 2, top - 1); /* result is second op. */\n }\n else {\n /* at least two non-empty string values; get as many as possible */\n size_t tl = vslen(s2v(top - 1));\n TString *ts;\n /* collect total length and number of strings */\n for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {\n size_t l = vslen(s2v(top - n - 1));\n if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl))\n luaG_runerror(L, \"string length overflow\");\n tl += l;\n }\n if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */\n char buff[LUAI_MAXSHORTLEN];\n copy2buff(top, n, buff); /* copy strings to buffer */\n ts = luaS_newlstr(L, buff, tl);\n }\n else { /* long string; copy strings directly to final result */\n ts = luaS_createlngstrobj(L, tl);\n copy2buff(top, n, getstr(ts));\n }\n setsvalue2s(L, top - n, ts); /* create result */\n }\n total -= n-1; /* got 'n' strings to create 1 new */\n L->top -= n-1; /* popped 'n' strings and pushed one */\n } while (total > 1); /* repeat until only 1 result left */\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-33099", "cwe_id": "CWE-787" }, { "id": 3158, "func": "void luaV_concat (lua_State *L, int total) {\n if (total == 1)\n return; /* \"all\" values already concatenated */\n do {\n StkId top = L->top;\n int n = 2; /* number of elements handled in this pass (at least 2) */\n if (!(ttisstring(s2v(top - 2)) || cvt2str(s2v(top - 2))) ||\n !tostring(L, s2v(top - 1)))\n luaT_tryconcatTM(L);\n else if (isemptystr(s2v(top - 1))) /* second operand is empty? */\n cast_void(tostring(L, s2v(top - 2))); /* result is first operand */\n else if (isemptystr(s2v(top - 2))) { /* first operand is empty string? */\n setobjs2s(L, top - 2, top - 1); /* result is second op. */\n }\n else {\n /* at least two non-empty string values; get as many as possible */\n size_t tl = vslen(s2v(top - 1));\n TString *ts;\n /* collect total length and number of strings */\n for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {\n size_t l = vslen(s2v(top - n - 1));\n if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) {\n L->top = top - total; /* pop strings to avoid wasting stack */\n luaG_runerror(L, \"string length overflow\");\n }\n tl += l;\n }\n if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */\n char buff[LUAI_MAXSHORTLEN];\n copy2buff(top, n, buff); /* copy strings to buffer */\n ts = luaS_newlstr(L, buff, tl);\n }\n else { /* long string; copy strings directly to final result */\n ts = luaS_createlngstrobj(L, tl);\n copy2buff(top, n, getstr(ts));\n }\n setsvalue2s(L, top - n, ts); /* create result */\n }\n total -= n-1; /* got 'n' strings to create 1 new */\n L->top = top - (n - 1); /* popped 'n' strings and pushed one */\n } while (total > 1); /* repeat until only 1 result left */\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-33099", "cwe_id": "CWE-787" }, { "id": 305, "func": "static int ipxitf_ioctl(unsigned int cmd, void __user *arg)\n{\n\tint rc = -EINVAL;\n\tstruct ifreq ifr;\n\tint val;\n\n\tswitch (cmd) {\n\tcase SIOCSIFADDR: {\n\t\tstruct sockaddr_ipx *sipx;\n\t\tstruct ipx_interface_definition f;\n\n\t\trc = -EFAULT;\n\t\tif (copy_from_user(&ifr, arg, sizeof(ifr)))\n\t\t\tbreak;\n\t\tsipx = (struct sockaddr_ipx *)&ifr.ifr_addr;\n\t\trc = -EINVAL;\n\t\tif (sipx->sipx_family != AF_IPX)\n\t\t\tbreak;\n\t\tf.ipx_network = sipx->sipx_network;\n\t\tmemcpy(f.ipx_device, ifr.ifr_name,\n\t\t\tsizeof(f.ipx_device));\n\t\tmemcpy(f.ipx_node, sipx->sipx_node, IPX_NODE_LEN);\n\t\tf.ipx_dlink_type = sipx->sipx_type;\n\t\tf.ipx_special = sipx->sipx_special;\n\n\t\tif (sipx->sipx_action == IPX_DLTITF)\n\t\t\trc = ipxitf_delete(&f);\n\t\telse\n\t\t\trc = ipxitf_create(&f);\n\t\tbreak;\n\t}\n\tcase SIOCGIFADDR: {\n\t\tstruct sockaddr_ipx *sipx;\n\t\tstruct ipx_interface *ipxif;\n\t\tstruct net_device *dev;\n\n\t\trc = -EFAULT;\n\t\tif (copy_from_user(&ifr, arg, sizeof(ifr)))\n\t\t\tbreak;\n\t\tsipx = (struct sockaddr_ipx *)&ifr.ifr_addr;\n\t\tdev = __dev_get_by_name(&init_net, ifr.ifr_name);\n\t\trc = -ENODEV;\n\t\tif (!dev)\n\t\t\tbreak;\n\t\tipxif = ipxitf_find_using_phys(dev,\n\t\t\t\t\t ipx_map_frame_type(sipx->sipx_type));\n\t\trc = -EADDRNOTAVAIL;\n\t\tif (!ipxif)\n\t\t\tbreak;\n\n\t\tsipx->sipx_family\t= AF_IPX;\n\t\tsipx->sipx_network\t= ipxif->if_netnum;\n\t\tmemcpy(sipx->sipx_node, ipxif->if_node,\n\t\t\tsizeof(sipx->sipx_node));\n\t\trc = -EFAULT;\n\t\tif (copy_to_user(arg, &ifr, sizeof(ifr)))\n\t\t\tbreak;\n\t\tipxitf_put(ipxif);\n\t\trc = 0;\n\t\tbreak;\n\t}\n\tcase SIOCAIPXITFCRT:\n\t\trc = -EFAULT;\n\t\tif (get_user(val, (unsigned char __user *) arg))\n\t\t\tbreak;\n\t\trc = 0;\n\t\tipxcfg_auto_create_interfaces = val;\n\t\tbreak;\n\tcase SIOCAIPXPRISLT:\n\t\trc = -EFAULT;\n\t\tif (get_user(val, (unsigned char __user *) arg))\n\t\t\tbreak;\n\t\trc = 0;\n\t\tipxcfg_set_auto_select(val);\n\t\tbreak;\n\t}\n\n\treturn rc;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7487", "cwe_id": "CWE-416" }, { "id": 305, "func": "static int ipxitf_ioctl(unsigned int cmd, void __user *arg)\n{\n\tint rc = -EINVAL;\n\tstruct ifreq ifr;\n\tint val;\n\n\tswitch (cmd) {\n\tcase SIOCSIFADDR: {\n\t\tstruct sockaddr_ipx *sipx;\n\t\tstruct ipx_interface_definition f;\n\n\t\trc = -EFAULT;\n\t\tif (copy_from_user(&ifr, arg, sizeof(ifr)))\n\t\t\tbreak;\n\t\tsipx = (struct sockaddr_ipx *)&ifr.ifr_addr;\n\t\trc = -EINVAL;\n\t\tif (sipx->sipx_family != AF_IPX)\n\t\t\tbreak;\n\t\tf.ipx_network = sipx->sipx_network;\n\t\tmemcpy(f.ipx_device, ifr.ifr_name,\n\t\t\tsizeof(f.ipx_device));\n\t\tmemcpy(f.ipx_node, sipx->sipx_node, IPX_NODE_LEN);\n\t\tf.ipx_dlink_type = sipx->sipx_type;\n\t\tf.ipx_special = sipx->sipx_special;\n\n\t\tif (sipx->sipx_action == IPX_DLTITF)\n\t\t\trc = ipxitf_delete(&f);\n\t\telse\n\t\t\trc = ipxitf_create(&f);\n\t\tbreak;\n\t}\n\tcase SIOCGIFADDR: {\n\t\tstruct sockaddr_ipx *sipx;\n\t\tstruct ipx_interface *ipxif;\n\t\tstruct net_device *dev;\n\n\t\trc = -EFAULT;\n\t\tif (copy_from_user(&ifr, arg, sizeof(ifr)))\n\t\t\tbreak;\n\t\tsipx = (struct sockaddr_ipx *)&ifr.ifr_addr;\n\t\tdev = __dev_get_by_name(&init_net, ifr.ifr_name);\n\t\trc = -ENODEV;\n\t\tif (!dev)\n\t\t\tbreak;\n\t\tipxif = ipxitf_find_using_phys(dev,\n\t\t\t\t\t ipx_map_frame_type(sipx->sipx_type));\n\t\trc = -EADDRNOTAVAIL;\n\t\tif (!ipxif)\n\t\t\tbreak;\n\n\t\tsipx->sipx_family\t= AF_IPX;\n\t\tsipx->sipx_network\t= ipxif->if_netnum;\n\t\tmemcpy(sipx->sipx_node, ipxif->if_node,\n\t\t\tsizeof(sipx->sipx_node));\n\t\trc = 0;\n\t\tif (copy_to_user(arg, &ifr, sizeof(ifr)))\n\t\t\trc = -EFAULT;\n\t\tipxitf_put(ipxif);\n\t\tbreak;\n\t}\n\tcase SIOCAIPXITFCRT:\n\t\trc = -EFAULT;\n\t\tif (get_user(val, (unsigned char __user *) arg))\n\t\t\tbreak;\n\t\trc = 0;\n\t\tipxcfg_auto_create_interfaces = val;\n\t\tbreak;\n\tcase SIOCAIPXPRISLT:\n\t\trc = -EFAULT;\n\t\tif (get_user(val, (unsigned char __user *) arg))\n\t\t\tbreak;\n\t\trc = 0;\n\t\tipxcfg_set_auto_select(val);\n\t\tbreak;\n\t}\n\n\treturn rc;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7487", "cwe_id": "CWE-416" }, { "id": 1312, "func": "static RList *r_bin_wasm_get_global_entries (RBinWasmObj *bin, RBinWasmSection *sec) {\n\tRList *ret = NULL;\n\tRBinWasmGlobalEntry *ptr = NULL;\n\tint buflen = bin->buf->length;\n\tif (sec->payload_data + 32 > buflen) {\n\t\treturn NULL;\n\t}\n\n\tif (!(ret = r_list_newf ((RListFree)free))) {\n\t\treturn NULL;\n\t}\n\n\tut8* buf = bin->buf->buf + (ut32)sec->payload_data;\n\tut32 len = sec->payload_len;\n\tut32 count = sec->count;\n\tut32 i = 0, r = 0;\n\n\twhile (i < len && len < buflen && r < count) {\n\t\tif (!(ptr = R_NEW0 (RBinWasmGlobalEntry))) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tif (len + 8 > buflen || !(consume_u8 (buf + i, buf + len, (ut8*)&ptr->content_type, &i))) {\n\t\t\tgoto beach;\n\t\t}\n\t\tif (len + 8 > buflen || !(consume_u8 (buf + i, buf + len, &ptr->mutability, &i))) {\n\t\t\tgoto beach;\n\t\t}\n\t\tif (len + 8 > buflen || !(consume_init_expr (buf + i, buf + len, R_BIN_WASM_END_OF_CODE, NULL, &i))) {\n\t\t\tgoto beach;\n\t\t}\n\t\tr_list_append (ret, ptr);\n\t\tr++;\n\t}\n\treturn ret;\nbeach:\n\tfree (ptr);\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7854", "cwe_id": "CWE-125" }, { "id": 1312, "func": "static RList *r_bin_wasm_get_global_entries (RBinWasmObj *bin, RBinWasmSection *sec) {\n\tRList *ret = NULL;\n\tRBinWasmGlobalEntry *ptr = NULL;\n\n\tif (!(ret = r_list_newf ((RListFree)free))) {\n\t\treturn NULL;\n\t}\n\n\tut8* buf = bin->buf->buf + (ut32)sec->payload_data;\n\tint buflen = bin->buf->length - (ut32)sec->payload_data;\n\tut32 len = sec->payload_len;\n\tut32 count = sec->count;\n\tut32 i = 0, r = 0;\n\n\twhile (i < len && len < buflen && r < count) {\n\t\tif (!(ptr = R_NEW0 (RBinWasmGlobalEntry))) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tif (len + 8 > buflen || !(consume_u8 (buf + i, buf + len, (ut8*)&ptr->content_type, &i))) {\n\t\t\tgoto beach;\n\t\t}\n\t\tif (len + 8 > buflen || !(consume_u8 (buf + i, buf + len, &ptr->mutability, &i))) {\n\t\t\tgoto beach;\n\t\t}\n\t\tif (len + 8 > buflen || !(consume_init_expr (buf + i, buf + len, R_BIN_WASM_END_OF_CODE, NULL, &i))) {\n\t\t\tgoto beach;\n\t\t}\n\t\tr_list_append (ret, ptr);\n\t\tr++;\n\t}\n\treturn ret;\nbeach:\n\tfree (ptr);\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7854", "cwe_id": "CWE-125" }, { "id": 1173, "func": "PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_nack(\n\t\t\t\t\tpjmedia_rtcp_session *session,\n\t\t\t\t\tvoid *buf,\n\t\t\t\t\tpj_size_t *length,\n\t\t\t\t\tunsigned nack_cnt,\n\t\t\t\t\tconst pjmedia_rtcp_fb_nack nack[])\n{\n pjmedia_rtcp_common *hdr;\n pj_uint8_t *p;\n unsigned len, i;\n\n PJ_ASSERT_RETURN(session && buf && length && nack_cnt && nack, PJ_EINVAL);\n\n len = (3 + nack_cnt) * 4;\n if (len > *length)\n\treturn PJ_ETOOSMALL;\n\n /* Build RTCP-FB NACK header */\n hdr = (pjmedia_rtcp_common*)buf;\n pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));\n hdr->pt = RTCP_RTPFB;\n hdr->count = 1; /* FMT = 1 */\n hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));\n\n /* Build RTCP-FB NACK FCI */\n p = (pj_uint8_t*)hdr + sizeof(*hdr);\n for (i = 0; i < nack_cnt; ++i) {\n\tpj_uint16_t val;\n\tval = pj_htons((pj_uint16_t)nack[i].pid);\n\tpj_memcpy(p, &val, 2);\n\tval = pj_htons(nack[i].blp);\n\tpj_memcpy(p+2, &val, 2);\n\tp += 4;\n }\n\n /* Finally */\n *length = len;\n\n return PJ_SUCCESS;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-24786", "cwe_id": "CWE-125" }, { "id": 1173, "func": "PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_nack(\n\t\t\t\t\tpjmedia_rtcp_session *session,\n\t\t\t\t\tvoid *buf,\n\t\t\t\t\tpj_size_t *length,\n\t\t\t\t\tunsigned nack_cnt,\n\t\t\t\t\tconst pjmedia_rtcp_fb_nack nack[])\n{\n pjmedia_rtcp_fb_common *hdr;\n pj_uint8_t *p;\n unsigned len, i;\n\n PJ_ASSERT_RETURN(session && buf && length && nack_cnt && nack, PJ_EINVAL);\n\n len = (3 + nack_cnt) * 4;\n if (len > *length)\n\treturn PJ_ETOOSMALL;\n\n /* Build RTCP-FB NACK header */\n hdr = (pjmedia_rtcp_fb_common*)buf;\n pj_memcpy(hdr, &session->rtcp_fb_com, sizeof(*hdr));\n hdr->rtcp_common.pt = RTCP_RTPFB;\n hdr->rtcp_common.count = 1; /* FMT = 1 */\n hdr->rtcp_common.length = pj_htons((pj_uint16_t)(len/4 - 1));\n\n /* Build RTCP-FB NACK FCI */\n p = (pj_uint8_t*)hdr + sizeof(*hdr);\n for (i = 0; i < nack_cnt; ++i) {\n\tpj_uint16_t val;\n\tval = pj_htons((pj_uint16_t)nack[i].pid);\n\tpj_memcpy(p, &val, 2);\n\tval = pj_htons(nack[i].blp);\n\tpj_memcpy(p+2, &val, 2);\n\tp += 4;\n }\n\n /* Finally */\n *length = len;\n\n return PJ_SUCCESS;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-24786", "cwe_id": "CWE-125" }, { "id": 404, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input = GetInput(context, node, kInput);\n const TfLiteTensor* axis = GetInput(context, node, kAxis);\n TfLiteTensor* output = GetOutput(context, node, 0);\n output->type = input->type;\n if (IsConstantTensor(axis)) {\n int axis_value;\n TF_LITE_ENSURE_OK(context,\n GetAxisValueFromTensor(context, *axis, &axis_value));\n return ExpandTensorDim(context, *input, axis_value, output);\n }\n SetTensorToDynamic(output);\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 404, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInput, &input));\n const TfLiteTensor* axis;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kAxis, &axis));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));\n output->type = input->type;\n if (IsConstantTensor(axis)) {\n int axis_value;\n TF_LITE_ENSURE_OK(context,\n GetAxisValueFromTensor(context, *axis, &axis_value));\n return ExpandTensorDim(context, *input, axis_value, output);\n }\n SetTensorToDynamic(output);\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1196, "func": " static port::StatusOr Create(\n GpuExecutor* parent, int max_seq_length, int batch_size, int data_size,\n const absl::Span& seq_lengths, bool time_major,\n cudnnDataType_t data_type) {\n CHECK_GT(max_seq_length, 0);\n int dims[] = {batch_size, data_size, 1};\n int strides[] = {dims[1] * dims[2], dims[2], 1};\n TensorDescriptor tensor_desc = CreateTensorDescriptor();\n RETURN_IF_CUDNN_ERROR(cudnnSetTensorNdDescriptor(\n /*tensorDesc=*/tensor_desc.get(), /*dataType=*/data_type,\n /*nbDims=*/sizeof(dims) / sizeof(dims[0]), /*dimA=*/dims,\n /*strideA=*/strides));\n const int* seq_lengths_array = seq_lengths.data();\n RNNDataDescriptor data_desc = CreateRNNDataDescriptor();\n float padding_fill = 0.0f;\n cudnnRNNDataLayout_t layout;\n if (time_major) {\n layout = CUDNN_RNN_DATA_LAYOUT_SEQ_MAJOR_UNPACKED;\n } else {\n layout = CUDNN_RNN_DATA_LAYOUT_BATCH_MAJOR_UNPACKED;\n }\n RETURN_IF_CUDNN_ERROR(cudnnSetRNNDataDescriptor(\n /*RNNDataDesc=*/data_desc.get(), /*dataType*/ data_type,\n /*layout=*/layout,\n /*maxSeqLength=*/max_seq_length,\n /*batchSize=*/batch_size, /*vectorSize=*/data_size,\n /*seqLengthArray=*/seq_lengths_array,\n /*paddingFill*/ (void*)&padding_fill));\n return CudnnRnnSequenceTensorDescriptor(\n parent, max_seq_length, batch_size, data_size, data_type,\n std::move(data_desc), std::move(tensor_desc));\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-26270", "cwe_id": "CWE-20" }, { "id": 1196, "func": " static port::StatusOr Create(\n GpuExecutor* parent, int max_seq_length, int batch_size, int data_size,\n const absl::Span& seq_lengths, bool time_major,\n cudnnDataType_t data_type) {\n if (max_seq_length <= 0) {\n return port::Status(port::error::INVALID_ARGUMENT, \"max_seq_length <= 0\");\n }\n int dims[] = {batch_size, data_size, 1};\n int strides[] = {dims[1] * dims[2], dims[2], 1};\n TensorDescriptor tensor_desc = CreateTensorDescriptor();\n RETURN_IF_CUDNN_ERROR(cudnnSetTensorNdDescriptor(\n /*tensorDesc=*/tensor_desc.get(), /*dataType=*/data_type,\n /*nbDims=*/sizeof(dims) / sizeof(dims[0]), /*dimA=*/dims,\n /*strideA=*/strides));\n const int* seq_lengths_array = seq_lengths.data();\n RNNDataDescriptor data_desc = CreateRNNDataDescriptor();\n float padding_fill = 0.0f;\n cudnnRNNDataLayout_t layout;\n if (time_major) {\n layout = CUDNN_RNN_DATA_LAYOUT_SEQ_MAJOR_UNPACKED;\n } else {\n layout = CUDNN_RNN_DATA_LAYOUT_BATCH_MAJOR_UNPACKED;\n }\n RETURN_IF_CUDNN_ERROR(cudnnSetRNNDataDescriptor(\n /*RNNDataDesc=*/data_desc.get(), /*dataType*/ data_type,\n /*layout=*/layout,\n /*maxSeqLength=*/max_seq_length,\n /*batchSize=*/batch_size, /*vectorSize=*/data_size,\n /*seqLengthArray=*/seq_lengths_array,\n /*paddingFill*/ (void*)&padding_fill));\n return CudnnRnnSequenceTensorDescriptor(\n parent, max_seq_length, batch_size, data_size, data_type,\n std::move(data_desc), std::move(tensor_desc));\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-26270", "cwe_id": "CWE-20" }, { "id": 1211, "func": "void inet_sock_destruct(struct sock *sk)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\n\t__skb_queue_purge(&sk->sk_receive_queue);\n\t__skb_queue_purge(&sk->sk_error_queue);\n\n\tsk_mem_reclaim(sk);\n\n\tif (sk->sk_type == SOCK_STREAM && sk->sk_state != TCP_CLOSE) {\n\t\tpr_err(\"Attempt to release TCP socket in state %d %p\\n\",\n\t\t sk->sk_state, sk);\n\t\treturn;\n\t}\n\tif (!sock_flag(sk, SOCK_DEAD)) {\n\t\tpr_err(\"Attempt to release alive inet socket %p\\n\", sk);\n\t\treturn;\n\t}\n\n\tWARN_ON(atomic_read(&sk->sk_rmem_alloc));\n\tWARN_ON(atomic_read(&sk->sk_wmem_alloc));\n\tWARN_ON(sk->sk_wmem_queued);\n\tWARN_ON(sk->sk_forward_alloc);\n\n\tkfree(inet->opt);\n\tdst_release(rcu_dereference_check(sk->sk_dst_cache, 1));\n\tsk_refcnt_debug_dec(sk);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 1211, "func": "void inet_sock_destruct(struct sock *sk)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\n\t__skb_queue_purge(&sk->sk_receive_queue);\n\t__skb_queue_purge(&sk->sk_error_queue);\n\n\tsk_mem_reclaim(sk);\n\n\tif (sk->sk_type == SOCK_STREAM && sk->sk_state != TCP_CLOSE) {\n\t\tpr_err(\"Attempt to release TCP socket in state %d %p\\n\",\n\t\t sk->sk_state, sk);\n\t\treturn;\n\t}\n\tif (!sock_flag(sk, SOCK_DEAD)) {\n\t\tpr_err(\"Attempt to release alive inet socket %p\\n\", sk);\n\t\treturn;\n\t}\n\n\tWARN_ON(atomic_read(&sk->sk_rmem_alloc));\n\tWARN_ON(atomic_read(&sk->sk_wmem_alloc));\n\tWARN_ON(sk->sk_wmem_queued);\n\tWARN_ON(sk->sk_forward_alloc);\n\n\tkfree(rcu_dereference_protected(inet->inet_opt, 1));\n\tdst_release(rcu_dereference_check(sk->sk_dst_cache, 1));\n\tsk_refcnt_debug_dec(sk);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-3552", "cwe_id": "CWE-362" }, { "id": 1978, "func": "mrb_remove_method(mrb_state *mrb, struct RClass *c, mrb_sym mid)\n{\n mt_tbl *h;\n\n MRB_CLASS_ORIGIN(c);\n h = c->mt;\n\n if (h && mt_del(mrb, h, mid)) return;\n mrb_name_error(mrb, mid, \"method '%n' not defined in %C\", mid, c);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-1286", "cwe_id": "CWE-787" }, { "id": 1978, "func": "mrb_remove_method(mrb_state *mrb, struct RClass *c, mrb_sym mid)\n{\n mt_tbl *h;\n\n MRB_CLASS_ORIGIN(c);\n h = c->mt;\n\n if (h && mt_del(mrb, h, mid)) {\n mrb_mc_clear_by_class(mrb, c);\n return;\n }\n mrb_name_error(mrb, mid, \"method '%n' not defined in %C\", mid, c);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-1286", "cwe_id": "CWE-787" }, { "id": 1087, "func": "static int ssl_parse_client_psk_identity( mbedtls_ssl_context *ssl, unsigned char **p,\n const unsigned char *end )\n{\n int ret = 0;\n size_t n;\n\n if( ssl->conf->f_psk == NULL &&\n ( ssl->conf->psk == NULL || ssl->conf->psk_identity == NULL ||\n ssl->conf->psk_identity_len == 0 || ssl->conf->psk_len == 0 ) )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"got no pre-shared key\" ) );\n return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED );\n }\n\n /*\n * Receive client pre-shared key identity name\n */\n if( *p + 2 > end )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad client key exchange message\" ) );\n return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE );\n }\n\n n = ( (*p)[0] << 8 ) | (*p)[1];\n *p += 2;\n\n if( n < 1 || n > 65535 || *p + n > end )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad client key exchange message\" ) );\n return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE );\n }\n\n if( ssl->conf->f_psk != NULL )\n {\n if( ssl->conf->f_psk( ssl->conf->p_psk, ssl, *p, n ) != 0 )\n ret = MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY;\n }\n else\n {\n /* Identity is not a big secret since clients send it in the clear,\n * but treat it carefully anyway, just in case */\n if( n != ssl->conf->psk_identity_len ||\n mbedtls_ssl_safer_memcmp( ssl->conf->psk_identity, *p, n ) != 0 )\n {\n ret = MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY;\n }\n }\n\n if( ret == MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY )\n {\n MBEDTLS_SSL_DEBUG_BUF( 3, \"Unknown PSK identity\", *p, n );\n mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,\n MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY );\n return( MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY );\n }\n\n *p += n;\n\n return( 0 );\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-18187", "cwe_id": "CWE-190" }, { "id": 1087, "func": "static int ssl_parse_client_psk_identity( mbedtls_ssl_context *ssl, unsigned char **p,\n const unsigned char *end )\n{\n int ret = 0;\n size_t n;\n\n if( ssl->conf->f_psk == NULL &&\n ( ssl->conf->psk == NULL || ssl->conf->psk_identity == NULL ||\n ssl->conf->psk_identity_len == 0 || ssl->conf->psk_len == 0 ) )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"got no pre-shared key\" ) );\n return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED );\n }\n\n /*\n * Receive client pre-shared key identity name\n */\n if( end - *p < 2 )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad client key exchange message\" ) );\n return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE );\n }\n\n n = ( (*p)[0] << 8 ) | (*p)[1];\n *p += 2;\n\n if( n < 1 || n > 65535 || n > (size_t) ( end - *p ) )\n {\n MBEDTLS_SSL_DEBUG_MSG( 1, ( \"bad client key exchange message\" ) );\n return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE );\n }\n\n if( ssl->conf->f_psk != NULL )\n {\n if( ssl->conf->f_psk( ssl->conf->p_psk, ssl, *p, n ) != 0 )\n ret = MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY;\n }\n else\n {\n /* Identity is not a big secret since clients send it in the clear,\n * but treat it carefully anyway, just in case */\n if( n != ssl->conf->psk_identity_len ||\n mbedtls_ssl_safer_memcmp( ssl->conf->psk_identity, *p, n ) != 0 )\n {\n ret = MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY;\n }\n }\n\n if( ret == MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY )\n {\n MBEDTLS_SSL_DEBUG_BUF( 3, \"Unknown PSK identity\", *p, n );\n mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,\n MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY );\n return( MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY );\n }\n\n *p += n;\n\n return( 0 );\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-18187", "cwe_id": "CWE-190" }, { "id": 2451, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n const TfLiteTensor* multipliers = GetInput(context, node, kInputMultipliers);\n // Only int32 and int64 multipliers type is supported.\n if (multipliers->type != kTfLiteInt32 && multipliers->type != kTfLiteInt64) {\n context->ReportError(context,\n \"Multipliers of type '%s' are not supported by tile.\",\n TfLiteTypeGetName(multipliers->type));\n return kTfLiteError;\n }\n\n if (IsConstantTensor(multipliers)) {\n TF_LITE_ENSURE_OK(context, ResizeOutput(context, node));\n } else {\n SetTensorToDynamic(output);\n }\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2451, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n const TfLiteTensor* multipliers;\n TF_LITE_ENSURE_OK(\n context, GetInputSafe(context, node, kInputMultipliers, &multipliers));\n // Only int32 and int64 multipliers type is supported.\n if (multipliers->type != kTfLiteInt32 && multipliers->type != kTfLiteInt64) {\n context->ReportError(context,\n \"Multipliers of type '%s' are not supported by tile.\",\n TfLiteTypeGetName(multipliers->type));\n return kTfLiteError;\n }\n\n if (IsConstantTensor(multipliers)) {\n TF_LITE_ENSURE_OK(context, ResizeOutput(context, node));\n } else {\n SetTensorToDynamic(output);\n }\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 777, "func": "static void process_constructors (RBinFile *bf, RList *ret, int bits) {\n\tRList *secs = sections (bf);\n\tRListIter *iter;\n\tRBinSection *sec;\n\tint i, type;\n\tr_list_foreach (secs, iter, sec) {\n\t\ttype = -1;\n\t\tif (!strcmp (sec->name, \".fini_array\")) {\n\t\t\ttype = R_BIN_ENTRY_TYPE_FINI;\n\t\t} else if (!strcmp (sec->name, \".init_array\")) {\n\t\t\ttype = R_BIN_ENTRY_TYPE_INIT;\n\t\t} else if (!strcmp (sec->name, \".preinit_array\")) {\n\t\t\ttype = R_BIN_ENTRY_TYPE_PREINIT;\n\t\t}\n\t\tif (type != -1) {\n\t\t\tut8 *buf = calloc (sec->size, 1);\n\t\t\tif (!buf) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t(void)r_buf_read_at (bf->buf, sec->paddr, buf, sec->size);\n\t\t\tif (bits == 32) {\n\t\t\t\tfor (i = 0; i < sec->size; i += 4) {\n\t\t\t\t\tut32 addr32 = r_read_le32 (buf + i);\n\t\t\t\t\tif (addr32) {\n\t\t\t\t\t\tRBinAddr *ba = newEntry (sec->paddr + i, (ut64)addr32, type, bits);\n\t\t\t\t\t\tr_list_append (ret, ba);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (i = 0; i < sec->size; i += 8) {\n\t\t\t\t\tut64 addr64 = r_read_le64 (buf + i);\n\t\t\t\t\tif (addr64) {\n\t\t\t\t\t\tRBinAddr *ba = newEntry (sec->paddr + i, addr64, type, bits);\n\t\t\t\t\t\tr_list_append (ret, ba);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfree (buf);\n\t\t}\n\t}\n\tr_list_free (secs);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-11376", "cwe_id": "CWE-125" }, { "id": 777, "func": "static void process_constructors (RBinFile *bf, RList *ret, int bits) {\n\tRList *secs = sections (bf);\n\tRListIter *iter;\n\tRBinSection *sec;\n\tint i, type;\n\tr_list_foreach (secs, iter, sec) {\n\t\ttype = -1;\n\t\tif (!strcmp (sec->name, \".fini_array\")) {\n\t\t\ttype = R_BIN_ENTRY_TYPE_FINI;\n\t\t} else if (!strcmp (sec->name, \".init_array\")) {\n\t\t\ttype = R_BIN_ENTRY_TYPE_INIT;\n\t\t} else if (!strcmp (sec->name, \".preinit_array\")) {\n\t\t\ttype = R_BIN_ENTRY_TYPE_PREINIT;\n\t\t}\n\t\tif (type != -1) {\n\t\t\tut8 *buf = calloc (sec->size, 1);\n\t\t\tif (!buf) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t(void)r_buf_read_at (bf->buf, sec->paddr, buf, sec->size);\n\t\t\tif (bits == 32) {\n\t\t\t\tfor (i = 0; (i + 3) < sec->size; i += 4) {\n\t\t\t\t\tut32 addr32 = r_read_le32 (buf + i);\n\t\t\t\t\tif (addr32) {\n\t\t\t\t\t\tRBinAddr *ba = newEntry (sec->paddr + i, (ut64)addr32, type, bits);\n\t\t\t\t\t\tr_list_append (ret, ba);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (i = 0; (i + 7) < sec->size; i += 8) {\n\t\t\t\t\tut64 addr64 = r_read_le64 (buf + i);\n\t\t\t\t\tif (addr64) {\n\t\t\t\t\t\tRBinAddr *ba = newEntry (sec->paddr + i, addr64, type, bits);\n\t\t\t\t\t\tr_list_append (ret, ba);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfree (buf);\n\t\t}\n\t}\n\tr_list_free (secs);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-11376", "cwe_id": "CWE-125" }, { "id": 1133, "func": "static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsigned int src_size, double scale_d, const interpolation_method pFilter)\n{\n double width_d;\n double scale_f_d = 1.0;\n const double filter_width_d = DEFAULT_BOX_RADIUS;\n\tint windows_size;\n\tunsigned int u;\n\tLineContribType *res;\n\n if (scale_d < 1.0) {\n width_d = filter_width_d / scale_d;\n scale_f_d = scale_d;\n } else {\n width_d= filter_width_d;\n }\n\n windows_size = 2 * (int)ceil(width_d) + 1;\n res = _gdContributionsAlloc(line_size, windows_size);\n\n for (u = 0; u < line_size; u++) {\n const double dCenter = (double)u / scale_d;\n /* get the significant edge points affecting the pixel */\n register int iLeft = MAX(0, (int)floor (dCenter - width_d));\n int iRight = MIN((int)ceil(dCenter + width_d), (int)src_size - 1);\n double dTotalWeight = 0.0;\n\t\tint iSrc;\n\n res->ContribRow[u].Left = iLeft;\n res->ContribRow[u].Right = iRight;\n\n /* Cut edge points to fit in filter window in case of spill-off */\n if (iRight - iLeft + 1 > windows_size) {\n if (iLeft < ((int)src_size - 1 / 2)) {\n iLeft++;\n } else {\n iRight--;\n }\n }\n\n for (iSrc = iLeft; iSrc <= iRight; iSrc++) {\n dTotalWeight += (res->ContribRow[u].Weights[iSrc-iLeft] = scale_f_d * (*pFilter)(scale_f_d * (dCenter - (double)iSrc)));\n }\n\n\t\tif (dTotalWeight < 0.0) {\n\t\t\t_gdContributionsFree(res);\n\t\t\treturn NULL;\n\t\t}\n\n if (dTotalWeight > 0.0) {\n for (iSrc = iLeft; iSrc <= iRight; iSrc++) {\n res->ContribRow[u].Weights[iSrc-iLeft] /= dTotalWeight;\n }\n }\n }\n return res;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-7456", "cwe_id": "CWE-125" }, { "id": 1133, "func": "static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsigned int src_size, double scale_d, const interpolation_method pFilter)\n{\n double width_d;\n double scale_f_d = 1.0;\n const double filter_width_d = DEFAULT_BOX_RADIUS;\n\tint windows_size;\n\tunsigned int u;\n\tLineContribType *res;\n\n if (scale_d < 1.0) {\n width_d = filter_width_d / scale_d;\n scale_f_d = scale_d;\n } else {\n width_d= filter_width_d;\n }\n\n windows_size = 2 * (int)ceil(width_d) + 1;\n res = _gdContributionsAlloc(line_size, windows_size);\n\n for (u = 0; u < line_size; u++) {\n const double dCenter = (double)u / scale_d;\n /* get the significant edge points affecting the pixel */\n register int iLeft = MAX(0, (int)floor (dCenter - width_d));\n int iRight = MIN((int)ceil(dCenter + width_d), (int)src_size - 1);\n double dTotalWeight = 0.0;\n\t\tint iSrc;\n\n /* Cut edge points to fit in filter window in case of spill-off */\n if (iRight - iLeft + 1 > windows_size) {\n if (iLeft < ((int)src_size - 1 / 2)) {\n iLeft++;\n } else {\n iRight--;\n }\n }\n\n res->ContribRow[u].Left = iLeft;\n res->ContribRow[u].Right = iRight;\n\n for (iSrc = iLeft; iSrc <= iRight; iSrc++) {\n dTotalWeight += (res->ContribRow[u].Weights[iSrc-iLeft] = scale_f_d * (*pFilter)(scale_f_d * (dCenter - (double)iSrc)));\n }\n\n\t\tif (dTotalWeight < 0.0) {\n\t\t\t_gdContributionsFree(res);\n\t\t\treturn NULL;\n\t\t}\n\n if (dTotalWeight > 0.0) {\n for (iSrc = iLeft; iSrc <= iRight; iSrc++) {\n res->ContribRow[u].Weights[iSrc-iLeft] /= dTotalWeight;\n }\n }\n }\n return res;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-7456", "cwe_id": "CWE-125" }, { "id": 2133, "func": "BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)\n{\n\tint sx, sy;\n\tint i;\n\tint ncx, ncy, nc, cs, cx, cy;\n\tint x, y, ylo, yhi, xlo, xhi;\n\tint vers, fmt;\n\tt_chunk_info *chunkIdx = NULL;\t/* So we can gdFree it with impunity. */\n\tunsigned char *chunkBuf = NULL;\t/* So we can gdFree it with impunity. */\n\tint chunkNum = 0;\n\tint chunkMax = 0;\n\tuLongf chunkLen;\n\tint chunkPos = 0;\n\tint compMax = 0;\n\tint bytesPerPixel;\n\tchar *compBuf = NULL;\t\t/* So we can gdFree it with impunity. */\n\n\tgdImagePtr im;\n\n\t/* Get the header */\n\tim =\n\t _gd2CreateFromFile (in, &sx, &sy, &cs, &vers, &fmt, &ncx, &ncy,\n\t &chunkIdx);\n\tif (im == NULL) {\n\t\t/* No need to free chunkIdx as _gd2CreateFromFile does it for us. */\n\t\treturn 0;\n\t}\n\n\tbytesPerPixel = im->trueColor ? 4 : 1;\n\tnc = ncx * ncy;\n\n\tif (gd2_compressed (fmt)) {\n\t\t/* Find the maximum compressed chunk size. */\n\t\tcompMax = 0;\n\t\tfor (i = 0; (i < nc); i++) {\n\t\t\tif (chunkIdx[i].size > compMax) {\n\t\t\t\tcompMax = chunkIdx[i].size;\n\t\t\t};\n\t\t};\n\t\tcompMax++;\n\n\t\t/* Allocate buffers */\n\t\tchunkMax = cs * bytesPerPixel * cs;\n\t\tchunkBuf = gdCalloc (chunkMax, 1);\n\t\tif (!chunkBuf) {\n\t\t\tgoto fail;\n\t\t}\n\t\tcompBuf = gdCalloc (compMax, 1);\n\t\tif (!compBuf) {\n\t\t\tgoto fail;\n\t\t}\n\n\t\tGD2_DBG (printf (\"Largest compressed chunk is %d bytes\\n\", compMax));\n\t};\n\n\t/* if ( (ncx != sx / cs) || (ncy != sy / cs)) { */\n\t/* goto fail2; */\n\t/* }; */\n\n\t/* Read the data... */\n\tfor (cy = 0; (cy < ncy); cy++) {\n\t\tfor (cx = 0; (cx < ncx); cx++) {\n\n\t\t\tylo = cy * cs;\n\t\t\tyhi = ylo + cs;\n\t\t\tif (yhi > im->sy) {\n\t\t\t\tyhi = im->sy;\n\t\t\t};\n\n\t\t\tGD2_DBG (printf\n\t\t\t (\"Processing Chunk %d (%d, %d), y from %d to %d\\n\",\n\t\t\t chunkNum, cx, cy, ylo, yhi));\n\n\t\t\tif (gd2_compressed (fmt)) {\n\n\t\t\t\tchunkLen = chunkMax;\n\n\t\t\t\tif (!_gd2ReadChunk (chunkIdx[chunkNum].offset,\n\t\t\t\t compBuf,\n\t\t\t\t chunkIdx[chunkNum].size,\n\t\t\t\t (char *) chunkBuf, &chunkLen, in)) {\n\t\t\t\t\tGD2_DBG (printf (\"Error reading comproessed chunk\\n\"));\n\t\t\t\t\tgoto fail;\n\t\t\t\t};\n\n\t\t\t\tchunkPos = 0;\n\t\t\t};\n\n\t\t\tfor (y = ylo; (y < yhi); y++) {\n\n\t\t\t\txlo = cx * cs;\n\t\t\t\txhi = xlo + cs;\n\t\t\t\tif (xhi > im->sx) {\n\t\t\t\t\txhi = im->sx;\n\t\t\t\t};\n\t\t\t\t/*GD2_DBG(printf(\"y=%d: \",y)); */\n\t\t\t\tif (!gd2_compressed (fmt)) {\n\t\t\t\t\tfor (x = xlo; x < xhi; x++) {\n\n\t\t\t\t\t\tif (im->trueColor) {\n\t\t\t\t\t\t\tif (!gdGetInt (&im->tpixels[y][x], in)) {\n\t\t\t\t\t\t\t\t/*printf(\"EOF while reading\\n\"); */\n\t\t\t\t\t\t\t\t/*gdImageDestroy(im); */\n\t\t\t\t\t\t\t\t/*return 0; */\n\t\t\t\t\t\t\t\tim->tpixels[y][x] = 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tint ch;\n\t\t\t\t\t\t\tif (!gdGetByte (&ch, in)) {\n\t\t\t\t\t\t\t\t/*printf(\"EOF while reading\\n\"); */\n\t\t\t\t\t\t\t\t/*gdImageDestroy(im); */\n\t\t\t\t\t\t\t\t/*return 0; */\n\t\t\t\t\t\t\t\tch = 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tim->pixels[y][x] = ch;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (x = xlo; x < xhi; x++) {\n\t\t\t\t\t\tif (im->trueColor) {\n\t\t\t\t\t\t\t/* 2.0.1: work around a gcc bug by being verbose.\n\t\t\t\t\t\t\t TBB */\n\t\t\t\t\t\t\tint a = chunkBuf[chunkPos++] << 24;\n\t\t\t\t\t\t\tint r = chunkBuf[chunkPos++] << 16;\n\t\t\t\t\t\t\tint g = chunkBuf[chunkPos++] << 8;\n\t\t\t\t\t\t\tint b = chunkBuf[chunkPos++];\n\t\t\t\t\t\t\t/* 2.0.11: tpixels */\n\t\t\t\t\t\t\tim->tpixels[y][x] = a + r + g + b;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tim->pixels[y][x] = chunkBuf[chunkPos++];\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\t/*GD2_DBG(printf(\"\\n\")); */\n\t\t\t};\n\t\t\tchunkNum++;\n\t\t};\n\t};\n\n\tGD2_DBG (printf (\"Freeing memory\\n\"));\n\n\tgdFree (chunkBuf);\n\tgdFree (compBuf);\n\tgdFree (chunkIdx);\n\n\tGD2_DBG (printf (\"Done\\n\"));\n\n\treturn im;\n\nfail:\n\tgdImageDestroy (im);\n\tif (chunkBuf) {\n\t\tgdFree (chunkBuf);\n\t}\n\tif (compBuf) {\n\t\tgdFree (compBuf);\n\t}\n\tif (chunkIdx) {\n\t\tgdFree (chunkIdx);\n\t}\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10167", "cwe_id": "CWE-20" }, { "id": 2133, "func": "BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)\n{\n\tint sx, sy;\n\tint i;\n\tint ncx, ncy, nc, cs, cx, cy;\n\tint x, y, ylo, yhi, xlo, xhi;\n\tint vers, fmt;\n\tt_chunk_info *chunkIdx = NULL;\t/* So we can gdFree it with impunity. */\n\tunsigned char *chunkBuf = NULL;\t/* So we can gdFree it with impunity. */\n\tint chunkNum = 0;\n\tint chunkMax = 0;\n\tuLongf chunkLen;\n\tint chunkPos = 0;\n\tint compMax = 0;\n\tint bytesPerPixel;\n\tchar *compBuf = NULL;\t\t/* So we can gdFree it with impunity. */\n\n\tgdImagePtr im;\n\n\t/* Get the header */\n\tim =\n\t _gd2CreateFromFile (in, &sx, &sy, &cs, &vers, &fmt, &ncx, &ncy,\n\t &chunkIdx);\n\tif (im == NULL) {\n\t\t/* No need to free chunkIdx as _gd2CreateFromFile does it for us. */\n\t\treturn 0;\n\t}\n\n\tbytesPerPixel = im->trueColor ? 4 : 1;\n\tnc = ncx * ncy;\n\n\tif (gd2_compressed (fmt)) {\n\t\t/* Find the maximum compressed chunk size. */\n\t\tcompMax = 0;\n\t\tfor (i = 0; (i < nc); i++) {\n\t\t\tif (chunkIdx[i].size > compMax) {\n\t\t\t\tcompMax = chunkIdx[i].size;\n\t\t\t};\n\t\t};\n\t\tcompMax++;\n\n\t\t/* Allocate buffers */\n\t\tchunkMax = cs * bytesPerPixel * cs;\n\t\tchunkBuf = gdCalloc (chunkMax, 1);\n\t\tif (!chunkBuf) {\n\t\t\tgoto fail;\n\t\t}\n\t\tcompBuf = gdCalloc (compMax, 1);\n\t\tif (!compBuf) {\n\t\t\tgoto fail;\n\t\t}\n\n\t\tGD2_DBG (printf (\"Largest compressed chunk is %d bytes\\n\", compMax));\n\t};\n\n\t/* if ( (ncx != sx / cs) || (ncy != sy / cs)) { */\n\t/* goto fail2; */\n\t/* }; */\n\n\t/* Read the data... */\n\tfor (cy = 0; (cy < ncy); cy++) {\n\t\tfor (cx = 0; (cx < ncx); cx++) {\n\n\t\t\tylo = cy * cs;\n\t\t\tyhi = ylo + cs;\n\t\t\tif (yhi > im->sy) {\n\t\t\t\tyhi = im->sy;\n\t\t\t};\n\n\t\t\tGD2_DBG (printf\n\t\t\t (\"Processing Chunk %d (%d, %d), y from %d to %d\\n\",\n\t\t\t chunkNum, cx, cy, ylo, yhi));\n\n\t\t\tif (gd2_compressed (fmt)) {\n\n\t\t\t\tchunkLen = chunkMax;\n\n\t\t\t\tif (!_gd2ReadChunk (chunkIdx[chunkNum].offset,\n\t\t\t\t compBuf,\n\t\t\t\t chunkIdx[chunkNum].size,\n\t\t\t\t (char *) chunkBuf, &chunkLen, in)) {\n\t\t\t\t\tGD2_DBG (printf (\"Error reading comproessed chunk\\n\"));\n\t\t\t\t\tgoto fail;\n\t\t\t\t};\n\n\t\t\t\tchunkPos = 0;\n\t\t\t};\n\n\t\t\tfor (y = ylo; (y < yhi); y++) {\n\n\t\t\t\txlo = cx * cs;\n\t\t\t\txhi = xlo + cs;\n\t\t\t\tif (xhi > im->sx) {\n\t\t\t\t\txhi = im->sx;\n\t\t\t\t};\n\t\t\t\t/*GD2_DBG(printf(\"y=%d: \",y)); */\n\t\t\t\tif (!gd2_compressed (fmt)) {\n\t\t\t\t\tfor (x = xlo; x < xhi; x++) {\n\n\t\t\t\t\t\tif (im->trueColor) {\n\t\t\t\t\t\t\tif (!gdGetInt (&im->tpixels[y][x], in)) {\n\t\t\t\t\t\t\t\tgd_error(\"gd2: EOF while reading\\n\");\n\t\t\t\t\t\t\t\tgdImageDestroy(im);\n\t\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tint ch;\n\t\t\t\t\t\t\tif (!gdGetByte (&ch, in)) {\n\t\t\t\t\t\t\t\tgd_error(\"gd2: EOF while reading\\n\");\n\t\t\t\t\t\t\t\tgdImageDestroy(im);\n\t\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tim->pixels[y][x] = ch;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (x = xlo; x < xhi; x++) {\n\t\t\t\t\t\tif (im->trueColor) {\n\t\t\t\t\t\t\t/* 2.0.1: work around a gcc bug by being verbose.\n\t\t\t\t\t\t\t TBB */\n\t\t\t\t\t\t\tint a = chunkBuf[chunkPos++] << 24;\n\t\t\t\t\t\t\tint r = chunkBuf[chunkPos++] << 16;\n\t\t\t\t\t\t\tint g = chunkBuf[chunkPos++] << 8;\n\t\t\t\t\t\t\tint b = chunkBuf[chunkPos++];\n\t\t\t\t\t\t\t/* 2.0.11: tpixels */\n\t\t\t\t\t\t\tim->tpixels[y][x] = a + r + g + b;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tim->pixels[y][x] = chunkBuf[chunkPos++];\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\t/*GD2_DBG(printf(\"\\n\")); */\n\t\t\t};\n\t\t\tchunkNum++;\n\t\t};\n\t};\n\n\tGD2_DBG (printf (\"Freeing memory\\n\"));\n\n\tgdFree (chunkBuf);\n\tgdFree (compBuf);\n\tgdFree (chunkIdx);\n\n\tGD2_DBG (printf (\"Done\\n\"));\n\n\treturn im;\n\nfail:\n\tgdImageDestroy (im);\n\tif (chunkBuf) {\n\t\tgdFree (chunkBuf);\n\t}\n\tif (compBuf) {\n\t\tgdFree (compBuf);\n\t}\n\tif (chunkIdx) {\n\t\tgdFree (chunkIdx);\n\t}\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10167", "cwe_id": "CWE-20" }, { "id": 1959, "func": "void enc28j60WritePhyReg(NetInterface *interface, uint16_t address,\n uint16_t data)\n{\n //Write register address\n enc28j60WriteReg(interface, ENC28J60_REG_MIREGADR, address & REG_ADDR_MASK);\n\n //Write the lower 8 bits\n enc28j60WriteReg(interface, ENC28J60_REG_MIWRL, LSB(data));\n //Write the upper 8 bits\n enc28j60WriteReg(interface, ENC28J60_REG_MIWRH, MSB(data));\n\n //Wait until the PHY register has been written\n while((enc28j60ReadReg(interface, ENC28J60_REG_MISTAT) & MISTAT_BUSY) != 0)\n {\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1959, "func": "void enc28j60WritePhyReg(NetInterface *interface, uint16_t address,\n uint16_t data)\n{\n //Write register address\n enc28j60WriteReg(interface, ENC28J60_MIREGADR, address & REG_ADDR_MASK);\n\n //Write the lower 8 bits\n enc28j60WriteReg(interface, ENC28J60_MIWRL, LSB(data));\n //Write the upper 8 bits\n enc28j60WriteReg(interface, ENC28J60_MIWRH, MSB(data));\n\n //Wait until the PHY register has been written\n while((enc28j60ReadReg(interface, ENC28J60_MISTAT) & ENC28J60_MISTAT_BUSY) != 0)\n {\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 545, "func": "static void process_blob(struct rev_info *revs,\n\t\t\t struct blob *blob,\n\t\t\t show_object_fn show,\n\t\t\t struct strbuf *path,\n\t\t\t const char *name,\n\t\t\t void *cb_data)\n{\n\tstruct object *obj = &blob->object;\n\n\tif (!revs->blob_objects)\n\t\treturn;\n\tif (!obj)\n\t\tdie(\"bad blob object\");\n\tif (obj->flags & (UNINTERESTING | SEEN))\n\t\treturn;\n\tobj->flags |= SEEN;\n\tshow(obj, path, name, cb_data);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 545, "func": "static void process_blob(struct rev_info *revs,\n\t\t\t struct blob *blob,\n\t\t\t show_object_fn show,\n\t\t\t struct strbuf *path,\n\t\t\t const char *name,\n\t\t\t void *cb_data)\n{\n\tstruct object *obj = &blob->object;\n\tsize_t pathlen;\n\n\tif (!revs->blob_objects)\n\t\treturn;\n\tif (!obj)\n\t\tdie(\"bad blob object\");\n\tif (obj->flags & (UNINTERESTING | SEEN))\n\t\treturn;\n\tobj->flags |= SEEN;\n\n\tpathlen = path->len;\n\tstrbuf_addstr(path, name);\n\tshow(obj, path->buf, cb_data);\n\tstrbuf_setlen(path, pathlen);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 2630, "func": " bool CFontFileType1::RemovePfbMarkers()\n {\n bool bSuccess = true;\n\n int nBlockType = 0;\n int nBlockLen = 0;\n int nChar = 0;\n\n unsigned char *sBuffer = NULL;\n int nBufLen = 0;\n\n while ( nBlockType != PFB_DONE )\n {\n while ( 0 == nBlockLen )\n {\n nChar = ReadU8( &bSuccess );\n if ( !bSuccess )\n return false;\n\n nBlockType = ReadU8( &bSuccess );\n if ( !bSuccess || PFB_MARKER != nChar || ( PFB_ASCII != nBlockType && PFB_BINARY != nBlockType && PFB_DONE != nBlockType ) )\n return false;\n\n if ( PFB_DONE == nBlockType )\n break;\n\n nBlockLen = ReadU32LE( &bSuccess );\n if ( !bSuccess )\n return false;\n }\n\n // \u0427\u0438\u0442\u0430\u0435\u043c \u0441\u0430\u043c \u0431\u043b\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445\n if ( nBlockLen > 0 )\n {\n if ( !sBuffer )\n {\n sBuffer = (unsigned char*)MemUtilsMalloc( nBlockLen );\n if ( !sBuffer )\n return false;\n }\n else\n sBuffer = (unsigned char*)MemUtilsRealloc( sBuffer, nBufLen + nBlockLen );\n\n Read( sBuffer + nBufLen, nBlockLen );\n nBufLen += nBlockLen;\n }\n nBlockLen = 0;\n }\n\n if ( m_bFreeFileData )\n MemUtilsFree( m_sFile );\n\n m_bFreeFileData = true;\n m_sFile = (unsigned char*)sBuffer;\n m_sFileData = m_sFile;\n m_nLen = nBufLen;\n m_nPos = 0;\n\n return true;\n }", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-29777", "cwe_id": "CWE-787" }, { "id": 2630, "func": " bool CFontFileType1::RemovePfbMarkers()\n {\n bool bSuccess = true;\n\n int nBlockType = 0;\n int nBlockLen = 0;\n int nChar = 0;\n\n unsigned char *sBuffer = NULL;\n unsigned int nBufLen = 0;\n\n while ( nBlockType != PFB_DONE )\n {\n while ( 0 == nBlockLen )\n {\n nChar = ReadU8( &bSuccess );\n if ( !bSuccess )\n return false;\n\n nBlockType = ReadU8( &bSuccess );\n if ( !bSuccess || PFB_MARKER != nChar || ( PFB_ASCII != nBlockType && PFB_BINARY != nBlockType && PFB_DONE != nBlockType ) )\n return false;\n\n if ( PFB_DONE == nBlockType )\n break;\n\n nBlockLen = ReadU32LE( &bSuccess );\n if ( !bSuccess )\n return false;\n }\n\n // \u0427\u0438\u0442\u0430\u0435\u043c \u0441\u0430\u043c \u0431\u043b\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445\n if ( nBlockLen > 0 )\n {\n if ( !sBuffer )\n {\n sBuffer = (unsigned char*)MemUtilsMalloc( nBlockLen );\n if ( !sBuffer )\n return false;\n }\n else\n sBuffer = (unsigned char*)MemUtilsRealloc( sBuffer, nBufLen + nBlockLen );\n\n Read( sBuffer + nBufLen, nBlockLen );\n nBufLen += nBlockLen;\n }\n nBlockLen = 0;\n }\n\n if ( m_bFreeFileData )\n MemUtilsFree( m_sFile );\n\n m_bFreeFileData = true;\n m_sFile = (unsigned char*)sBuffer;\n m_sFileData = m_sFile;\n m_nLen = nBufLen;\n m_nPos = 0;\n\n return true;\n }", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-29777", "cwe_id": "CWE-787" }, { "id": 1800, "func": "ast_for_call(struct compiling *c, const node *n, expr_ty func,\n const node *maybegenbeg, const node *closepar)\n{\n /*\n arglist: argument (',' argument)* [',']\n argument: ( test [comp_for] | '*' test | test '=' test | '**' test )\n */\n\n int i, nargs, nkeywords;\n int ndoublestars;\n asdl_seq *args;\n asdl_seq *keywords;\n\n REQ(n, arglist);\n\n nargs = 0;\n nkeywords = 0;\n for (i = 0; i < NCH(n); i++) {\n node *ch = CHILD(n, i);\n if (TYPE(ch) == argument) {\n if (NCH(ch) == 1)\n nargs++;\n else if (TYPE(CHILD(ch, 1)) == comp_for) {\n nargs++;\n if (!maybegenbeg) {\n ast_error(c, ch, \"invalid syntax\");\n return NULL;\n }\n if (NCH(n) > 1) {\n ast_error(c, ch, \"Generator expression must be parenthesized\");\n return NULL;\n }\n }\n else if (TYPE(CHILD(ch, 0)) == STAR)\n nargs++;\n else if (TYPE(CHILD(ch, 1)) == COLONEQUAL) {\n nargs++;\n }\n else\n /* TYPE(CHILD(ch, 0)) == DOUBLESTAR or keyword argument */\n nkeywords++;\n }\n }\n\n args = _Py_asdl_seq_new(nargs, c->c_arena);\n if (!args)\n return NULL;\n keywords = _Py_asdl_seq_new(nkeywords, c->c_arena);\n if (!keywords)\n return NULL;\n\n nargs = 0; /* positional arguments + iterable argument unpackings */\n nkeywords = 0; /* keyword arguments + keyword argument unpackings */\n ndoublestars = 0; /* just keyword argument unpackings */\n for (i = 0; i < NCH(n); i++) {\n node *ch = CHILD(n, i);\n if (TYPE(ch) == argument) {\n expr_ty e;\n node *chch = CHILD(ch, 0);\n if (NCH(ch) == 1) {\n /* a positional argument */\n if (nkeywords) {\n if (ndoublestars) {\n ast_error(c, chch,\n \"positional argument follows \"\n \"keyword argument unpacking\");\n }\n else {\n ast_error(c, chch,\n \"positional argument follows \"\n \"keyword argument\");\n }\n return NULL;\n }\n e = ast_for_expr(c, chch);\n if (!e)\n return NULL;\n asdl_seq_SET(args, nargs++, e);\n }\n else if (TYPE(chch) == STAR) {\n /* an iterable argument unpacking */\n expr_ty starred;\n if (ndoublestars) {\n ast_error(c, chch,\n \"iterable argument unpacking follows \"\n \"keyword argument unpacking\");\n return NULL;\n }\n e = ast_for_expr(c, CHILD(ch, 1));\n if (!e)\n return NULL;\n starred = Starred(e, Load, LINENO(chch),\n chch->n_col_offset,\n chch->n_end_lineno, chch->n_end_col_offset,\n c->c_arena);\n if (!starred)\n return NULL;\n asdl_seq_SET(args, nargs++, starred);\n\n }\n else if (TYPE(chch) == DOUBLESTAR) {\n /* a keyword argument unpacking */\n keyword_ty kw;\n i++;\n e = ast_for_expr(c, CHILD(ch, 1));\n if (!e)\n return NULL;\n kw = keyword(NULL, e, c->c_arena);\n asdl_seq_SET(keywords, nkeywords++, kw);\n ndoublestars++;\n }\n else if (TYPE(CHILD(ch, 1)) == comp_for) {\n /* the lone generator expression */\n e = copy_location(ast_for_genexp(c, ch), maybegenbeg);\n if (!e)\n return NULL;\n asdl_seq_SET(args, nargs++, e);\n }\n else if (TYPE(CHILD(ch, 1)) == COLONEQUAL) {\n /* treat colon equal as positional argument */\n if (nkeywords) {\n if (ndoublestars) {\n ast_error(c, chch,\n \"positional argument follows \"\n \"keyword argument unpacking\");\n }\n else {\n ast_error(c, chch,\n \"positional argument follows \"\n \"keyword argument\");\n }\n return NULL;\n }\n e = ast_for_namedexpr(c, ch);\n if (!e)\n return NULL;\n asdl_seq_SET(args, nargs++, e);\n }\n else {\n /* a keyword argument */\n keyword_ty kw;\n identifier key, tmp;\n int k;\n\n // To remain LL(1), the grammar accepts any test (basically, any\n // expression) in the keyword slot of a call site. So, we need\n // to manually enforce that the keyword is a NAME here.\n static const int name_tree[] = {\n test,\n or_test,\n and_test,\n not_test,\n comparison,\n expr,\n xor_expr,\n and_expr,\n shift_expr,\n arith_expr,\n term,\n factor,\n power,\n atom_expr,\n atom,\n 0,\n };\n node *expr_node = chch;\n for (int i = 0; name_tree[i]; i++) {\n if (TYPE(expr_node) != name_tree[i])\n break;\n if (NCH(expr_node) != 1)\n break;\n expr_node = CHILD(expr_node, 0);\n }\n if (TYPE(expr_node) != NAME) {\n ast_error(c, chch,\n \"expression cannot contain assignment, \"\n \"perhaps you meant \\\"==\\\"?\");\n return NULL;\n }\n key = new_identifier(STR(expr_node), c);\n if (key == NULL) {\n return NULL;\n }\n if (forbidden_name(c, key, chch, 1)) {\n return NULL;\n }\n for (k = 0; k < nkeywords; k++) {\n tmp = ((keyword_ty)asdl_seq_GET(keywords, k))->arg;\n if (tmp && !PyUnicode_Compare(tmp, key)) {\n ast_error(c, chch,\n \"keyword argument repeated\");\n return NULL;\n }\n }\n e = ast_for_expr(c, CHILD(ch, 2));\n if (!e)\n return NULL;\n kw = keyword(key, e, c->c_arena);\n if (!kw)\n return NULL;\n asdl_seq_SET(keywords, nkeywords++, kw);\n }\n }\n }\n\n return Call(func, args, keywords, func->lineno, func->col_offset,\n closepar->n_end_lineno, closepar->n_end_col_offset, c->c_arena);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1800, "func": "ast_for_call(struct compiling *c, const node *n, expr_ty func,\n const node *maybegenbeg, const node *closepar)\n{\n /*\n arglist: argument (',' argument)* [',']\n argument: ( test [comp_for] | '*' test | test '=' test | '**' test )\n */\n\n int i, nargs, nkeywords;\n int ndoublestars;\n asdl_seq *args;\n asdl_seq *keywords;\n\n REQ(n, arglist);\n\n nargs = 0;\n nkeywords = 0;\n for (i = 0; i < NCH(n); i++) {\n node *ch = CHILD(n, i);\n if (TYPE(ch) == argument) {\n if (NCH(ch) == 1)\n nargs++;\n else if (TYPE(CHILD(ch, 1)) == comp_for) {\n nargs++;\n if (!maybegenbeg) {\n ast_error(c, ch, \"invalid syntax\");\n return NULL;\n }\n if (NCH(n) > 1) {\n ast_error(c, ch, \"Generator expression must be parenthesized\");\n return NULL;\n }\n }\n else if (TYPE(CHILD(ch, 0)) == STAR)\n nargs++;\n else if (TYPE(CHILD(ch, 1)) == COLONEQUAL) {\n nargs++;\n }\n else\n /* TYPE(CHILD(ch, 0)) == DOUBLESTAR or keyword argument */\n nkeywords++;\n }\n }\n\n args = _Py_asdl_seq_new(nargs, c->c_arena);\n if (!args)\n return NULL;\n keywords = _Py_asdl_seq_new(nkeywords, c->c_arena);\n if (!keywords)\n return NULL;\n\n nargs = 0; /* positional arguments + iterable argument unpackings */\n nkeywords = 0; /* keyword arguments + keyword argument unpackings */\n ndoublestars = 0; /* just keyword argument unpackings */\n for (i = 0; i < NCH(n); i++) {\n node *ch = CHILD(n, i);\n if (TYPE(ch) == argument) {\n expr_ty e;\n node *chch = CHILD(ch, 0);\n if (NCH(ch) == 1) {\n /* a positional argument */\n if (nkeywords) {\n if (ndoublestars) {\n ast_error(c, chch,\n \"positional argument follows \"\n \"keyword argument unpacking\");\n }\n else {\n ast_error(c, chch,\n \"positional argument follows \"\n \"keyword argument\");\n }\n return NULL;\n }\n e = ast_for_expr(c, chch);\n if (!e)\n return NULL;\n asdl_seq_SET(args, nargs++, e);\n }\n else if (TYPE(chch) == STAR) {\n /* an iterable argument unpacking */\n expr_ty starred;\n if (ndoublestars) {\n ast_error(c, chch,\n \"iterable argument unpacking follows \"\n \"keyword argument unpacking\");\n return NULL;\n }\n e = ast_for_expr(c, CHILD(ch, 1));\n if (!e)\n return NULL;\n starred = Starred(e, Load, LINENO(chch),\n chch->n_col_offset,\n chch->n_end_lineno, chch->n_end_col_offset,\n c->c_arena);\n if (!starred)\n return NULL;\n asdl_seq_SET(args, nargs++, starred);\n\n }\n else if (TYPE(chch) == DOUBLESTAR) {\n /* a keyword argument unpacking */\n keyword_ty kw;\n i++;\n e = ast_for_expr(c, CHILD(ch, 1));\n if (!e)\n return NULL;\n kw = keyword(NULL, e, c->c_arena);\n asdl_seq_SET(keywords, nkeywords++, kw);\n ndoublestars++;\n }\n else if (TYPE(CHILD(ch, 1)) == comp_for) {\n /* the lone generator expression */\n e = copy_location(ast_for_genexp(c, ch), maybegenbeg);\n if (!e)\n return NULL;\n asdl_seq_SET(args, nargs++, e);\n }\n else if (TYPE(CHILD(ch, 1)) == COLONEQUAL) {\n /* treat colon equal as positional argument */\n if (nkeywords) {\n if (ndoublestars) {\n ast_error(c, chch,\n \"positional argument follows \"\n \"keyword argument unpacking\");\n }\n else {\n ast_error(c, chch,\n \"positional argument follows \"\n \"keyword argument\");\n }\n return NULL;\n }\n e = ast_for_namedexpr(c, ch);\n if (!e)\n return NULL;\n asdl_seq_SET(args, nargs++, e);\n }\n else {\n /* a keyword argument */\n keyword_ty kw;\n identifier key, tmp;\n int k;\n\n // To remain LL(1), the grammar accepts any test (basically, any\n // expression) in the keyword slot of a call site. So, we need\n // to manually enforce that the keyword is a NAME here.\n static const int name_tree[] = {\n test,\n or_test,\n and_test,\n not_test,\n comparison,\n expr,\n xor_expr,\n and_expr,\n shift_expr,\n arith_expr,\n term,\n factor,\n power,\n atom_expr,\n atom,\n 0,\n };\n node *expr_node = chch;\n for (int i = 0; name_tree[i]; i++) {\n if (TYPE(expr_node) != name_tree[i])\n break;\n if (NCH(expr_node) != 1)\n break;\n expr_node = CHILD(expr_node, 0);\n }\n if (TYPE(expr_node) != NAME) {\n ast_error(c, chch,\n \"expression cannot contain assignment, \"\n \"perhaps you meant \\\"==\\\"?\");\n return NULL;\n }\n key = new_identifier(STR(expr_node), c);\n if (key == NULL) {\n return NULL;\n }\n if (forbidden_name(c, key, chch, 1)) {\n return NULL;\n }\n for (k = 0; k < nkeywords; k++) {\n tmp = ((keyword_ty)asdl_seq_GET(keywords, k))->arg;\n if (tmp && !PyUnicode_Compare(tmp, key)) {\n ast_error(c, chch,\n \"keyword argument repeated\");\n return NULL;\n }\n }\n e = ast_for_expr(c, CHILD(ch, 2));\n if (!e)\n return NULL;\n kw = keyword(key, e, c->c_arena);\n if (!kw)\n return NULL;\n asdl_seq_SET(keywords, nkeywords++, kw);\n }\n }\n }\n\n return Call(func, args, keywords, func->lineno, func->col_offset,\n closepar->n_end_lineno, closepar->n_end_col_offset, c->c_arena);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2979, "func": "jas_image_t *jas_image_create(int numcmpts, jas_image_cmptparm_t *cmptparms,\n int clrspc)\n{\n\tjas_image_t *image;\n\tuint_fast32_t rawsize;\n\tuint_fast32_t inmem;\n\tint cmptno;\n\tjas_image_cmptparm_t *cmptparm;\n\n\tif (!(image = jas_image_create0())) {\n\t\treturn 0;\n\t}\n\n\timage->clrspc_ = clrspc;\n\timage->maxcmpts_ = numcmpts;\n\timage->inmem_ = true;\n\n\t/* Allocate memory for the per-component information. */\n\tif (!(image->cmpts_ = jas_alloc2(image->maxcmpts_,\n\t sizeof(jas_image_cmpt_t *)))) {\n\t\tjas_image_destroy(image);\n\t\treturn 0;\n\t}\n\t/* Initialize in case of failure. */\n\tfor (cmptno = 0; cmptno < image->maxcmpts_; ++cmptno) {\n\t\timage->cmpts_[cmptno] = 0;\n\t}\n\n\t/* Compute the approximate raw size of the image. */\n\trawsize = 0;\n\tfor (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,\n\t ++cmptparm) {\n\t\trawsize += cmptparm->width * cmptparm->height *\n\t\t (cmptparm->prec + 7) / 8;\n\t}\n\t/* Decide whether to buffer the image data in memory, based on the\n\t raw size of the image. */\n\tinmem = (rawsize < JAS_IMAGE_INMEMTHRESH);\n\n\t/* Create the individual image components. */\n\tfor (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,\n\t ++cmptparm) {\n\t\tif (!(image->cmpts_[cmptno] = jas_image_cmpt_create(cmptparm->tlx,\n\t\t cmptparm->tly, cmptparm->hstep, cmptparm->vstep,\n\t\t cmptparm->width, cmptparm->height, cmptparm->prec,\n\t\t cmptparm->sgnd, inmem))) {\n\t\t\tjas_image_destroy(image);\n\t\t\treturn 0;\n\t\t}\n\t\t++image->numcmpts_;\n\t}\n\n\t/* Determine the bounding box for all of the components on the\n\t reference grid (i.e., the image area) */\n\tjas_image_setbbox(image);\n\n\treturn image;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 2979, "func": "jas_image_t *jas_image_create(int numcmpts, jas_image_cmptparm_t *cmptparms,\n int clrspc)\n{\n\tjas_image_t *image;\n\tsize_t rawsize;\n\tuint_fast32_t inmem;\n\tint cmptno;\n\tjas_image_cmptparm_t *cmptparm;\n\n\timage = 0;\n\n\tJAS_DBGLOG(100, (\"jas_image_create(%d, %p, %d)\\n\", numcmpts, cmptparms,\n\t clrspc));\n\n\tif (!(image = jas_image_create0())) {\n\t\tgoto error;\n\t}\n\n\timage->clrspc_ = clrspc;\n\timage->maxcmpts_ = numcmpts;\n//\timage->inmem_ = true;\n\n\t/* Allocate memory for the per-component information. */\n\tif (!(image->cmpts_ = jas_alloc2(image->maxcmpts_,\n\t sizeof(jas_image_cmpt_t *)))) {\n\t\tgoto error;\n\t}\n\t/* Initialize in case of failure. */\n\tfor (cmptno = 0; cmptno < image->maxcmpts_; ++cmptno) {\n\t\timage->cmpts_[cmptno] = 0;\n\t}\n\n#if 0\n\t/* Compute the approximate raw size of the image. */\n\trawsize = 0;\n\tfor (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,\n\t ++cmptparm) {\n\t\trawsize += cmptparm->width * cmptparm->height *\n\t\t (cmptparm->prec + 7) / 8;\n\t}\n\t/* Decide whether to buffer the image data in memory, based on the\n\t raw size of the image. */\n\tinmem = (rawsize < JAS_IMAGE_INMEMTHRESH);\n#endif\n\n\t/* Create the individual image components. */\n\tfor (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,\n\t ++cmptparm) {\n\t\tif (!jas_safe_size_mul3(cmptparm->width, cmptparm->height,\n\t\t (cmptparm->prec + 7), &rawsize)) {\n\t\t\tgoto error;\n\t\t}\n\t\trawsize /= 8;\n\t\tinmem = (rawsize < JAS_IMAGE_INMEMTHRESH);\n\t\tif (!(image->cmpts_[cmptno] = jas_image_cmpt_create(cmptparm->tlx,\n\t\t cmptparm->tly, cmptparm->hstep, cmptparm->vstep,\n\t\t cmptparm->width, cmptparm->height, cmptparm->prec,\n\t\t cmptparm->sgnd, inmem))) {\n\t\t\tgoto error;\n\t\t}\n\t\t++image->numcmpts_;\n\t}\n\n\t/* Determine the bounding box for all of the components on the\n\t reference grid (i.e., the image area) */\n\tjas_image_setbbox(image);\n\n\treturn image;\n\nerror:\n\tif (image) {\n\t\tjas_image_destroy(image);\n\t}\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 1160, "func": " */\nstatic void php_wddx_pop_element(void *user_data, const XML_Char *name)\n{\n\tst_entry \t\t\t*ent1, *ent2;\n\twddx_stack \t\t\t*stack = (wddx_stack *)user_data;\n\tHashTable \t\t\t*target_hash;\n\tzend_class_entry \t**pce;\n\tzval\t\t\t\t*obj;\n\tzval\t\t\t\t*tmp;\n\tTSRMLS_FETCH();\n\n/* OBJECTS_FIXME */\n\tif (stack->top == 0) {\n\t\treturn;\n\t}\n\n\tif (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) ||\n\t\t!strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) ||\n\t \t!strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) ||\n\t\t!strcmp(name, EL_RECORDSET) || !strcmp(name, EL_BINARY) ||\n\t\t!strcmp(name, EL_DATETIME)) {\n\t\twddx_stack_top(stack, (void**)&ent1);\n\n\t\tif (!ent1->data) {\n\t\t\tif (stack->top > 1) {\n\t\t\t\tstack->top--;\n\t\t\t} else {\n\t\t\t\tstack->done = 1;\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!strcmp(name, EL_BINARY)) {\n\t\t\tint new_len=0;\n\t\t\tunsigned char *new_str;\n\n\t\t\tnew_str = php_base64_decode(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data), &new_len);\n\t\t\tSTR_FREE(Z_STRVAL_P(ent1->data));\n\t\t\tZ_STRVAL_P(ent1->data) = new_str;\n\t\t\tZ_STRLEN_P(ent1->data) = new_len;\n\t\t}\n\n\t\t/* Call __wakeup() method on the object. */\n\t\tif (Z_TYPE_P(ent1->data) == IS_OBJECT) {\n\t\t\tzval *fname, *retval = NULL;\n\n\t\t\tMAKE_STD_ZVAL(fname);\n\t\t\tZVAL_STRING(fname, \"__wakeup\", 1);\n\n\t\t\tcall_user_function_ex(NULL, &ent1->data, fname, &retval, 0, 0, 0, NULL TSRMLS_CC);\n\n\t\t\tzval_dtor(fname);\n\t\t\tFREE_ZVAL(fname);\n\t\t\tif (retval) {\n\t\t\t\tzval_ptr_dtor(&retval);\n\t\t\t}\n\t\t}\n\n\t\tif (stack->top > 1) {\n\t\t\tstack->top--;\n\t\t\twddx_stack_top(stack, (void**)&ent2);\n\n\t\t\t/* if non-existent field */\n\t\t\tif (ent2->type == ST_FIELD && ent2->data == NULL) {\n\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\tefree(ent1);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Z_TYPE_P(ent2->data) == IS_ARRAY || Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\ttarget_hash = HASH_OF(ent2->data);\n\n\t\t\t\tif (ent1->varname) {\n\t\t\t\t\tif (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&\n\t\t\t\t\t\tZ_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) &&\n\t\t\t\t\t\tent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) {\n\t\t\t\t\t\tzend_bool incomplete_class = 0;\n\n\t\t\t\t\t\tzend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\tif (zend_hash_find(EG(class_table), Z_STRVAL_P(ent1->data),\n\t\t\t\t\t\t\t\t\t\t Z_STRLEN_P(ent1->data)+1, (void **) &pce)==FAILURE) {\n\t\t\t\t\t\t\tincomplete_class = 1;\n\t\t\t\t\t\t\tpce = &PHP_IC_ENTRY;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/* Initialize target object */\n\t\t\t\t\t\tMAKE_STD_ZVAL(obj);\n\t\t\t\t\t\tobject_init_ex(obj, *pce);\n\n\t\t\t\t\t\t/* Merge current hashtable with object's default properties */\n\t\t\t\t\t\tzend_hash_merge(Z_OBJPROP_P(obj),\n\t\t\t\t\t\t\t\t\t\tZ_ARRVAL_P(ent2->data),\n\t\t\t\t\t\t\t\t\t\t(void (*)(void *)) zval_add_ref,\n\t\t\t\t\t\t\t\t\t\t(void *) &tmp, sizeof(zval *), 0);\n\n\t\t\t\t\t\tif (incomplete_class) {\n\t\t\t\t\t\t\tphp_store_class_name(obj, Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/* Clean up old array entry */\n\t\t\t\t\t\tzval_ptr_dtor(&ent2->data);\n\n\t\t\t\t\t\t/* Set stack entry to point to the newly created object */\n\t\t\t\t\t\tent2->data = obj;\n\n\t\t\t\t\t\t/* Clean up class name var entry */\n\t\t\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\t\t} else if (Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\t\t\tzend_class_entry *old_scope = EG(scope);\n\n\t\t\t\t\t\tEG(scope) = Z_OBJCE_P(ent2->data);\n\t\t\t\t\t\tZ_DELREF_P(ent1->data);\n\t\t\t\t\t\tadd_property_zval(ent2->data, ent1->varname, ent1->data);\n\t\t\t\t\t\tEG(scope) = old_scope;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tzend_symtable_update(target_hash, ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t\t}\n\t\t\t\t\tefree(ent1->varname);\n\t\t\t\t} else\t{\n\t\t\t\t\tzend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t}\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t} else {\n\t\t\tstack->done = 1;\n\t\t}\n\t} else if (!strcmp(name, EL_VAR) && stack->varname) {\n\t\tefree(stack->varname);\n\t\tstack->varname = NULL;\n\t} else if (!strcmp(name, EL_FIELD)) {\n\t\tst_entry *ent;\n\t\twddx_stack_top(stack, (void **)&ent);\n\t\tefree(ent);\n\t\tstack->top--;\n\t}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-7130", "cwe_id": "CWE-476" }, { "id": 1160, "func": " */\nstatic void php_wddx_pop_element(void *user_data, const XML_Char *name)\n{\n\tst_entry \t\t\t*ent1, *ent2;\n\twddx_stack \t\t\t*stack = (wddx_stack *)user_data;\n\tHashTable \t\t\t*target_hash;\n\tzend_class_entry \t**pce;\n\tzval\t\t\t\t*obj;\n\tzval\t\t\t\t*tmp;\n\tTSRMLS_FETCH();\n\n/* OBJECTS_FIXME */\n\tif (stack->top == 0) {\n\t\treturn;\n\t}\n\n\tif (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) ||\n\t\t!strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) ||\n\t \t!strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) ||\n\t\t!strcmp(name, EL_RECORDSET) || !strcmp(name, EL_BINARY) ||\n\t\t!strcmp(name, EL_DATETIME)) {\n\t\twddx_stack_top(stack, (void**)&ent1);\n\n\t\tif (!ent1->data) {\n\t\t\tif (stack->top > 1) {\n\t\t\t\tstack->top--;\n\t\t\t} else {\n\t\t\t\tstack->done = 1;\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!strcmp(name, EL_BINARY)) {\n\t\t\tint new_len=0;\n\t\t\tunsigned char *new_str;\n\n\t\t\tnew_str = php_base64_decode(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data), &new_len);\n\t\t\tSTR_FREE(Z_STRVAL_P(ent1->data));\n\t\t\tif (new_str) {\n\t\t\t\tZ_STRVAL_P(ent1->data) = new_str;\n\t\t\t\tZ_STRLEN_P(ent1->data) = new_len;\n\t\t\t} else {\n\t\t\t\tZVAL_EMPTY_STRING(ent1->data);\n\t\t\t}\n\t\t}\n\n\t\t/* Call __wakeup() method on the object. */\n\t\tif (Z_TYPE_P(ent1->data) == IS_OBJECT) {\n\t\t\tzval *fname, *retval = NULL;\n\n\t\t\tMAKE_STD_ZVAL(fname);\n\t\t\tZVAL_STRING(fname, \"__wakeup\", 1);\n\n\t\t\tcall_user_function_ex(NULL, &ent1->data, fname, &retval, 0, 0, 0, NULL TSRMLS_CC);\n\n\t\t\tzval_dtor(fname);\n\t\t\tFREE_ZVAL(fname);\n\t\t\tif (retval) {\n\t\t\t\tzval_ptr_dtor(&retval);\n\t\t\t}\n\t\t}\n\n\t\tif (stack->top > 1) {\n\t\t\tstack->top--;\n\t\t\twddx_stack_top(stack, (void**)&ent2);\n\n\t\t\t/* if non-existent field */\n\t\t\tif (ent2->type == ST_FIELD && ent2->data == NULL) {\n\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\tefree(ent1);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Z_TYPE_P(ent2->data) == IS_ARRAY || Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\ttarget_hash = HASH_OF(ent2->data);\n\n\t\t\t\tif (ent1->varname) {\n\t\t\t\t\tif (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&\n\t\t\t\t\t\tZ_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) &&\n\t\t\t\t\t\tent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) {\n\t\t\t\t\t\tzend_bool incomplete_class = 0;\n\n\t\t\t\t\t\tzend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\tif (zend_hash_find(EG(class_table), Z_STRVAL_P(ent1->data),\n\t\t\t\t\t\t\t\t\t\t Z_STRLEN_P(ent1->data)+1, (void **) &pce)==FAILURE) {\n\t\t\t\t\t\t\tincomplete_class = 1;\n\t\t\t\t\t\t\tpce = &PHP_IC_ENTRY;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/* Initialize target object */\n\t\t\t\t\t\tMAKE_STD_ZVAL(obj);\n\t\t\t\t\t\tobject_init_ex(obj, *pce);\n\n\t\t\t\t\t\t/* Merge current hashtable with object's default properties */\n\t\t\t\t\t\tzend_hash_merge(Z_OBJPROP_P(obj),\n\t\t\t\t\t\t\t\t\t\tZ_ARRVAL_P(ent2->data),\n\t\t\t\t\t\t\t\t\t\t(void (*)(void *)) zval_add_ref,\n\t\t\t\t\t\t\t\t\t\t(void *) &tmp, sizeof(zval *), 0);\n\n\t\t\t\t\t\tif (incomplete_class) {\n\t\t\t\t\t\t\tphp_store_class_name(obj, Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/* Clean up old array entry */\n\t\t\t\t\t\tzval_ptr_dtor(&ent2->data);\n\n\t\t\t\t\t\t/* Set stack entry to point to the newly created object */\n\t\t\t\t\t\tent2->data = obj;\n\n\t\t\t\t\t\t/* Clean up class name var entry */\n\t\t\t\t\t\tzval_ptr_dtor(&ent1->data);\n\t\t\t\t\t} else if (Z_TYPE_P(ent2->data) == IS_OBJECT) {\n\t\t\t\t\t\tzend_class_entry *old_scope = EG(scope);\n\n\t\t\t\t\t\tEG(scope) = Z_OBJCE_P(ent2->data);\n\t\t\t\t\t\tZ_DELREF_P(ent1->data);\n\t\t\t\t\t\tadd_property_zval(ent2->data, ent1->varname, ent1->data);\n\t\t\t\t\t\tEG(scope) = old_scope;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tzend_symtable_update(target_hash, ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t\t}\n\t\t\t\t\tefree(ent1->varname);\n\t\t\t\t} else\t{\n\t\t\t\t\tzend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL);\n\t\t\t\t}\n\t\t\t}\n\t\t\tefree(ent1);\n\t\t} else {\n\t\t\tstack->done = 1;\n\t\t}\n\t} else if (!strcmp(name, EL_VAR) && stack->varname) {\n\t\tefree(stack->varname);\n\t\tstack->varname = NULL;\n\t} else if (!strcmp(name, EL_FIELD)) {\n\t\tst_entry *ent;\n\t\twddx_stack_top(stack, (void **)&ent);\n\t\tefree(ent);\n\t\tstack->top--;\n\t}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-7130", "cwe_id": "CWE-476" }, { "id": 1756, "func": "static void nsc_encode_sse2(NSC_CONTEXT* context, const BYTE* data,\n UINT32 scanline)\n{\n\tnsc_encode_argb_to_aycocg_sse2(context, data, scanline);\n\n\tif (context->ChromaSubsamplingLevel > 0)\n\t{\n\t\tnsc_encode_subsampling_sse2(context);\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-8788", "cwe_id": "CWE-787" }, { "id": 1756, "func": "static BOOL nsc_encode_sse2(NSC_CONTEXT* context, const BYTE* data,\n UINT32 scanline)\n{\n\tnsc_encode_argb_to_aycocg_sse2(context, data, scanline);\n\n\tif (context->ChromaSubsamplingLevel > 0)\n\t{\n\t\tnsc_encode_subsampling_sse2(context);\n\t}\n\n\treturn TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-8788", "cwe_id": "CWE-787" }, { "id": 2569, "func": "MOBI_RET mobi_parse_huff(MOBIHuffCdic *huffcdic, const MOBIPdbRecord *record) {\n MOBIBuffer *buf = mobi_buffer_init_null(record->data, record->size);\n if (buf == NULL) {\n debug_print(\"%s\\n\", \"Memory allocation failed\");\n return MOBI_MALLOC_FAILED;\n }\n char huff_magic[5];\n mobi_buffer_getstring(huff_magic, buf, 4);\n const size_t header_length = mobi_buffer_get32(buf);\n if (strncmp(huff_magic, HUFF_MAGIC, 4) != 0 || header_length < HUFF_HEADER_LEN) {\n debug_print(\"HUFF wrong magic: %s\\n\", huff_magic);\n mobi_buffer_free_null(buf);\n return MOBI_DATA_CORRUPT;\n }\n const size_t data1_offset = mobi_buffer_get32(buf);\n const size_t data2_offset = mobi_buffer_get32(buf);\n /* skip little-endian table offsets */\n mobi_buffer_setpos(buf, data1_offset);\n if (buf->offset + (256 * 4) > buf->maxlen) {\n debug_print(\"%s\", \"HUFF data1 too short\\n\");\n mobi_buffer_free_null(buf);\n return MOBI_DATA_CORRUPT;\n }\n /* read 256 indices from data1 big-endian */\n for (int i = 0; i < 256; i++) {\n huffcdic->table1[i] = mobi_buffer_get32(buf);\n }\n mobi_buffer_setpos(buf, data2_offset);\n if (buf->offset + (64 * 4) > buf->maxlen) {\n debug_print(\"%s\", \"HUFF data2 too short\\n\");\n mobi_buffer_free_null(buf);\n return MOBI_DATA_CORRUPT;\n }\n /* read 32 mincode-maxcode pairs from data2 big-endian */\n huffcdic->mincode_table[0] = 0;\n huffcdic->maxcode_table[0] = 0xFFFFFFFF;\n for (int i = 1; i < 33; i++) {\n const uint32_t mincode = mobi_buffer_get32(buf);\n const uint32_t maxcode = mobi_buffer_get32(buf);\n huffcdic->mincode_table[i] = mincode << (32 - i);\n huffcdic->maxcode_table[i] = ((maxcode + 1) << (32 - i)) - 1;\n }\n mobi_buffer_free_null(buf);\n return MOBI_SUCCESS;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-3881", "cwe_id": "CWE-125" }, { "id": 2569, "func": "MOBI_RET mobi_parse_huff(MOBIHuffCdic *huffcdic, const MOBIPdbRecord *record) {\n MOBIBuffer *buf = mobi_buffer_init_null(record->data, record->size);\n if (buf == NULL) {\n debug_print(\"%s\\n\", \"Memory allocation failed\");\n return MOBI_MALLOC_FAILED;\n }\n char huff_magic[5];\n mobi_buffer_getstring(huff_magic, buf, 4);\n const size_t header_length = mobi_buffer_get32(buf);\n if (strncmp(huff_magic, HUFF_MAGIC, 4) != 0 || header_length < HUFF_HEADER_LEN) {\n debug_print(\"HUFF wrong magic: %s\\n\", huff_magic);\n mobi_buffer_free_null(buf);\n return MOBI_DATA_CORRUPT;\n }\n const size_t data1_offset = mobi_buffer_get32(buf);\n const size_t data2_offset = mobi_buffer_get32(buf);\n /* skip little-endian table offsets */\n mobi_buffer_setpos(buf, data1_offset);\n if (buf->offset + (256 * 4) > buf->maxlen) {\n debug_print(\"%s\", \"HUFF data1 too short\\n\");\n mobi_buffer_free_null(buf);\n return MOBI_DATA_CORRUPT;\n }\n /* read 256 indices from data1 big-endian */\n for (int i = 0; i < 256; i++) {\n huffcdic->table1[i] = mobi_buffer_get32(buf);\n }\n mobi_buffer_setpos(buf, data2_offset);\n if (buf->offset + (64 * 4) > buf->maxlen) {\n debug_print(\"%s\", \"HUFF data2 too short\\n\");\n mobi_buffer_free_null(buf);\n return MOBI_DATA_CORRUPT;\n }\n /* read 32 mincode-maxcode pairs from data2 big-endian */\n huffcdic->mincode_table[0] = 0;\n huffcdic->maxcode_table[0] = 0xFFFFFFFF;\n for (int i = 1; i < HUFF_CODETABLE_SIZE; i++) {\n const uint32_t mincode = mobi_buffer_get32(buf);\n const uint32_t maxcode = mobi_buffer_get32(buf);\n huffcdic->mincode_table[i] = mincode << (32 - i);\n huffcdic->maxcode_table[i] = ((maxcode + 1) << (32 - i)) - 1;\n }\n mobi_buffer_free_null(buf);\n return MOBI_SUCCESS;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-3881", "cwe_id": "CWE-125" }, { "id": 3263, "func": "static struct btrfs_device *btrfs_find_device_by_path(\n\t\tstruct btrfs_fs_info *fs_info, const char *device_path)\n{\n\tint ret = 0;\n\tstruct btrfs_super_block *disk_super;\n\tu64 devid;\n\tu8 *dev_uuid;\n\tstruct block_device *bdev;\n\tstruct buffer_head *bh;\n\tstruct btrfs_device *device;\n\n\tret = btrfs_get_bdev_and_sb(device_path, FMODE_READ,\n\t\t\t\t fs_info->bdev_holder, 0, &bdev, &bh);\n\tif (ret)\n\t\treturn ERR_PTR(ret);\n\tdisk_super = (struct btrfs_super_block *)bh->b_data;\n\tdevid = btrfs_stack_device_id(&disk_super->dev_item);\n\tdev_uuid = disk_super->dev_item.uuid;\n\tif (btrfs_fs_incompat(fs_info, METADATA_UUID))\n\t\tdevice = btrfs_find_device(fs_info->fs_devices, devid, dev_uuid,\n\t\t\t\t\t disk_super->metadata_uuid);\n\telse\n\t\tdevice = btrfs_find_device(fs_info->fs_devices, devid, dev_uuid,\n\t\t\t\t\t disk_super->fsid);\n\n\tbrelse(bh);\n\tif (!device)\n\t\tdevice = ERR_PTR(-ENOENT);\n\tblkdev_put(bdev, FMODE_READ);\n\treturn device;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-18885", "cwe_id": "CWE-476" }, { "id": 3263, "func": "static struct btrfs_device *btrfs_find_device_by_path(\n\t\tstruct btrfs_fs_info *fs_info, const char *device_path)\n{\n\tint ret = 0;\n\tstruct btrfs_super_block *disk_super;\n\tu64 devid;\n\tu8 *dev_uuid;\n\tstruct block_device *bdev;\n\tstruct buffer_head *bh;\n\tstruct btrfs_device *device;\n\n\tret = btrfs_get_bdev_and_sb(device_path, FMODE_READ,\n\t\t\t\t fs_info->bdev_holder, 0, &bdev, &bh);\n\tif (ret)\n\t\treturn ERR_PTR(ret);\n\tdisk_super = (struct btrfs_super_block *)bh->b_data;\n\tdevid = btrfs_stack_device_id(&disk_super->dev_item);\n\tdev_uuid = disk_super->dev_item.uuid;\n\tif (btrfs_fs_incompat(fs_info, METADATA_UUID))\n\t\tdevice = btrfs_find_device(fs_info->fs_devices, devid, dev_uuid,\n\t\t\t\t\t disk_super->metadata_uuid, true);\n\telse\n\t\tdevice = btrfs_find_device(fs_info->fs_devices, devid, dev_uuid,\n\t\t\t\t\t disk_super->fsid, true);\n\n\tbrelse(bh);\n\tif (!device)\n\t\tdevice = ERR_PTR(-ENOENT);\n\tblkdev_put(bdev, FMODE_READ);\n\treturn device;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-18885", "cwe_id": "CWE-476" }, { "id": 2378, "func": "void jas_matrix_clip(jas_matrix_t *matrix, jas_seqent_t minval,\n jas_seqent_t maxval)\n{\n\tint i;\n\tint j;\n\tjas_seqent_t v;\n\tjas_seqent_t *rowstart;\n\tjas_seqent_t *data;\n\tint rowstep;\n\n\tif (jas_matrix_numrows(matrix) > 0 && jas_matrix_numcols(matrix) > 0) {\n\t\tassert(matrix->rows_);\n\t\trowstep = jas_matrix_rowstep(matrix);\n\t\tfor (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,\n\t\t rowstart += rowstep) {\n\t\t\tdata = rowstart;\n\t\t\tfor (j = matrix->numcols_, data = rowstart; j > 0; --j,\n\t\t\t ++data) {\n\t\t\t\tv = *data;\n\t\t\t\tif (v < minval) {\n\t\t\t\t\t*data = minval;\n\t\t\t\t} else if (v > maxval) {\n\t\t\t\t\t*data = maxval;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 2378, "func": "void jas_matrix_clip(jas_matrix_t *matrix, jas_seqent_t minval,\n jas_seqent_t maxval)\n{\n\tjas_matind_t i;\n\tjas_matind_t j;\n\tjas_seqent_t v;\n\tjas_seqent_t *rowstart;\n\tjas_seqent_t *data;\n\tjas_matind_t rowstep;\n\n\tif (jas_matrix_numrows(matrix) > 0 && jas_matrix_numcols(matrix) > 0) {\n\t\tassert(matrix->rows_);\n\t\trowstep = jas_matrix_rowstep(matrix);\n\t\tfor (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,\n\t\t rowstart += rowstep) {\n\t\t\tdata = rowstart;\n\t\t\tfor (j = matrix->numcols_, data = rowstart; j > 0; --j,\n\t\t\t ++data) {\n\t\t\t\tv = *data;\n\t\t\t\tif (v < minval) {\n\t\t\t\t\t*data = minval;\n\t\t\t\t} else if (v > maxval) {\n\t\t\t\t\t*data = maxval;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-9395", "cwe_id": "CWE-20" }, { "id": 1825, "func": "GF_Err text_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu16 pSize;\n\tGF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s;\n\n\tISOM_DECREASE_SIZE(ptr, 51);\n\n\te = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)ptr, bs);\n\tif (e) return e;\n\n\tptr->displayFlags = gf_bs_read_u32(bs);\t\t\t/*Display flags*/\n\tptr->textJustification = gf_bs_read_u32(bs);\t/*Text justification*/\n\tgf_bs_read_data(bs, ptr->background_color, 6);\t/*Background color*/\n\tgpp_read_box(bs, &ptr->default_box);\t\t\t/*Default text box*/\n\tgf_bs_read_data(bs, ptr->reserved1, 8);\t\t\t/*Reserved*/\n\tptr->fontNumber = gf_bs_read_u16(bs);\t\t\t/*Font number*/\n\tptr->fontFace = gf_bs_read_u16(bs);\t\t\t/*Font face*/\n\tptr->reserved2 = gf_bs_read_u8(bs);\t\t\t/*Reserved*/\n\tptr->reserved3 = gf_bs_read_u16(bs);\t\t\t/*Reserved*/\n\tgf_bs_read_data(bs, ptr->foreground_color, 6);\t/*Foreground color*/\n\n\t/*ffmpeg compatibility with iPod streams: no pascal string*/\n\tif (!ptr->size)\n\t\treturn GF_OK;\n\n\tISOM_DECREASE_SIZE(ptr, 1);\n\tpSize = gf_bs_read_u8(bs); /*a Pascal string begins with its size: get textName size*/\n\n\tif (ptr->size < pSize) {\n\t\tu32 b_size = pSize;\n\t\tsize_t i = 0;\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[iso file] text box doesn't use a Pascal string: trying to decode anyway.\\n\"));\n\t\tptr->textName = (char*)gf_malloc((size_t)ptr->size + 1 + 1);\n\t\tif (!ptr->textName) return GF_OUT_OF_MEM;\n\n\t\tdo {\n\t\t\tchar c = (char)b_size;\n\t\t\tif (c == '\\0') {\n\t\t\t\tbreak;\n\t\t\t} else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {\n\t\t\t\tptr->textName[i] = c;\n\t\t\t} else {\n\t\t\t\tgf_free(ptr->textName);\n\t\t\t\tptr->textName = NULL;\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] text box doesn't use a Pascal string and contains non-chars. Abort.\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\ti++;\n\t\t\tif (!ptr->size)\n\t\t\t\tbreak;\n\t\t\tptr->size--;\n\t\t\tb_size = gf_bs_read_u8(bs);\n\t\t} while (b_size);\n\n\t\tptr->textName[i] = '\\0';\t\t\t\t/*Font name*/\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] text box doesn't use a Pascal string: \\\"%s\\\" detected.\\n\", ptr->textName));\n\t\treturn GF_OK;\n\t}\n\tif (pSize) {\n\t\tptr->textName = (char*) gf_malloc(pSize+1 * sizeof(char));\n\t\tif (!ptr->textName) return GF_OUT_OF_MEM;\n\n\t\tif (gf_bs_read_data(bs, ptr->textName, pSize) != pSize) {\n\t\t\tgf_free(ptr->textName);\n\t\t\tptr->textName = NULL;\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\t\tptr->textName[pSize] = '\\0';\t\t\t\t/*Font name*/\n\t}\n\tISOM_DECREASE_SIZE(ptr, pSize);\n\treturn gf_isom_box_array_read(s, bs);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-32139", "cwe_id": "CWE-476" }, { "id": 1825, "func": "GF_Err text_box_read(GF_Box *s, GF_BitStream *bs)\n{\n\tGF_Err e;\n\tu16 pSize;\n\tGF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s;\n\n\tISOM_DECREASE_SIZE(ptr, 8);\n\te = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)ptr, bs);\n\tif (e) return e;\n\t//some weird text entries are not QT text nor 3gpp, cf issue #1030\n\tif (!ptr->size) {\n\t\tptr->textJustification = 1;\n\t\treturn GF_OK;\n\t}\n\tISOM_DECREASE_SIZE(ptr, 43);\n\n\n\tptr->displayFlags = gf_bs_read_u32(bs);\t\t\t/*Display flags*/\n\tptr->textJustification = gf_bs_read_u32(bs);\t/*Text justification*/\n\tgf_bs_read_data(bs, ptr->background_color, 6);\t/*Background color*/\n\tgpp_read_box(bs, &ptr->default_box);\t\t\t/*Default text box*/\n\tgf_bs_read_data(bs, ptr->reserved1, 8);\t\t\t/*Reserved*/\n\tptr->fontNumber = gf_bs_read_u16(bs);\t\t\t/*Font number*/\n\tptr->fontFace = gf_bs_read_u16(bs);\t\t\t/*Font face*/\n\tptr->reserved2 = gf_bs_read_u8(bs);\t\t\t/*Reserved*/\n\tptr->reserved3 = gf_bs_read_u16(bs);\t\t\t/*Reserved*/\n\tgf_bs_read_data(bs, ptr->foreground_color, 6);\t/*Foreground color*/\n\n\t/*ffmpeg compatibility with iPod streams: no pascal string*/\n\tif (!ptr->size)\n\t\treturn GF_OK;\n\n\tISOM_DECREASE_SIZE(ptr, 1);\n\tpSize = gf_bs_read_u8(bs); /*a Pascal string begins with its size: get textName size*/\n\n\tif (ptr->size < pSize) {\n\t\tu32 b_size = pSize;\n\t\tsize_t i = 0;\n\t\tGF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (\"[iso file] text box doesn't use a Pascal string: trying to decode anyway.\\n\"));\n\t\tptr->textName = (char*)gf_malloc((size_t)ptr->size + 1 + 1);\n\t\tif (!ptr->textName) return GF_OUT_OF_MEM;\n\n\t\tdo {\n\t\t\tchar c = (char)b_size;\n\t\t\tif (c == '\\0') {\n\t\t\t\tbreak;\n\t\t\t} else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {\n\t\t\t\tptr->textName[i] = c;\n\t\t\t} else {\n\t\t\t\tgf_free(ptr->textName);\n\t\t\t\tptr->textName = NULL;\n\t\t\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] text box doesn't use a Pascal string and contains non-chars. Abort.\\n\"));\n\t\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t\t}\n\t\t\ti++;\n\t\t\tif (!ptr->size)\n\t\t\t\tbreak;\n\t\t\tptr->size--;\n\t\t\tb_size = gf_bs_read_u8(bs);\n\t\t} while (b_size);\n\n\t\tptr->textName[i] = '\\0';\t\t\t\t/*Font name*/\n\t\tGF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, (\"[iso file] text box doesn't use a Pascal string: \\\"%s\\\" detected.\\n\", ptr->textName));\n\t\treturn GF_OK;\n\t}\n\tif (pSize) {\n\t\tptr->textName = (char*) gf_malloc(pSize+1 * sizeof(char));\n\t\tif (!ptr->textName) return GF_OUT_OF_MEM;\n\n\t\tif (gf_bs_read_data(bs, ptr->textName, pSize) != pSize) {\n\t\t\tgf_free(ptr->textName);\n\t\t\tptr->textName = NULL;\n\t\t\treturn GF_ISOM_INVALID_FILE;\n\t\t}\n\t\tptr->textName[pSize] = '\\0';\t\t\t\t/*Font name*/\n\t}\n\tISOM_DECREASE_SIZE(ptr, pSize);\n\treturn gf_isom_box_array_read(s, bs);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-32139", "cwe_id": "CWE-476" }, { "id": 1326, "func": "static int xar_hash_check(int hash, const void * result, const void * expected)\n{\n int len;\n\n if (!result || !expected)\n return 1;\n switch (hash) {\n case XAR_CKSUM_SHA1:\n len = SHA1_HASH_SIZE;\n break;\n case XAR_CKSUM_MD5:\n len = CLI_HASH_MD5;\n break;\n case XAR_CKSUM_OTHER:\n case XAR_CKSUM_NONE:\n default:\n return 1;\n }\n return memcmp(result, expected, len);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-1000085", "cwe_id": "CWE-125" }, { "id": 1326, "func": "static int xar_hash_check(int hash, const void * result, const void * expected)\n{\n int len;\n\n if (!result || !expected)\n return 1;\n switch (hash) {\n case XAR_CKSUM_SHA1:\n len = CLI_HASHLEN_SHA1;\n break;\n case XAR_CKSUM_MD5:\n len = CLI_HASHLEN_MD5;\n break;\n case XAR_CKSUM_OTHER:\n case XAR_CKSUM_NONE:\n default:\n return 1;\n }\n return memcmp(result, expected, len);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-1000085", "cwe_id": "CWE-125" }, { "id": 3062, "func": "static void mark_commit(struct commit *c, void *data)\n{\n\tmark_object(&c->object, NULL, NULL, data);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 3062, "func": "static void mark_commit(struct commit *c, void *data)\n{\n\tmark_object(&c->object, NULL, data);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-2315", "cwe_id": "CWE-119" }, { "id": 2543, "func": "handle_keywordonly_args(struct compiling *c, const node *n, int start,\n asdl_seq *kwonlyargs, asdl_seq *kwdefaults)\n{\n PyObject *argname;\n node *ch;\n expr_ty expression, annotation;\n arg_ty arg = NULL;\n int i = start;\n int j = 0; /* index for kwdefaults and kwonlyargs */\n\n if (kwonlyargs == NULL) {\n ast_error(c, CHILD(n, start), \"named arguments must follow bare *\");\n return -1;\n }\n assert(kwdefaults != NULL);\n while (i < NCH(n)) {\n ch = CHILD(n, i);\n switch (TYPE(ch)) {\n case vfpdef:\n case tfpdef:\n if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {\n expression = ast_for_expr(c, CHILD(n, i + 2));\n if (!expression)\n goto error;\n asdl_seq_SET(kwdefaults, j, expression);\n i += 2; /* '=' and test */\n }\n else { /* setting NULL if no default value exists */\n asdl_seq_SET(kwdefaults, j, NULL);\n }\n if (NCH(ch) == 3) {\n /* ch is NAME ':' test */\n annotation = ast_for_expr(c, CHILD(ch, 2));\n if (!annotation)\n goto error;\n }\n else {\n annotation = NULL;\n }\n ch = CHILD(ch, 0);\n argname = NEW_IDENTIFIER(ch);\n if (!argname)\n goto error;\n if (forbidden_name(c, argname, ch, 0))\n goto error;\n arg = arg(argname, annotation, NULL, LINENO(ch), ch->n_col_offset,\n ch->n_end_lineno, ch->n_end_col_offset,\n c->c_arena);\n if (!arg)\n goto error;\n asdl_seq_SET(kwonlyargs, j++, arg);\n i += 1; /* the name */\n if (TYPE(CHILD(n, i)) == COMMA)\n i += 1; /* the comma, if present */\n break;\n case TYPE_COMMENT:\n /* arg will be equal to the last argument processed */\n arg->type_comment = NEW_TYPE_COMMENT(ch);\n if (!arg->type_comment)\n goto error;\n i += 1;\n break;\n case DOUBLESTAR:\n return i;\n default:\n ast_error(c, ch, \"unexpected node\");\n goto error;\n }\n }\n return i;\n error:\n return -1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2543, "func": "handle_keywordonly_args(struct compiling *c, const node *n, int start,\n asdl_seq *kwonlyargs, asdl_seq *kwdefaults)\n{\n PyObject *argname;\n node *ch;\n expr_ty expression, annotation;\n arg_ty arg = NULL;\n int i = start;\n int j = 0; /* index for kwdefaults and kwonlyargs */\n\n if (kwonlyargs == NULL) {\n ast_error(c, CHILD(n, start), \"named arguments must follow bare *\");\n return -1;\n }\n assert(kwdefaults != NULL);\n while (i < NCH(n)) {\n ch = CHILD(n, i);\n switch (TYPE(ch)) {\n case vfpdef:\n case tfpdef:\n if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {\n expression = ast_for_expr(c, CHILD(n, i + 2));\n if (!expression)\n goto error;\n asdl_seq_SET(kwdefaults, j, expression);\n i += 2; /* '=' and test */\n }\n else { /* setting NULL if no default value exists */\n asdl_seq_SET(kwdefaults, j, NULL);\n }\n if (NCH(ch) == 3) {\n /* ch is NAME ':' test */\n annotation = ast_for_expr(c, CHILD(ch, 2));\n if (!annotation)\n goto error;\n }\n else {\n annotation = NULL;\n }\n ch = CHILD(ch, 0);\n argname = NEW_IDENTIFIER(ch);\n if (!argname)\n goto error;\n if (forbidden_name(c, argname, ch, 0))\n goto error;\n arg = arg(argname, annotation, NULL, LINENO(ch), ch->n_col_offset,\n ch->n_end_lineno, ch->n_end_col_offset,\n c->c_arena);\n if (!arg)\n goto error;\n asdl_seq_SET(kwonlyargs, j++, arg);\n i += 1; /* the name */\n if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)\n i += 1; /* the comma, if present */\n break;\n case TYPE_COMMENT:\n /* arg will be equal to the last argument processed */\n arg->type_comment = NEW_TYPE_COMMENT(ch);\n if (!arg->type_comment)\n goto error;\n i += 1;\n break;\n case DOUBLESTAR:\n return i;\n default:\n ast_error(c, ch, \"unexpected node\");\n goto error;\n }\n }\n return i;\n error:\n return -1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1862, "func": "ikev2_ke_print(netdissect_options *ndo, u_char tpay,\n\t\tconst struct isakmp_gen *ext,\n\t\tu_int item_len _U_, const u_char *ep _U_,\n\t\tuint32_t phase _U_, uint32_t doi _U_,\n\t\tuint32_t proto _U_, int depth _U_)\n{\n\tstruct ikev2_ke ke;\n\tconst struct ikev2_ke *k;\n\n\tk = (const struct ikev2_ke *)ext;\n\tND_TCHECK(*ext);\n\tUNALIGNED_MEMCPY(&ke, ext, sizeof(ke));\n\tikev2_pay_print(ndo, NPSTR(tpay), ke.h.critical);\n\n\tND_PRINT((ndo,\" len=%u group=%s\", ntohs(ke.h.len) - 8,\n\t\t STR_OR_ID(ntohs(ke.ke_group), dh_p_map)));\n\n\tif (2 < ndo->ndo_vflag && 8 < ntohs(ke.h.len)) {\n\t\tND_PRINT((ndo,\" \"));\n\t\tif (!rawprint(ndo, (const uint8_t *)(k + 1), ntohs(ke.h.len) - 8))\n\t\t\tgoto trunc;\n\t}\n\treturn (const u_char *)ext + ntohs(ke.h.len);\ntrunc:\n\tND_PRINT((ndo,\" [|%s]\", NPSTR(tpay)));\n\treturn NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13690", "cwe_id": "CWE-125" }, { "id": 1862, "func": "ikev2_ke_print(netdissect_options *ndo, u_char tpay,\n\t\tconst struct isakmp_gen *ext,\n\t\tu_int item_len _U_, const u_char *ep _U_,\n\t\tuint32_t phase _U_, uint32_t doi _U_,\n\t\tuint32_t proto _U_, int depth _U_)\n{\n\tstruct ikev2_ke ke;\n\tconst struct ikev2_ke *k;\n\n\tk = (const struct ikev2_ke *)ext;\n\tND_TCHECK(*k);\n\tUNALIGNED_MEMCPY(&ke, ext, sizeof(ke));\n\tikev2_pay_print(ndo, NPSTR(tpay), ke.h.critical);\n\n\tND_PRINT((ndo,\" len=%u group=%s\", ntohs(ke.h.len) - 8,\n\t\t STR_OR_ID(ntohs(ke.ke_group), dh_p_map)));\n\n\tif (2 < ndo->ndo_vflag && 8 < ntohs(ke.h.len)) {\n\t\tND_PRINT((ndo,\" \"));\n\t\tif (!rawprint(ndo, (const uint8_t *)(k + 1), ntohs(ke.h.len) - 8))\n\t\t\tgoto trunc;\n\t}\n\treturn (const u_char *)ext + ntohs(ke.h.len);\ntrunc:\n\tND_PRINT((ndo,\" [|%s]\", NPSTR(tpay)));\n\treturn NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13690", "cwe_id": "CWE-125" }, { "id": 1548, "func": "void Filter::onUpstreamEvent(Network::ConnectionEvent event) {\n // Update the connecting flag before processing the event because we may start a new connection\n // attempt in initializeUpstreamConnection.\n bool connecting = connecting_;\n connecting_ = false;\n\n if (event == Network::ConnectionEvent::RemoteClose ||\n event == Network::ConnectionEvent::LocalClose) {\n upstream_.reset();\n disableIdleTimer();\n\n if (connecting) {\n if (event == Network::ConnectionEvent::RemoteClose) {\n getStreamInfo().setResponseFlag(StreamInfo::ResponseFlag::UpstreamConnectionFailure);\n read_callbacks_->upstreamHost()->outlierDetector().putResult(\n Upstream::Outlier::Result::LocalOriginConnectFailed);\n }\n\n initializeUpstreamConnection();\n } else {\n if (read_callbacks_->connection().state() == Network::Connection::State::Open) {\n read_callbacks_->connection().close(Network::ConnectionCloseType::FlushWrite);\n }\n }\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-43826", "cwe_id": "CWE-416" }, { "id": 1548, "func": "void Filter::onUpstreamEvent(Network::ConnectionEvent event) {\n // Update the connecting flag before processing the event because we may start a new connection\n // attempt in initializeUpstreamConnection.\n bool connecting = connecting_;\n connecting_ = false;\n\n if (event == Network::ConnectionEvent::RemoteClose ||\n event == Network::ConnectionEvent::LocalClose) {\n upstream_.reset();\n disableIdleTimer();\n\n if (connecting) {\n if (event == Network::ConnectionEvent::RemoteClose) {\n getStreamInfo().setResponseFlag(StreamInfo::ResponseFlag::UpstreamConnectionFailure);\n read_callbacks_->upstreamHost()->outlierDetector().putResult(\n Upstream::Outlier::Result::LocalOriginConnectFailed);\n }\n\n if (!downstream_closed_) {\n initializeUpstreamConnection();\n }\n } else {\n if (read_callbacks_->connection().state() == Network::Connection::State::Open) {\n read_callbacks_->connection().close(Network::ConnectionCloseType::FlushWrite);\n }\n }\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-43826", "cwe_id": "CWE-416" }, { "id": 633, "func": "tok_new(void)\n{\n struct tok_state *tok = (struct tok_state *)PyMem_MALLOC(\n sizeof(struct tok_state));\n if (tok == NULL)\n return NULL;\n tok->buf = tok->cur = tok->end = tok->inp = tok->start = NULL;\n tok->done = E_OK;\n tok->fp = NULL;\n tok->input = NULL;\n tok->tabsize = TABSIZE;\n tok->indent = 0;\n tok->indstack[0] = 0;\n\n tok->atbol = 1;\n tok->pendin = 0;\n tok->prompt = tok->nextprompt = NULL;\n tok->lineno = 0;\n tok->level = 0;\n tok->altwarning = 1;\n tok->alterror = 1;\n tok->alttabsize = 1;\n tok->altindstack[0] = 0;\n tok->decoding_state = STATE_INIT;\n tok->decoding_erred = 0;\n tok->read_coding_spec = 0;\n tok->enc = NULL;\n tok->encoding = NULL;\n tok->cont_line = 0;\n#ifndef PGEN\n tok->filename = NULL;\n tok->decoding_readline = NULL;\n tok->decoding_buffer = NULL;\n#endif\n\n tok->async_def = 0;\n tok->async_def_indent = 0;\n tok->async_def_nl = 0;\n\n return tok;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 633, "func": "tok_new(void)\n{\n struct tok_state *tok = (struct tok_state *)PyMem_MALLOC(\n sizeof(struct tok_state));\n if (tok == NULL)\n return NULL;\n tok->buf = tok->cur = tok->end = tok->inp = tok->start = NULL;\n tok->done = E_OK;\n tok->fp = NULL;\n tok->input = NULL;\n tok->tabsize = TABSIZE;\n tok->indent = 0;\n tok->indstack[0] = 0;\n\n tok->atbol = 1;\n tok->pendin = 0;\n tok->prompt = tok->nextprompt = NULL;\n tok->lineno = 0;\n tok->level = 0;\n tok->altindstack[0] = 0;\n tok->decoding_state = STATE_INIT;\n tok->decoding_erred = 0;\n tok->read_coding_spec = 0;\n tok->enc = NULL;\n tok->encoding = NULL;\n tok->cont_line = 0;\n#ifndef PGEN\n tok->filename = NULL;\n tok->decoding_readline = NULL;\n tok->decoding_buffer = NULL;\n#endif\n\n tok->async_def = 0;\n tok->async_def_indent = 0;\n tok->async_def_nl = 0;\n tok->async_always = 0;\n\n return tok;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 265, "func": "irc_ctcp_dcc_filename_without_quotes (const char *filename)\n{\n int length;\n\n length = strlen (filename);\n if (length > 0)\n {\n if ((filename[0] == '\\\"') && (filename[length - 1] == '\\\"'))\n return weechat_strndup (filename + 1, length - 2);\n }\n return strdup (filename);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-8073", "cwe_id": "CWE-119" }, { "id": 265, "func": "irc_ctcp_dcc_filename_without_quotes (const char *filename)\n{\n int length;\n\n length = strlen (filename);\n if (length > 1)\n {\n if ((filename[0] == '\\\"') && (filename[length - 1] == '\\\"'))\n return weechat_strndup (filename + 1, length - 2);\n }\n return strdup (filename);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-8073", "cwe_id": "CWE-119" }, { "id": 1342, "func": "void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)\n{\n\tconst struct k_clock *kc = timr->kclock;\n\tktime_t now, remaining, iv;\n\tstruct timespec64 ts64;\n\tbool sig_none;\n\n\tsig_none = timr->it_sigev_notify == SIGEV_NONE;\n\tiv = timr->it_interval;\n\n\t/* interval timer ? */\n\tif (iv) {\n\t\tcur_setting->it_interval = ktime_to_timespec64(iv);\n\t} else if (!timr->it_active) {\n\t\t/*\n\t\t * SIGEV_NONE oneshot timers are never queued. Check them\n\t\t * below.\n\t\t */\n\t\tif (!sig_none)\n\t\t\treturn;\n\t}\n\n\t/*\n\t * The timespec64 based conversion is suboptimal, but it's not\n\t * worth to implement yet another callback.\n\t */\n\tkc->clock_get(timr->it_clock, &ts64);\n\tnow = timespec64_to_ktime(ts64);\n\n\t/*\n\t * When a requeue is pending or this is a SIGEV_NONE timer move the\n\t * expiry time forward by intervals, so expiry is > now.\n\t */\n\tif (iv && (timr->it_requeue_pending & REQUEUE_PENDING || sig_none))\n\t\ttimr->it_overrun += (int)kc->timer_forward(timr, now);\n\n\tremaining = kc->timer_remaining(timr, now);\n\t/* Return 0 only, when the timer is expired and not pending */\n\tif (remaining <= 0) {\n\t\t/*\n\t\t * A single shot SIGEV_NONE timer must return 0, when\n\t\t * it is expired !\n\t\t */\n\t\tif (!sig_none)\n\t\t\tcur_setting->it_value.tv_nsec = 1;\n\t} else {\n\t\tcur_setting->it_value = ktime_to_timespec64(remaining);\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-12896", "cwe_id": "CWE-190" }, { "id": 1342, "func": "void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)\n{\n\tconst struct k_clock *kc = timr->kclock;\n\tktime_t now, remaining, iv;\n\tstruct timespec64 ts64;\n\tbool sig_none;\n\n\tsig_none = timr->it_sigev_notify == SIGEV_NONE;\n\tiv = timr->it_interval;\n\n\t/* interval timer ? */\n\tif (iv) {\n\t\tcur_setting->it_interval = ktime_to_timespec64(iv);\n\t} else if (!timr->it_active) {\n\t\t/*\n\t\t * SIGEV_NONE oneshot timers are never queued. Check them\n\t\t * below.\n\t\t */\n\t\tif (!sig_none)\n\t\t\treturn;\n\t}\n\n\t/*\n\t * The timespec64 based conversion is suboptimal, but it's not\n\t * worth to implement yet another callback.\n\t */\n\tkc->clock_get(timr->it_clock, &ts64);\n\tnow = timespec64_to_ktime(ts64);\n\n\t/*\n\t * When a requeue is pending or this is a SIGEV_NONE timer move the\n\t * expiry time forward by intervals, so expiry is > now.\n\t */\n\tif (iv && (timr->it_requeue_pending & REQUEUE_PENDING || sig_none))\n\t\ttimr->it_overrun += kc->timer_forward(timr, now);\n\n\tremaining = kc->timer_remaining(timr, now);\n\t/* Return 0 only, when the timer is expired and not pending */\n\tif (remaining <= 0) {\n\t\t/*\n\t\t * A single shot SIGEV_NONE timer must return 0, when\n\t\t * it is expired !\n\t\t */\n\t\tif (!sig_none)\n\t\t\tcur_setting->it_value.tv_nsec = 1;\n\t} else {\n\t\tcur_setting->it_value = ktime_to_timespec64(remaining);\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-12896", "cwe_id": "CWE-190" }, { "id": 580, "func": "static void traverse_for_entities(\n\tconst char *old,\n\tsize_t oldlen,\n\tchar *ret, /* should have allocated TRAVERSE_FOR_ENTITIES_EXPAND_SIZE(olden) */\n\tsize_t *retlen,\n\tint all,\n\tint flags,\n\tconst entity_ht *inv_map,\n\tenum entity_charset charset)\n{\n\tconst char *p,\n\t\t\t *lim;\n\tchar\t *q;\n\tint doctype = flags & ENT_HTML_DOC_TYPE_MASK;\n\n\tlim = old + oldlen; /* terminator address */\n\tassert(*lim == '\\0');\n\n\tfor (p = old, q = ret; p < lim;) {\n\t\tunsigned code, code2 = 0;\n\t\tconst char *next = NULL; /* when set, next > p, otherwise possible inf loop */\n\n\t\t/* Shift JIS, Big5 and HKSCS use multi-byte encodings where an\n\t\t * ASCII range byte can be part of a multi-byte sequence.\n\t\t * However, they start at 0x40, therefore if we find a 0x26 byte,\n\t\t * we're sure it represents the '&' character. */\n\n\t\t/* assumes there are no single-char entities */\n\t\tif (p[0] != '&' || (p + 3 >= lim)) {\n\t\t\t*(q++) = *(p++);\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* now p[3] is surely valid and is no terminator */\n\n\t\t/* numerical entity */\n\t\tif (p[1] == '#') {\n\t\t\tnext = &p[2];\n\t\t\tif (process_numeric_entity(&next, &code) == FAILURE)\n\t\t\t\tgoto invalid_code;\n\n\t\t\t/* If we're in htmlspecialchars_decode, we're only decoding entities\n\t\t\t * that represent &, <, >, \" and '. Is this one of them? */\n\t\t\tif (!all && (code > 63U ||\n\t\t\t\t\tstage3_table_be_apos_00000[code].data.ent.entity == NULL))\n\t\t\t\tgoto invalid_code;\n\n\t\t\t/* are we allowed to decode this entity in this document type?\n\t\t\t * HTML 5 is the only that has a character that cannot be used in \n\t\t\t * a numeric entity but is allowed literally (U+000D). The\n\t\t\t * unoptimized version would be ... || !numeric_entity_is_allowed(code) */\n\t\t\tif (!unicode_cp_is_allowed(code, doctype) ||\n\t\t\t\t\t(doctype == ENT_HTML_DOC_HTML5 && code == 0x0D))\n\t\t\t\tgoto invalid_code;\n\t\t} else {\n\t\t\tconst char *start;\n\t\t\tsize_t ent_len;\n\n\t\t\tnext = &p[1];\n\t\t\tstart = next;\n\n\t\t\tif (process_named_entity_html(&next, &start, &ent_len) == FAILURE)\n\t\t\t\tgoto invalid_code;\n\n\t\t\tif (resolve_named_entity_html(start, ent_len, inv_map, &code, &code2) == FAILURE) {\n\t\t\t\tif (doctype == ENT_HTML_DOC_XHTML && ent_len == 4 && start[0] == 'a'\n\t\t\t\t\t\t\t&& start[1] == 'p' && start[2] == 'o' && start[3] == 's') {\n\t\t\t\t\t/* uses html4 inv_map, which doesn't include apos;. This is a\n\t\t\t\t\t * hack to support it */\n\t\t\t\t\tcode = (unsigned) '\\'';\n\t\t\t\t} else {\n\t\t\t\t\tgoto invalid_code;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tassert(*next == ';');\n\t\t\n\t\tif (((code == '\\'' && !(flags & ENT_HTML_QUOTE_SINGLE)) ||\n\t\t\t\t(code == '\"' && !(flags & ENT_HTML_QUOTE_DOUBLE)))\n\t\t\t\t/* && code2 == '\\0' always true for current maps */)\n\t\t\tgoto invalid_code;\n\n\t\t/* UTF-8 doesn't need mapping (ISO-8859-1 doesn't either, but\n\t\t * the call is needed to ensure the codepoint <= U+00FF) */\n\t\tif (charset != cs_utf_8) {\n\t\t\t/* replace unicode code point */\n\t\t\tif (map_from_unicode(code, charset, &code) == FAILURE || code2 != 0)\n\t\t\t\tgoto invalid_code; /* not representable in target charset */\n\t\t}\n\n\t\tq += write_octet_sequence(q, charset, code);\n\t\tif (code2) {\n\t\t\tq += write_octet_sequence(q, charset, code2);\n\t\t}\n\n\t\t/* jump over the valid entity; may go beyond size of buffer; np */\n\t\tp = next + 1;\n\t\tcontinue;\n\ninvalid_code:\n\t\tfor (; p < next; p++) {\n\t\t\t*(q++) = *p;\n\t\t}\n\t}\n\t\n\t*q = '\\0';\n\t*retlen = (size_t)(q - ret);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5094", "cwe_id": "CWE-190" }, { "id": 580, "func": "static void traverse_for_entities(\n\tconst char *old,\n\tsize_t oldlen,\n\tchar *ret, /* should have allocated TRAVERSE_FOR_ENTITIES_EXPAND_SIZE(olden) */\n\tsize_t *retlen,\n\tint all,\n\tint flags,\n\tconst entity_ht *inv_map,\n\tenum entity_charset charset)\n{\n\tconst char *p,\n\t\t\t *lim;\n\tchar\t *q;\n\tint doctype = flags & ENT_HTML_DOC_TYPE_MASK;\n\n\tlim = old + oldlen; /* terminator address */\n\tassert(*lim == '\\0');\n\n\tfor (p = old, q = ret; p < lim;) {\n\t\tunsigned code, code2 = 0;\n\t\tconst char *next = NULL; /* when set, next > p, otherwise possible inf loop */\n\n\t\t/* Shift JIS, Big5 and HKSCS use multi-byte encodings where an\n\t\t * ASCII range byte can be part of a multi-byte sequence.\n\t\t * However, they start at 0x40, therefore if we find a 0x26 byte,\n\t\t * we're sure it represents the '&' character. */\n\n\t\t/* assumes there are no single-char entities */\n\t\tif (p[0] != '&' || (p + 3 >= lim)) {\n\t\t\t*(q++) = *(p++);\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* now p[3] is surely valid and is no terminator */\n\n\t\t/* numerical entity */\n\t\tif (p[1] == '#') {\n\t\t\tnext = &p[2];\n\t\t\tif (process_numeric_entity(&next, &code) == FAILURE)\n\t\t\t\tgoto invalid_code;\n\n\t\t\t/* If we're in htmlspecialchars_decode, we're only decoding entities\n\t\t\t * that represent &, <, >, \" and '. Is this one of them? */\n\t\t\tif (!all && (code > 63U ||\n\t\t\t\t\tstage3_table_be_apos_00000[code].data.ent.entity == NULL))\n\t\t\t\tgoto invalid_code;\n\n\t\t\t/* are we allowed to decode this entity in this document type?\n\t\t\t * HTML 5 is the only that has a character that cannot be used in\n\t\t\t * a numeric entity but is allowed literally (U+000D). The\n\t\t\t * unoptimized version would be ... || !numeric_entity_is_allowed(code) */\n\t\t\tif (!unicode_cp_is_allowed(code, doctype) ||\n\t\t\t\t\t(doctype == ENT_HTML_DOC_HTML5 && code == 0x0D))\n\t\t\t\tgoto invalid_code;\n\t\t} else {\n\t\t\tconst char *start;\n\t\t\tsize_t ent_len;\n\n\t\t\tnext = &p[1];\n\t\t\tstart = next;\n\n\t\t\tif (process_named_entity_html(&next, &start, &ent_len) == FAILURE)\n\t\t\t\tgoto invalid_code;\n\n\t\t\tif (resolve_named_entity_html(start, ent_len, inv_map, &code, &code2) == FAILURE) {\n\t\t\t\tif (doctype == ENT_HTML_DOC_XHTML && ent_len == 4 && start[0] == 'a'\n\t\t\t\t\t\t\t&& start[1] == 'p' && start[2] == 'o' && start[3] == 's') {\n\t\t\t\t\t/* uses html4 inv_map, which doesn't include apos;. This is a\n\t\t\t\t\t * hack to support it */\n\t\t\t\t\tcode = (unsigned) '\\'';\n\t\t\t\t} else {\n\t\t\t\t\tgoto invalid_code;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tassert(*next == ';');\n\n\t\tif (((code == '\\'' && !(flags & ENT_HTML_QUOTE_SINGLE)) ||\n\t\t\t\t(code == '\"' && !(flags & ENT_HTML_QUOTE_DOUBLE)))\n\t\t\t\t/* && code2 == '\\0' always true for current maps */)\n\t\t\tgoto invalid_code;\n\n\t\t/* UTF-8 doesn't need mapping (ISO-8859-1 doesn't either, but\n\t\t * the call is needed to ensure the codepoint <= U+00FF) */\n\t\tif (charset != cs_utf_8) {\n\t\t\t/* replace unicode code point */\n\t\t\tif (map_from_unicode(code, charset, &code) == FAILURE || code2 != 0)\n\t\t\t\tgoto invalid_code; /* not representable in target charset */\n\t\t}\n\n\t\tq += write_octet_sequence(q, charset, code);\n\t\tif (code2) {\n\t\t\tq += write_octet_sequence(q, charset, code2);\n\t\t}\n\n\t\t/* jump over the valid entity; may go beyond size of buffer; np */\n\t\tp = next + 1;\n\t\tcontinue;\n\ninvalid_code:\n\t\tfor (; p < next; p++) {\n\t\t\t*(q++) = *p;\n\t\t}\n\t}\n\n\t*q = '\\0';\n\t*retlen = (size_t)(q - ret);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5094", "cwe_id": "CWE-190" }, { "id": 1422, "func": "void uwbd_stop(struct uwb_rc *rc)\n{\n\tkthread_stop(rc->uwbd.task);\n\tuwbd_flush(rc);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-16526", "cwe_id": "CWE-119" }, { "id": 1422, "func": "void uwbd_stop(struct uwb_rc *rc)\n{\n\tif (rc->uwbd.task)\n\t\tkthread_stop(rc->uwbd.task);\n\tuwbd_flush(rc);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-16526", "cwe_id": "CWE-119" }, { "id": 87, "func": "error_t ksz8851UpdateMacAddrFilter(NetInterface *interface)\n{\n uint_t i;\n uint_t k;\n uint32_t crc;\n uint16_t hashTable[4];\n MacFilterEntry *entry;\n\n //Debug message\n TRACE_DEBUG(\"Updating MAC filter...\\r\\n\");\n\n //Clear hash table\n osMemset(hashTable, 0, sizeof(hashTable));\n\n //The MAC address filter contains the list of MAC addresses to accept\n //when receiving an Ethernet frame\n for(i = 0; i < MAC_ADDR_FILTER_SIZE; i++)\n {\n //Point to the current entry\n entry = &interface->macAddrFilter[i];\n\n //Valid entry?\n if(entry->refCount > 0)\n {\n //Compute CRC over the current MAC address\n crc = ksz8851CalcCrc(&entry->addr, sizeof(MacAddr));\n //Calculate the corresponding index in the table\n k = (crc >> 26) & 0x3F;\n //Update hash table contents\n hashTable[k / 16] |= (1 << (k % 16));\n }\n }\n\n //Write the hash table to the KSZ8851 controller\n ksz8851WriteReg(interface, KSZ8851_REG_MAHTR0, hashTable[0]);\n ksz8851WriteReg(interface, KSZ8851_REG_MAHTR1, hashTable[1]);\n ksz8851WriteReg(interface, KSZ8851_REG_MAHTR2, hashTable[2]);\n ksz8851WriteReg(interface, KSZ8851_REG_MAHTR3, hashTable[3]);\n\n //Debug message\n TRACE_DEBUG(\" MAHTR0 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_REG_MAHTR0));\n TRACE_DEBUG(\" MAHTR1 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_REG_MAHTR1));\n TRACE_DEBUG(\" MAHTR2 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_REG_MAHTR2));\n TRACE_DEBUG(\" MAHTR3 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_REG_MAHTR3));\n\n //Successful processing\n return NO_ERROR;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 87, "func": "error_t ksz8851UpdateMacAddrFilter(NetInterface *interface)\n{\n uint_t i;\n uint_t k;\n uint32_t crc;\n uint16_t hashTable[4];\n MacFilterEntry *entry;\n\n //Debug message\n TRACE_DEBUG(\"Updating MAC filter...\\r\\n\");\n\n //Clear hash table\n osMemset(hashTable, 0, sizeof(hashTable));\n\n //The MAC address filter contains the list of MAC addresses to accept\n //when receiving an Ethernet frame\n for(i = 0; i < MAC_ADDR_FILTER_SIZE; i++)\n {\n //Point to the current entry\n entry = &interface->macAddrFilter[i];\n\n //Valid entry?\n if(entry->refCount > 0)\n {\n //Compute CRC over the current MAC address\n crc = ksz8851CalcCrc(&entry->addr, sizeof(MacAddr));\n //Calculate the corresponding index in the table\n k = (crc >> 26) & 0x3F;\n //Update hash table contents\n hashTable[k / 16] |= (1 << (k % 16));\n }\n }\n\n //Write the hash table to the KSZ8851 controller\n ksz8851WriteReg(interface, KSZ8851_MAHTR0, hashTable[0]);\n ksz8851WriteReg(interface, KSZ8851_MAHTR1, hashTable[1]);\n ksz8851WriteReg(interface, KSZ8851_MAHTR2, hashTable[2]);\n ksz8851WriteReg(interface, KSZ8851_MAHTR3, hashTable[3]);\n\n //Debug message\n TRACE_DEBUG(\" MAHTR0 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_MAHTR0));\n TRACE_DEBUG(\" MAHTR1 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_MAHTR1));\n TRACE_DEBUG(\" MAHTR2 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_MAHTR2));\n TRACE_DEBUG(\" MAHTR3 = %04\" PRIX16 \"\\r\\n\", ksz8851ReadReg(interface, KSZ8851_MAHTR3));\n\n //Successful processing\n return NO_ERROR;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 1334, "func": "chdlc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)\n{\n\tregister u_int length = h->len;\n\tregister u_int caplen = h->caplen;\n\n\tif (caplen < CHDLC_HDRLEN) {\n\t\tND_PRINT((ndo, \"[|chdlc]\"));\n\t\treturn (caplen);\n\t}\n return (chdlc_print(ndo, p,length));\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13687", "cwe_id": "CWE-125" }, { "id": 1334, "func": "chdlc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)\n{\n\treturn chdlc_print(ndo, p, h->len);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13687", "cwe_id": "CWE-125" }, { "id": 3277, "func": "R_API RBinJavaAttrInfo *r_bin_java_inner_classes_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tRBinJavaClassesAttribute *icattr;\n\tRBinJavaAttrInfo *attr = NULL;\n\tRBinJavaCPTypeObj *obj;\n\tut32 i = 0;\n\tut64 offset = 0, curpos;\n\tattr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\toffset += 6;\n\tif (buf_offset + offset + 8 > sz) {\n\t\teprintf (\"Invalid amount of inner classes\\n\");\n\t\treturn NULL;\n\t}\n\tif (attr == NULL) {\n\t\t// TODO eprintf\n\t\treturn attr;\n\t}\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_INNER_CLASSES_ATTR;\n\tattr->info.inner_classes_attr.number_of_classes = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.inner_classes_attr.classes = r_list_newf (r_bin_java_inner_classes_attr_entry_free);\n\tfor (i = 0; i < attr->info.inner_classes_attr.number_of_classes; i++) {\n\t\tcurpos = buf_offset + offset;\n\t\tif (buf_offset + offset + 8 > sz) {\n\t\t\teprintf (\"Invalid amount of inner classes\\n\");\n\t\t\tbreak;\n\t\t}\n\t\ticattr = R_NEW0 (RBinJavaClassesAttribute);\n\t\tif (!icattr) {\n\t\t\tbreak;\n\t\t}\n\t\ticattr->inner_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->outer_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_name_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_class_access_flags = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->flags_str = retrieve_class_method_access_string (icattr->inner_class_access_flags);\n\t\ticattr->file_offset = curpos;\n\t\ticattr->size = 8;\n\n\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_name_idx);\n\t\tif (!obj) {\n\t\t\teprintf (\"BINCPLIS IS HULL %d\\n\", icattr->inner_name_idx);\n\t\t}\n\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\tif (!icattr->name) {\n\t\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_class_info_idx);\n\t\t\tif (!obj) {\n\t\t\t\teprintf (\"BINCPLIST IS NULL %d\\n\", icattr->inner_class_info_idx);\n\t\t\t}\n\t\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\t\tif (!icattr->name) {\n\t\t\t\ticattr->name = r_str_dup (NULL, \"NULL\");\n\t\t\t\teprintf (\"r_bin_java_inner_classes_attr: Unable to find the name for %d index.\\n\", icattr->inner_name_idx);\n\t\t\t\tfree (icattr);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tIFDBG eprintf (\"r_bin_java_inner_classes_attr: Inner class name %d is %s.\\n\", icattr->inner_name_idx, icattr->name);\n\t\tr_list_append (attr->info.inner_classes_attr.classes, (void *) icattr);\n\t}\n\tattr->size = offset;\n\t// IFDBG r_bin_java_print_inner_classes_attr_summary(attr);\n\treturn attr;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-0519", "cwe_id": "CWE-119" }, { "id": 3277, "func": "R_API RBinJavaAttrInfo *r_bin_java_inner_classes_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {\n\tRBinJavaClassesAttribute *icattr;\n\tRBinJavaCPTypeObj *obj;\n\tut32 i = 0;\n\tut64 offset = 0, curpos;\n\tif (sz < 8) {\n\t\treturn NULL;\n\t}\n\tRBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);\n\tif (!attr) {\n\t\treturn NULL;\n\t}\n\toffset += 6;\n\tattr->type = R_BIN_JAVA_ATTR_TYPE_INNER_CLASSES_ATTR;\n\tattr->info.inner_classes_attr.number_of_classes = R_BIN_JAVA_USHORT (buffer, offset);\n\toffset += 2;\n\tattr->info.inner_classes_attr.classes = r_list_newf (r_bin_java_inner_classes_attr_entry_free);\n\tfor (i = 0; i < attr->info.inner_classes_attr.number_of_classes; i++) {\n\t\tcurpos = buf_offset + offset;\n\t\tif (offset + 8 > sz) {\n\t\t\teprintf (\"Invalid amount of inner classes\\n\");\n\t\t\tbreak;\n\t\t}\n\t\ticattr = R_NEW0 (RBinJavaClassesAttribute);\n\t\tif (!icattr) {\n\t\t\tbreak;\n\t\t}\n\t\ticattr->inner_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->outer_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_name_idx = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->inner_class_access_flags = R_BIN_JAVA_USHORT (buffer, offset);\n\t\toffset += 2;\n\t\ticattr->flags_str = retrieve_class_method_access_string (icattr->inner_class_access_flags);\n\t\ticattr->file_offset = curpos;\n\t\ticattr->size = 8;\n\n\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_name_idx);\n\t\tif (!obj) {\n\t\t\teprintf (\"BINCPLIS IS HULL %d\\n\", icattr->inner_name_idx);\n\t\t}\n\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\tif (!icattr->name) {\n\t\t\tobj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_class_info_idx);\n\t\t\tif (!obj) {\n\t\t\t\teprintf (\"BINCPLIST IS NULL %d\\n\", icattr->inner_class_info_idx);\n\t\t\t}\n\t\t\ticattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj);\n\t\t\tif (!icattr->name) {\n\t\t\t\ticattr->name = r_str_dup (NULL, \"NULL\");\n\t\t\t\teprintf (\"r_bin_java_inner_classes_attr: Unable to find the name for %d index.\\n\", icattr->inner_name_idx);\n\t\t\t\tfree (icattr);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tIFDBG eprintf (\"r_bin_java_inner_classes_attr: Inner class name %d is %s.\\n\", icattr->inner_name_idx, icattr->name);\n\t\tr_list_append (attr->info.inner_classes_attr.classes, (void *) icattr);\n\t}\n\tattr->size = offset;\n\t// IFDBG r_bin_java_print_inner_classes_attr_summary(attr);\n\treturn attr;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-0519", "cwe_id": "CWE-119" }, { "id": 2249, "func": "forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,\n\t\t UChar* range, UChar** low, UChar** high, UChar** low_prev)\n{\n UChar *p, *pprev = (UChar* )NULL;\n\n#ifdef ONIG_DEBUG_SEARCH\n fprintf(stderr, \"forward_search_range: str: %d, end: %d, s: %d, range: %d\\n\",\n\t (int )str, (int )end, (int )s, (int )range);\n#endif\n\n p = s;\n if (reg->dmin > 0) {\n if (ONIGENC_IS_SINGLEBYTE(reg->enc)) {\n p += reg->dmin;\n }\n else {\n UChar *q = p + reg->dmin;\n\n if (q >= end) return 0; /* fail */\n while (p < q) p += enclen(reg->enc, p);\n }\n }\n\n retry:\n switch (reg->optimize) {\n case ONIG_OPTIMIZE_EXACT:\n p = slow_search(reg->enc, reg->exact, reg->exact_end, p, end, range);\n break;\n case ONIG_OPTIMIZE_EXACT_IC:\n p = slow_search_ic(reg->enc, reg->case_fold_flag,\n reg->exact, reg->exact_end, p, end, range);\n break;\n\n case ONIG_OPTIMIZE_EXACT_BM:\n p = bm_search(reg, reg->exact, reg->exact_end, p, end, range);\n break;\n\n case ONIG_OPTIMIZE_EXACT_BM_NOT_REV:\n p = bm_search_notrev(reg, reg->exact, reg->exact_end, p, end, range);\n break;\n\n case ONIG_OPTIMIZE_MAP:\n p = map_search(reg->enc, reg->map, p, range);\n break;\n }\n\n if (p && p < range) {\n if (p - reg->dmin < s) {\n retry_gate:\n pprev = p;\n p += enclen(reg->enc, p);\n goto retry;\n }\n\n if (reg->sub_anchor) {\n UChar* prev;\n\n switch (reg->sub_anchor) {\n case ANCHOR_BEGIN_LINE:\n if (!ON_STR_BEGIN(p)) {\n prev = onigenc_get_prev_char_head(reg->enc,\n (pprev ? pprev : str), p);\n if (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end))\n goto retry_gate;\n }\n break;\n\n case ANCHOR_END_LINE:\n if (ON_STR_END(p)) {\n#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE\n prev = (UChar* )onigenc_get_prev_char_head(reg->enc,\n (pprev ? pprev : str), p);\n if (prev && ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end))\n goto retry_gate;\n#endif\n }\n else if (! ONIGENC_IS_MBC_NEWLINE(reg->enc, p, end)\n#ifdef USE_CRNL_AS_LINE_TERMINATOR\n && ! ONIGENC_IS_MBC_CRNL(reg->enc, p, end)\n#endif\n )\n goto retry_gate;\n break;\n }\n }\n\n if (reg->dmax == 0) {\n *low = p;\n if (low_prev) {\n if (*low > s)\n *low_prev = onigenc_get_prev_char_head(reg->enc, s, p);\n else\n *low_prev = onigenc_get_prev_char_head(reg->enc,\n (pprev ? pprev : str), p);\n }\n }\n else {\n if (reg->dmax != ONIG_INFINITE_DISTANCE) {\n *low = p - reg->dmax;\n if (*low > s) {\n *low = onigenc_get_right_adjust_char_head_with_prev(reg->enc, s,\n *low, (const UChar** )low_prev);\n if (low_prev && IS_NULL(*low_prev))\n *low_prev = onigenc_get_prev_char_head(reg->enc,\n (pprev ? pprev : s), *low);\n }\n else {\n if (low_prev)\n *low_prev = onigenc_get_prev_char_head(reg->enc,\n (pprev ? pprev : str), *low);\n }\n }\n }\n /* no needs to adjust *high, *high is used as range check only */\n *high = p - reg->dmin;\n\n#ifdef ONIG_DEBUG_SEARCH\n fprintf(stderr,\n \"forward_search_range success: low: %d, high: %d, dmin: %d, dmax: %d\\n\",\n\t (int )(*low - str), (int )(*high - str), reg->dmin, reg->dmax);\n#endif\n return 1; /* success */\n }\n\n return 0; /* fail */\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-9229", "cwe_id": "CWE-476" }, { "id": 2249, "func": "forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,\n\t\t UChar* range, UChar** low, UChar** high, UChar** low_prev)\n{\n UChar *p, *pprev = (UChar* )NULL;\n\n#ifdef ONIG_DEBUG_SEARCH\n fprintf(stderr, \"forward_search_range: str: %d, end: %d, s: %d, range: %d\\n\",\n\t (int )str, (int )end, (int )s, (int )range);\n#endif\n\n p = s;\n if (reg->dmin > 0) {\n if (ONIGENC_IS_SINGLEBYTE(reg->enc)) {\n p += reg->dmin;\n }\n else {\n UChar *q = p + reg->dmin;\n\n if (q >= end) return 0; /* fail */\n while (p < q) p += enclen(reg->enc, p);\n }\n }\n\n retry:\n switch (reg->optimize) {\n case ONIG_OPTIMIZE_EXACT:\n p = slow_search(reg->enc, reg->exact, reg->exact_end, p, end, range);\n break;\n case ONIG_OPTIMIZE_EXACT_IC:\n p = slow_search_ic(reg->enc, reg->case_fold_flag,\n reg->exact, reg->exact_end, p, end, range);\n break;\n\n case ONIG_OPTIMIZE_EXACT_BM:\n p = bm_search(reg, reg->exact, reg->exact_end, p, end, range);\n break;\n\n case ONIG_OPTIMIZE_EXACT_BM_NOT_REV:\n p = bm_search_notrev(reg, reg->exact, reg->exact_end, p, end, range);\n break;\n\n case ONIG_OPTIMIZE_MAP:\n p = map_search(reg->enc, reg->map, p, range);\n break;\n }\n\n if (p && p < range) {\n if (p - reg->dmin < s) {\n retry_gate:\n pprev = p;\n p += enclen(reg->enc, p);\n goto retry;\n }\n\n if (reg->sub_anchor) {\n UChar* prev;\n\n switch (reg->sub_anchor) {\n case ANCHOR_BEGIN_LINE:\n if (!ON_STR_BEGIN(p)) {\n prev = onigenc_get_prev_char_head(reg->enc,\n (pprev ? pprev : str), p);\n if (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end))\n goto retry_gate;\n }\n break;\n\n case ANCHOR_END_LINE:\n if (ON_STR_END(p)) {\n#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE\n prev = (UChar* )onigenc_get_prev_char_head(reg->enc,\n (pprev ? pprev : str), p);\n if (prev && ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end))\n goto retry_gate;\n#endif\n }\n else if (! ONIGENC_IS_MBC_NEWLINE(reg->enc, p, end)\n#ifdef USE_CRNL_AS_LINE_TERMINATOR\n && ! ONIGENC_IS_MBC_CRNL(reg->enc, p, end)\n#endif\n )\n goto retry_gate;\n break;\n }\n }\n\n if (reg->dmax == 0) {\n *low = p;\n if (low_prev) {\n if (*low > s)\n *low_prev = onigenc_get_prev_char_head(reg->enc, s, p);\n else\n *low_prev = onigenc_get_prev_char_head(reg->enc,\n (pprev ? pprev : str), p);\n }\n }\n else {\n if (reg->dmax != ONIG_INFINITE_DISTANCE) {\n if (p - str < reg->dmax) {\n *low = (UChar* )str;\n if (low_prev)\n *low_prev = onigenc_get_prev_char_head(reg->enc, str, *low);\n }\n else {\n *low = p - reg->dmax;\n if (*low > s) {\n *low = onigenc_get_right_adjust_char_head_with_prev(reg->enc, s,\n *low, (const UChar** )low_prev);\n if (low_prev && IS_NULL(*low_prev))\n *low_prev = onigenc_get_prev_char_head(reg->enc,\n (pprev ? pprev : s), *low);\n }\n else {\n if (low_prev)\n *low_prev = onigenc_get_prev_char_head(reg->enc,\n (pprev ? pprev : str), *low);\n }\n }\n }\n }\n /* no needs to adjust *high, *high is used as range check only */\n *high = p - reg->dmin;\n\n#ifdef ONIG_DEBUG_SEARCH\n fprintf(stderr,\n \"forward_search_range success: low: %d, high: %d, dmin: %d, dmax: %d\\n\",\n\t (int )(*low - str), (int )(*high - str), reg->dmin, reg->dmax);\n#endif\n return 1; /* success */\n }\n\n return 0; /* fail */\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-9229", "cwe_id": "CWE-476" }, { "id": 800, "func": "int sc_file_set_sec_attr(sc_file_t *file, const u8 *sec_attr,\n\t\t\t size_t sec_attr_len)\n{\n\tu8 *tmp;\n\tif (!sc_file_valid(file)) {\n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\t}\n\n\tif (sec_attr == NULL) {\n\t\tif (file->sec_attr != NULL)\n\t\t\tfree(file->sec_attr);\n\t\tfile->sec_attr = NULL;\n\t\tfile->sec_attr_len = 0;\n\t\treturn 0;\n\t }\n\ttmp = (u8 *) realloc(file->sec_attr, sec_attr_len);\n\tif (!tmp) {\n\t\tif (file->sec_attr)\n\t\t\tfree(file->sec_attr);\n\t\tfile->sec_attr = NULL;\n\t\tfile->sec_attr_len = 0;\n\t\treturn SC_ERROR_OUT_OF_MEMORY;\n\t}\n\tfile->sec_attr = tmp;\n\tmemcpy(file->sec_attr, sec_attr, sec_attr_len);\n\tfile->sec_attr_len = sec_attr_len;\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-16391", "cwe_id": "CWE-119" }, { "id": 800, "func": "int sc_file_set_sec_attr(sc_file_t *file, const u8 *sec_attr,\n\t\t\t size_t sec_attr_len)\n{\n\tu8 *tmp;\n\tif (!sc_file_valid(file)) {\n\t\treturn SC_ERROR_INVALID_ARGUMENTS;\n\t}\n\n\tif (sec_attr == NULL || sec_attr_len) {\n\t\tif (file->sec_attr != NULL)\n\t\t\tfree(file->sec_attr);\n\t\tfile->sec_attr = NULL;\n\t\tfile->sec_attr_len = 0;\n\t\treturn 0;\n\t }\n\ttmp = (u8 *) realloc(file->sec_attr, sec_attr_len);\n\tif (!tmp) {\n\t\tif (file->sec_attr)\n\t\t\tfree(file->sec_attr);\n\t\tfile->sec_attr = NULL;\n\t\tfile->sec_attr_len = 0;\n\t\treturn SC_ERROR_OUT_OF_MEMORY;\n\t}\n\tfile->sec_attr = tmp;\n\tmemcpy(file->sec_attr, sec_attr, sec_attr_len);\n\tfile->sec_attr_len = sec_attr_len;\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-16391", "cwe_id": "CWE-119" }, { "id": 2344, "func": "void snd_msndmidi_input_read(void *mpuv)\n{\n\tunsigned long flags;\n\tstruct snd_msndmidi *mpu = mpuv;\n\tvoid *pwMIDQData = mpu->dev->mappedbase + MIDQ_DATA_BUFF;\n\n\tspin_lock_irqsave(&mpu->input_lock, flags);\n\twhile (readw(mpu->dev->MIDQ + JQS_wTail) !=\n\t readw(mpu->dev->MIDQ + JQS_wHead)) {\n\t\tu16 wTmp, val;\n\t\tval = readw(pwMIDQData + 2 * readw(mpu->dev->MIDQ + JQS_wHead));\n\n\t\t\tif (test_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER,\n\t\t\t\t &mpu->mode))\n\t\t\t\tsnd_rawmidi_receive(mpu->substream_input,\n\t\t\t\t\t\t (unsigned char *)&val, 1);\n\n\t\twTmp = readw(mpu->dev->MIDQ + JQS_wHead) + 1;\n\t\tif (wTmp > readw(mpu->dev->MIDQ + JQS_wSize))\n\t\t\twritew(0, mpu->dev->MIDQ + JQS_wHead);\n\t\telse\n\t\t\twritew(wTmp, mpu->dev->MIDQ + JQS_wHead);\n\t}\n\tspin_unlock_irqrestore(&mpu->input_lock, flags);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-9984", "cwe_id": "CWE-125" }, { "id": 2344, "func": "void snd_msndmidi_input_read(void *mpuv)\n{\n\tunsigned long flags;\n\tstruct snd_msndmidi *mpu = mpuv;\n\tvoid *pwMIDQData = mpu->dev->mappedbase + MIDQ_DATA_BUFF;\n\tu16 head, tail, size;\n\n\tspin_lock_irqsave(&mpu->input_lock, flags);\n\thead = readw(mpu->dev->MIDQ + JQS_wHead);\n\ttail = readw(mpu->dev->MIDQ + JQS_wTail);\n\tsize = readw(mpu->dev->MIDQ + JQS_wSize);\n\tif (head > size || tail > size)\n\t\tgoto out;\n\twhile (head != tail) {\n\t\tunsigned char val = readw(pwMIDQData + 2 * head);\n\n\t\tif (test_bit(MSNDMIDI_MODE_BIT_INPUT_TRIGGER, &mpu->mode))\n\t\t\tsnd_rawmidi_receive(mpu->substream_input, &val, 1);\n\t\tif (++head > size)\n\t\t\thead = 0;\n\t\twritew(head, mpu->dev->MIDQ + JQS_wHead);\n\t}\n out:\n\tspin_unlock_irqrestore(&mpu->input_lock, flags);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-9984", "cwe_id": "CWE-125" }, { "id": 2649, "func": "TfLiteStatus Subgraph::Invoke() {\n if (!consistent_) {\n ReportError(\"Invoke called on model that is not consistent.\");\n return kTfLiteError;\n }\n\n TfLiteStatus status = kTfLiteOk;\n if (state_ == kStateUninvokable) {\n ReportError(\"Invoke called on model that is not ready.\");\n return kTfLiteError;\n } else if (memory_planner_ && !memory_planner_->HasNonPersistentMemory()) {\n ReportError(\"Non-persistent memory is not available.\");\n return kTfLiteError;\n }\n TFLITE_SCOPED_TAGGED_DEFAULT_PROFILE(profiler_.get(), \"Invoke\");\n\n // Invocations are always done in node order.\n // Note that calling Invoke repeatedly will cause the original memory plan to\n // be reused, unless either ResizeInputTensor() or AllocateTensors() has been\n // called.\n for (int execution_plan_index = 0;\n execution_plan_index < execution_plan_.size(); execution_plan_index++) {\n if (execution_plan_index == next_execution_plan_index_to_prepare_) {\n TF_LITE_ENSURE_STATUS(PrepareOpsAndTensors());\n TF_LITE_ENSURE(&context_, next_execution_plan_index_to_prepare_ >=\n execution_plan_index);\n }\n int node_index = execution_plan_[execution_plan_index];\n TfLiteNode& node = nodes_and_registration_[node_index].first;\n const TfLiteRegistration& registration =\n nodes_and_registration_[node_index].second;\n\n const char* op_name = nullptr;\n if (profiler_) op_name = GetTFLiteOpName(registration);\n TFLITE_SCOPED_TAGGED_OPERATOR_PROFILE(profiler_.get(), op_name, node_index);\n\n for (int i = 0; i < node.inputs->size; ++i) {\n int tensor_index = node.inputs->data[i];\n if (tensor_index == kTfLiteOptionalTensor) {\n continue;\n }\n TfLiteTensor* tensor = &tensors_[tensor_index];\n if (tensor->delegate && tensor->delegate != node.delegate &&\n tensor->data_is_stale) {\n TF_LITE_ENSURE_STATUS(EnsureTensorDataIsReadable(tensor_index));\n }\n if (tensor->data.raw == nullptr && tensor->bytes > 0) {\n if (registration.builtin_code == kTfLiteBuiltinReshape && i == 1) {\n // In general, having a tensor here with no buffer will be an error.\n // However, for the reshape operator, the second input tensor is only\n // used for the shape, not for the data. Thus, null buffer is ok.\n continue;\n } else {\n // In all other cases, we need to return an error as otherwise we will\n // trigger a null pointer dereference (likely).\n ReportError(\"Input tensor %d lacks data\", tensor_index);\n return kTfLiteError;\n }\n }\n }\n\n if (check_cancelled_func_ != nullptr &&\n check_cancelled_func_(cancellation_data_)) {\n ReportError(\"Client requested cancel during Invoke()\");\n return kTfLiteError;\n }\n\n EnsureTensorsVectorCapacity();\n tensor_resized_since_op_invoke_ = false;\n if (OpInvoke(registration, &node) != kTfLiteOk) {\n return ReportOpError(&context_, node, registration, node_index,\n \"failed to invoke\");\n }\n\n // Force execution prep for downstream ops if the latest op triggered the\n // resize of a dynamic tensor.\n if (tensor_resized_since_op_invoke_ &&\n HasDynamicTensor(context_, node.outputs)) {\n next_execution_plan_index_to_prepare_ = execution_plan_index + 1;\n\n // This happens when an intermediate dynamic tensor is resized.\n // We don't have to prepare all the ops, but we need to recompute\n // the allocation plan.\n if (next_execution_plan_index_to_plan_allocation_ >\n next_execution_plan_index_to_prepare_) {\n next_execution_plan_index_to_plan_allocation_ =\n next_execution_plan_index_to_prepare_;\n if (memory_planner_) {\n TF_LITE_ENSURE_STATUS(memory_planner_->ResetAllocationsAfter(\n next_execution_plan_index_to_plan_allocation_ - 1));\n }\n }\n }\n }\n\n return status;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-29592", "cwe_id": "CWE-476" }, { "id": 2649, "func": "TfLiteStatus Subgraph::Invoke() {\n if (!consistent_) {\n ReportError(\"Invoke called on model that is not consistent.\");\n return kTfLiteError;\n }\n\n TfLiteStatus status = kTfLiteOk;\n if (state_ == kStateUninvokable) {\n ReportError(\"Invoke called on model that is not ready.\");\n return kTfLiteError;\n } else if (memory_planner_ && !memory_planner_->HasNonPersistentMemory()) {\n ReportError(\"Non-persistent memory is not available.\");\n return kTfLiteError;\n }\n TFLITE_SCOPED_TAGGED_DEFAULT_PROFILE(profiler_.get(), \"Invoke\");\n\n // Invocations are always done in node order.\n // Note that calling Invoke repeatedly will cause the original memory plan to\n // be reused, unless either ResizeInputTensor() or AllocateTensors() has been\n // called.\n for (int execution_plan_index = 0;\n execution_plan_index < execution_plan_.size(); execution_plan_index++) {\n if (execution_plan_index == next_execution_plan_index_to_prepare_) {\n TF_LITE_ENSURE_STATUS(PrepareOpsAndTensors());\n TF_LITE_ENSURE(&context_, next_execution_plan_index_to_prepare_ >=\n execution_plan_index);\n }\n int node_index = execution_plan_[execution_plan_index];\n TfLiteNode& node = nodes_and_registration_[node_index].first;\n const TfLiteRegistration& registration =\n nodes_and_registration_[node_index].second;\n\n const char* op_name = nullptr;\n if (profiler_) op_name = GetTFLiteOpName(registration);\n TFLITE_SCOPED_TAGGED_OPERATOR_PROFILE(profiler_.get(), op_name, node_index);\n\n for (int i = 0; i < node.inputs->size; ++i) {\n int tensor_index = node.inputs->data[i];\n if (tensor_index == kTfLiteOptionalTensor) {\n continue;\n }\n TfLiteTensor* tensor = &tensors_[tensor_index];\n if (tensor->delegate && tensor->delegate != node.delegate &&\n tensor->data_is_stale) {\n TF_LITE_ENSURE_STATUS(EnsureTensorDataIsReadable(tensor_index));\n }\n if (tensor->data.raw == nullptr && tensor->bytes > 0) {\n if (registration.builtin_code == kTfLiteBuiltinReshape && i == 1 &&\n tensor->dims->size != 1) {\n // In general, having a tensor here with no buffer will be an error.\n // However, for the reshape operator, the second input tensor is\n // sometimes only used for the shape, not for the data. Thus, null\n // buffer is ok in this situation.\n // The situation where null buffer is not ok for reshape operator is\n // only when there are 2 inputs given to the node and the one\n // corresponding to the shape (i == 1) is a vector that contains all\n // dimensions. See `GetOutputShape()` function in\n // `tensorflow/lite/kernels/reshape.cc`\n continue;\n } else {\n // In all other cases, we need to return an error as otherwise we will\n // trigger a null pointer dereference (likely).\n ReportError(\"Input tensor %d lacks data\", tensor_index);\n return kTfLiteError;\n }\n }\n }\n\n if (check_cancelled_func_ != nullptr &&\n check_cancelled_func_(cancellation_data_)) {\n ReportError(\"Client requested cancel during Invoke()\");\n return kTfLiteError;\n }\n\n EnsureTensorsVectorCapacity();\n tensor_resized_since_op_invoke_ = false;\n if (OpInvoke(registration, &node) != kTfLiteOk) {\n return ReportOpError(&context_, node, registration, node_index,\n \"failed to invoke\");\n }\n\n // Force execution prep for downstream ops if the latest op triggered the\n // resize of a dynamic tensor.\n if (tensor_resized_since_op_invoke_ &&\n HasDynamicTensor(context_, node.outputs)) {\n next_execution_plan_index_to_prepare_ = execution_plan_index + 1;\n\n // This happens when an intermediate dynamic tensor is resized.\n // We don't have to prepare all the ops, but we need to recompute\n // the allocation plan.\n if (next_execution_plan_index_to_plan_allocation_ >\n next_execution_plan_index_to_prepare_) {\n next_execution_plan_index_to_plan_allocation_ =\n next_execution_plan_index_to_prepare_;\n if (memory_planner_) {\n TF_LITE_ENSURE_STATUS(memory_planner_->ResetAllocationsAfter(\n next_execution_plan_index_to_plan_allocation_ - 1));\n }\n }\n }\n }\n\n return status;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-29592", "cwe_id": "CWE-476" }, { "id": 2227, "func": "static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,\n\t\t size_t len, int noblock, int flags, int *addr_len)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tsize_t copied = 0;\n\tint err = -EOPNOTSUPP;\n\tstruct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;\n\tstruct sk_buff *skb;\n\n\tif (flags & MSG_OOB)\n\t\tgoto out;\n\n\tif (addr_len)\n\t\t*addr_len = sizeof(*sin);\n\n\tif (flags & MSG_ERRQUEUE) {\n\t\terr = ip_recv_error(sk, msg, len);\n\t\tgoto out;\n\t}\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &err);\n\tif (!skb)\n\t\tgoto out;\n\n\tcopied = skb->len;\n\tif (len < copied) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err)\n\t\tgoto done;\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\t/* Copy the address. */\n\tif (sin) {\n\t\tsin->sin_family = AF_INET;\n\t\tsin->sin_addr.s_addr = ip_hdr(skb)->saddr;\n\t\tsin->sin_port = 0;\n\t\tmemset(&sin->sin_zero, 0, sizeof(sin->sin_zero));\n\t}\n\tif (inet->cmsg_flags)\n\t\tip_cmsg_recv(msg, skb);\n\tif (flags & MSG_TRUNC)\n\t\tcopied = skb->len;\ndone:\n\tskb_free_datagram(sk, skb);\nout:\n\tif (err)\n\t\treturn err;\n\treturn copied;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-7263", "cwe_id": "CWE-20" }, { "id": 2227, "func": "static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,\n\t\t size_t len, int noblock, int flags, int *addr_len)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tsize_t copied = 0;\n\tint err = -EOPNOTSUPP;\n\tstruct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;\n\tstruct sk_buff *skb;\n\n\tif (flags & MSG_OOB)\n\t\tgoto out;\n\n\tif (flags & MSG_ERRQUEUE) {\n\t\terr = ip_recv_error(sk, msg, len);\n\t\tgoto out;\n\t}\n\n\tskb = skb_recv_datagram(sk, flags, noblock, &err);\n\tif (!skb)\n\t\tgoto out;\n\n\tcopied = skb->len;\n\tif (len < copied) {\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t\tcopied = len;\n\t}\n\n\terr = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (err)\n\t\tgoto done;\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\t/* Copy the address. */\n\tif (sin) {\n\t\tsin->sin_family = AF_INET;\n\t\tsin->sin_addr.s_addr = ip_hdr(skb)->saddr;\n\t\tsin->sin_port = 0;\n\t\tmemset(&sin->sin_zero, 0, sizeof(sin->sin_zero));\n\t\t*addr_len = sizeof(*sin);\n\t}\n\tif (inet->cmsg_flags)\n\t\tip_cmsg_recv(msg, skb);\n\tif (flags & MSG_TRUNC)\n\t\tcopied = skb->len;\ndone:\n\tskb_free_datagram(sk, skb);\nout:\n\tif (err)\n\t\treturn err;\n\treturn copied;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-7263", "cwe_id": "CWE-20" }, { "id": 21, "func": "static void gf_dump_vrml_proto_field(GF_SceneDumper *sdump, GF_Node *node, GF_FieldInfo field)\n{\n\tu32 i, sf_type;\n\tvoid *slot_ptr;\n\n\tDUMP_IND(sdump);\n\tgf_fprintf(sdump->trace, \"trace, \">\\n\");\n\t\t\tsdump->indent++;\n\t\t\tif (!sdump->X3DDump) gf_fprintf(sdump->trace, \"\");\n\t\t\tgf_dump_vrml_node(sdump, field.far_ptr ? *(GF_Node **)field.far_ptr : NULL, 0, NULL);\n\t\t\tif (!sdump->X3DDump) gf_fprintf(sdump->trace, \"\");\n\t\t\tsdump->indent--;\n\t\t\tDUMP_IND(sdump);\n\t\t\tgf_fprintf(sdump->trace, \"\\n\");\n\t\t} else {\n\t\t\tif (sdump->X3DDump) {\n\t\t\t\tgf_fprintf(sdump->trace, \" value=\\\"\");\n\t\t\t} else {\n\t\t\t\tgf_fprintf(sdump->trace, \" %s=\\\"\", GetXMTFieldTypeValueName(field.fieldType));\n\t\t\t}\n\t\t\tgf_dump_vrml_sffield(sdump, field.fieldType, field.far_ptr, 0, node);\n\t\t\tgf_fprintf(sdump->trace, \"\\\"/>\\n\");\n\t\t}\n\t} else {\n\t\tGenMFField *mffield = (GenMFField *) field.far_ptr;\n\t\tsf_type = gf_sg_vrml_get_sf_type(field.fieldType);\n\n\t\tif ((field.eventType==GF_SG_EVENT_FIELD) || (field.eventType==GF_SG_EVENT_EXPOSED_FIELD)) {\n\t\t\tif (sf_type == GF_SG_VRML_SFNODE) {\n\t\t\t\tGF_ChildNodeItem *list = *(GF_ChildNodeItem **)field.far_ptr;\n\t\t\t\tgf_fprintf(sdump->trace, \">\\n\");\n\t\t\t\tsdump->indent++;\n\t\t\t\tif (!sdump->X3DDump) gf_fprintf(sdump->trace, \"\");\n\t\t\t\twhile (list) {\n\t\t\t\t\tgf_dump_vrml_node(sdump, list->node, 1, NULL);\n\t\t\t\t\tlist = list->next;\n\t\t\t\t}\n\t\t\t\tif (!sdump->X3DDump) gf_fprintf(sdump->trace, \"\");\n\t\t\t\tsdump->indent--;\n\t\t\t\tDUMP_IND(sdump);\n\t\t\t\tgf_fprintf(sdump->trace, \"\\n\");\n\t\t\t} else {\n\t\t\t\tif (sdump->X3DDump) {\n\t\t\t\t\tgf_fprintf(sdump->trace, \" value=\\\"\");\n\t\t\t\t} else {\n\t\t\t\t\tgf_fprintf(sdump->trace, \" %s=\\\"\", GetXMTFieldTypeValueName(field.fieldType));\n\t\t\t\t}\n\t\t\t\tif (mffield) {\n\t\t\t\t\tfor (i=0; icount; i++) {\n\t\t\t\t\t\tif (i) gf_fprintf(sdump->trace, \" \");\n\t\t\t\t\t\tif (field.fieldType != GF_SG_VRML_MFNODE) {\n\t\t\t\t\t\t\tgf_sg_vrml_mf_get_item(field.far_ptr, field.fieldType, &slot_ptr, i);\n\t\t\t\t\t\t\tgf_dump_vrml_sffield(sdump, sf_type, slot_ptr, (mffield->count>1) ? 1 : 0, node);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tgf_fprintf(sdump->trace, \"\\\"/>\\n\");\n\t\t\t}\n\t\t}\n\t}\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-2549", "cwe_id": "CWE-476" }, { "id": 21, "func": "static void gf_dump_vrml_proto_field(GF_SceneDumper *sdump, GF_Node *node, GF_FieldInfo field)\n{\n\tu32 i, sf_type;\n\tvoid *slot_ptr;\n\n\tDUMP_IND(sdump);\n\tgf_fprintf(sdump->trace, \"trace, \">\\n\");\n\t\t\tsdump->indent++;\n\t\t\tif (!sdump->X3DDump) gf_fprintf(sdump->trace, \"\");\n\t\t\tgf_dump_vrml_node(sdump, field.far_ptr ? *(GF_Node **)field.far_ptr : NULL, 0, NULL);\n\t\t\tif (!sdump->X3DDump) gf_fprintf(sdump->trace, \"\");\n\t\t\tsdump->indent--;\n\t\t\tDUMP_IND(sdump);\n\t\t\tgf_fprintf(sdump->trace, \"\\n\");\n\t\t} else {\n\t\t\tif (sdump->X3DDump) {\n\t\t\t\tgf_fprintf(sdump->trace, \" value=\\\"\");\n\t\t\t} else {\n\t\t\t\tgf_fprintf(sdump->trace, \" %s=\\\"\", GetXMTFieldTypeValueName(field.fieldType));\n\t\t\t}\n\t\t\tgf_dump_vrml_sffield(sdump, field.fieldType, field.far_ptr, 0, node);\n\t\t\tgf_fprintf(sdump->trace, \"\\\"/>\\n\");\n\t\t}\n\t} else {\n\t\tGenMFField *mffield = (GenMFField *) field.far_ptr;\n\t\tsf_type = gf_sg_vrml_get_sf_type(field.fieldType);\n\n\t\tif ((field.eventType==GF_SG_EVENT_FIELD) || (field.eventType==GF_SG_EVENT_EXPOSED_FIELD)) {\n\t\t\tif (sf_type == GF_SG_VRML_SFNODE) {\n\t\t\t\tGF_ChildNodeItem *list = *(GF_ChildNodeItem **)field.far_ptr;\n\t\t\t\tgf_fprintf(sdump->trace, \">\\n\");\n\t\t\t\tsdump->indent++;\n\t\t\t\tif (!sdump->X3DDump) gf_fprintf(sdump->trace, \"\");\n\t\t\t\twhile (list) {\n\t\t\t\t\tgf_dump_vrml_node(sdump, list->node, 1, NULL);\n\t\t\t\t\tlist = list->next;\n\t\t\t\t}\n\t\t\t\tif (!sdump->X3DDump) gf_fprintf(sdump->trace, \"\");\n\t\t\t\tsdump->indent--;\n\t\t\t\tDUMP_IND(sdump);\n\t\t\t\tgf_fprintf(sdump->trace, \"\\n\");\n\t\t\t} else {\n\t\t\t\tif (sdump->X3DDump) {\n\t\t\t\t\tgf_fprintf(sdump->trace, \" value=\\\"\");\n\t\t\t\t} else {\n\t\t\t\t\tgf_fprintf(sdump->trace, \" %s=\\\"\", GetXMTFieldTypeValueName(field.fieldType));\n\t\t\t\t}\n\t\t\t\tfor (i=0; mffield && (icount); i++) {\n\t\t\t\t\tif (i) gf_fprintf(sdump->trace, \" \");\n\t\t\t\t\tif (field.fieldType != GF_SG_VRML_MFNODE) {\n\t\t\t\t\t\tgf_sg_vrml_mf_get_item(field.far_ptr, field.fieldType, &slot_ptr, i);\n\t\t\t\t\t\tgf_dump_vrml_sffield(sdump, sf_type, slot_ptr, (mffield->count>1) ? 1 : 0, node);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tgf_fprintf(sdump->trace, \"\\\"/>\\n\");\n\t\t\t}\n\t\t}\n\t}\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-2549", "cwe_id": "CWE-476" }, { "id": 2573, "func": "juniper_mfr_print(netdissect_options *ndo,\n const struct pcap_pkthdr *h, register const u_char *p)\n{\n struct juniper_l2info_t l2info;\n\n memset(&l2info, 0, sizeof(l2info));\n l2info.pictype = DLT_JUNIPER_MFR;\n if (juniper_parse_header(ndo, p, h, &l2info) == 0)\n return l2info.header_len;\n\n p+=l2info.header_len;\n\n /* child-link ? */\n if (l2info.cookie_len == 0) {\n mfr_print(ndo, p, l2info.length);\n return l2info.header_len;\n }\n\n /* first try the LSQ protos */\n if (l2info.cookie_len == AS_PIC_COOKIE_LEN) {\n switch(l2info.proto) {\n case JUNIPER_LSQ_L3_PROTO_IPV4:\n ip_print(ndo, p, l2info.length);\n return l2info.header_len;\n case JUNIPER_LSQ_L3_PROTO_IPV6:\n ip6_print(ndo, p,l2info.length);\n return l2info.header_len;\n case JUNIPER_LSQ_L3_PROTO_MPLS:\n mpls_print(ndo, p, l2info.length);\n return l2info.header_len;\n case JUNIPER_LSQ_L3_PROTO_ISO:\n isoclns_print(ndo, p, l2info.length, l2info.caplen);\n return l2info.header_len;\n default:\n break;\n }\n return l2info.header_len;\n }\n\n /* suppress Bundle-ID if frame was captured on a child-link */\n if (ndo->ndo_eflag && EXTRACT_32BITS(l2info.cookie) != 1)\n ND_PRINT((ndo, \"Bundle-ID %u, \", l2info.bundle));\n switch (l2info.proto) {\n case (LLCSAP_ISONS<<8 | LLCSAP_ISONS):\n isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);\n break;\n case (LLC_UI<<8 | NLPID_Q933):\n case (LLC_UI<<8 | NLPID_IP):\n case (LLC_UI<<8 | NLPID_IP6):\n /* pass IP{4,6} to the OSI layer for proper link-layer printing */\n isoclns_print(ndo, p - 1, l2info.length + 1, l2info.caplen + 1);\n break;\n default:\n ND_PRINT((ndo, \"unknown protocol 0x%04x, length %u\", l2info.proto, l2info.length));\n }\n\n return l2info.header_len;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-12897", "cwe_id": "CWE-125" }, { "id": 2573, "func": "juniper_mfr_print(netdissect_options *ndo,\n const struct pcap_pkthdr *h, register const u_char *p)\n{\n struct juniper_l2info_t l2info;\n\n memset(&l2info, 0, sizeof(l2info));\n l2info.pictype = DLT_JUNIPER_MFR;\n if (juniper_parse_header(ndo, p, h, &l2info) == 0)\n return l2info.header_len;\n\n p+=l2info.header_len;\n\n /* child-link ? */\n if (l2info.cookie_len == 0) {\n mfr_print(ndo, p, l2info.length);\n return l2info.header_len;\n }\n\n /* first try the LSQ protos */\n if (l2info.cookie_len == AS_PIC_COOKIE_LEN) {\n switch(l2info.proto) {\n case JUNIPER_LSQ_L3_PROTO_IPV4:\n ip_print(ndo, p, l2info.length);\n return l2info.header_len;\n case JUNIPER_LSQ_L3_PROTO_IPV6:\n ip6_print(ndo, p,l2info.length);\n return l2info.header_len;\n case JUNIPER_LSQ_L3_PROTO_MPLS:\n mpls_print(ndo, p, l2info.length);\n return l2info.header_len;\n case JUNIPER_LSQ_L3_PROTO_ISO:\n isoclns_print(ndo, p, l2info.length);\n return l2info.header_len;\n default:\n break;\n }\n return l2info.header_len;\n }\n\n /* suppress Bundle-ID if frame was captured on a child-link */\n if (ndo->ndo_eflag && EXTRACT_32BITS(l2info.cookie) != 1)\n ND_PRINT((ndo, \"Bundle-ID %u, \", l2info.bundle));\n switch (l2info.proto) {\n case (LLCSAP_ISONS<<8 | LLCSAP_ISONS):\n isoclns_print(ndo, p + 1, l2info.length - 1);\n break;\n case (LLC_UI<<8 | NLPID_Q933):\n case (LLC_UI<<8 | NLPID_IP):\n case (LLC_UI<<8 | NLPID_IP6):\n /* pass IP{4,6} to the OSI layer for proper link-layer printing */\n isoclns_print(ndo, p - 1, l2info.length + 1);\n break;\n default:\n ND_PRINT((ndo, \"unknown protocol 0x%04x, length %u\", l2info.proto, l2info.length));\n }\n\n return l2info.header_len;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-12897", "cwe_id": "CWE-125" }, { "id": 443, "func": "void ConnectionManagerImpl::ActiveStream::encodeHeaders(ResponseHeaderMap& headers,\n bool end_stream) {\n // Base headers.\n\n // We want to preserve the original date header, but we add a date header if it is absent\n if (!headers.Date()) {\n connection_manager_.config_.dateProvider().setDateHeader(headers);\n }\n\n // Following setReference() is safe because serverName() is constant for the life of the\n // listener.\n const auto transformation = connection_manager_.config_.serverHeaderTransformation();\n if (transformation == ConnectionManagerConfig::HttpConnectionManagerProto::OVERWRITE ||\n (transformation == ConnectionManagerConfig::HttpConnectionManagerProto::APPEND_IF_ABSENT &&\n headers.Server() == nullptr)) {\n headers.setReferenceServer(connection_manager_.config_.serverName());\n }\n ConnectionManagerUtility::mutateResponseHeaders(\n headers, request_headers_.get(), connection_manager_.config_,\n connection_manager_.config_.via(), filter_manager_.streamInfo(),\n connection_manager_.proxy_name_, connection_manager_.clear_hop_by_hop_response_headers_);\n\n bool drain_connection_due_to_overload = false;\n if (connection_manager_.drain_state_ == DrainState::NotDraining &&\n connection_manager_.random_generator_.bernoulli(\n connection_manager_.overload_disable_keepalive_ref_.value())) {\n ENVOY_STREAM_LOG(debug, \"disabling keepalive due to envoy overload\", *this);\n drain_connection_due_to_overload = true;\n connection_manager_.stats_.named_.downstream_cx_overload_disable_keepalive_.inc();\n }\n\n // See if we want to drain/close the connection. Send the go away frame prior to encoding the\n // header block.\n if (connection_manager_.drain_state_ == DrainState::NotDraining &&\n (connection_manager_.drain_close_.drainClose() || drain_connection_due_to_overload)) {\n\n // This doesn't really do anything for HTTP/1.1 other then give the connection another boost\n // of time to race with incoming requests. For HTTP/2 connections, send a GOAWAY frame to\n // prevent any new streams.\n connection_manager_.startDrainSequence();\n connection_manager_.stats_.named_.downstream_cx_drain_close_.inc();\n ENVOY_STREAM_LOG(debug, \"drain closing connection\", *this);\n }\n\n if (connection_manager_.codec_->protocol() == Protocol::Http10) {\n // As HTTP/1.0 and below can not do chunked encoding, if there is no content\n // length the response will be framed by connection close.\n if (!headers.ContentLength()) {\n state_.saw_connection_close_ = true;\n }\n // If the request came with a keep-alive and no other factor resulted in a\n // connection close header, send an explicit keep-alive header.\n if (!state_.saw_connection_close_) {\n headers.setConnection(Headers::get().ConnectionValues.KeepAlive);\n }\n }\n\n if (connection_manager_.drain_state_ == DrainState::NotDraining && state_.saw_connection_close_) {\n ENVOY_STREAM_LOG(debug, \"closing connection due to connection close header\", *this);\n connection_manager_.drain_state_ = DrainState::Closing;\n }\n\n // If we are destroying a stream before remote is complete and the connection does not support\n // multiplexing, we should disconnect since we don't want to wait around for the request to\n // finish.\n if (!filter_manager_.remoteComplete()) {\n if (connection_manager_.codec_->protocol() < Protocol::Http2) {\n connection_manager_.drain_state_ = DrainState::Closing;\n }\n\n connection_manager_.stats_.named_.downstream_rq_response_before_rq_complete_.inc();\n }\n\n if (connection_manager_.drain_state_ != DrainState::NotDraining &&\n connection_manager_.codec_->protocol() < Protocol::Http2) {\n // If the connection manager is draining send \"Connection: Close\" on HTTP/1.1 connections.\n // Do not do this for H2 (which drains via GOAWAY) or Upgrade or CONNECT (as the\n // payload is no longer HTTP/1.1)\n if (!Utility::isUpgrade(headers) &&\n !HeaderUtility::isConnectResponse(request_headers_.get(), *responseHeaders())) {\n headers.setReferenceConnection(Headers::get().ConnectionValues.Close);\n }\n }\n\n if (connection_manager_.config_.tracingConfig()) {\n if (connection_manager_.config_.tracingConfig()->operation_name_ ==\n Tracing::OperationName::Ingress) {\n // For ingress (inbound) responses, if the request headers do not include a\n // decorator operation (override), and the decorated operation should be\n // propagated, then pass the decorator's operation name (if defined)\n // as a response header to enable the client service to use it in its client span.\n if (decorated_operation_ && state_.decorated_propagate_) {\n headers.setEnvoyDecoratorOperation(*decorated_operation_);\n }\n } else if (connection_manager_.config_.tracingConfig()->operation_name_ ==\n Tracing::OperationName::Egress) {\n const HeaderEntry* resp_operation_override = headers.EnvoyDecoratorOperation();\n\n // For Egress (outbound) response, if a decorator operation name has been provided, it\n // should be used to override the active span's operation.\n if (resp_operation_override) {\n if (!resp_operation_override->value().empty() && active_span_) {\n active_span_->setOperation(resp_operation_override->value().getStringView());\n }\n // Remove header so not propagated to service.\n headers.removeEnvoyDecoratorOperation();\n }\n }\n }\n\n chargeStats(headers);\n\n ENVOY_STREAM_LOG(debug, \"encoding headers via codec (end_stream={}):\\n{}\", *this, end_stream,\n headers);\n\n // Now actually encode via the codec.\n filter_manager_.streamInfo().downstreamTiming().onFirstDownstreamTxByteSent(\n connection_manager_.time_source_);\n response_encoder_->encodeHeaders(headers, end_stream);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-43825", "cwe_id": "CWE-416" }, { "id": 443, "func": "void ConnectionManagerImpl::ActiveStream::encodeHeaders(ResponseHeaderMap& headers,\n bool end_stream) {\n // Base headers.\n\n // We want to preserve the original date header, but we add a date header if it is absent\n if (!headers.Date()) {\n connection_manager_.config_.dateProvider().setDateHeader(headers);\n }\n\n // Following setReference() is safe because serverName() is constant for the life of the\n // listener.\n const auto transformation = connection_manager_.config_.serverHeaderTransformation();\n if (transformation == ConnectionManagerConfig::HttpConnectionManagerProto::OVERWRITE ||\n (transformation == ConnectionManagerConfig::HttpConnectionManagerProto::APPEND_IF_ABSENT &&\n headers.Server() == nullptr)) {\n headers.setReferenceServer(connection_manager_.config_.serverName());\n }\n ConnectionManagerUtility::mutateResponseHeaders(\n headers, request_headers_.get(), connection_manager_.config_,\n connection_manager_.config_.via(), filter_manager_.streamInfo(),\n connection_manager_.proxy_name_, connection_manager_.clear_hop_by_hop_response_headers_);\n\n bool drain_connection_due_to_overload = false;\n if (connection_manager_.drain_state_ == DrainState::NotDraining &&\n connection_manager_.random_generator_.bernoulli(\n connection_manager_.overload_disable_keepalive_ref_.value())) {\n ENVOY_STREAM_LOG(debug, \"disabling keepalive due to envoy overload\", *this);\n drain_connection_due_to_overload = true;\n connection_manager_.stats_.named_.downstream_cx_overload_disable_keepalive_.inc();\n }\n\n // See if we want to drain/close the connection. Send the go away frame prior to encoding the\n // header block.\n if (connection_manager_.drain_state_ == DrainState::NotDraining &&\n (connection_manager_.drain_close_.drainClose() || drain_connection_due_to_overload)) {\n\n // This doesn't really do anything for HTTP/1.1 other then give the connection another boost\n // of time to race with incoming requests. For HTTP/2 connections, send a GOAWAY frame to\n // prevent any new streams.\n connection_manager_.startDrainSequence();\n connection_manager_.stats_.named_.downstream_cx_drain_close_.inc();\n ENVOY_STREAM_LOG(debug, \"drain closing connection\", *this);\n }\n\n if (connection_manager_.codec_->protocol() == Protocol::Http10) {\n // As HTTP/1.0 and below can not do chunked encoding, if there is no content\n // length the response will be framed by connection close.\n if (!headers.ContentLength()) {\n state_.saw_connection_close_ = true;\n }\n // If the request came with a keep-alive and no other factor resulted in a\n // connection close header, send an explicit keep-alive header.\n if (!state_.saw_connection_close_) {\n headers.setConnection(Headers::get().ConnectionValues.KeepAlive);\n }\n }\n\n if (connection_manager_.drain_state_ == DrainState::NotDraining && state_.saw_connection_close_) {\n ENVOY_STREAM_LOG(debug, \"closing connection due to connection close header\", *this);\n connection_manager_.drain_state_ = DrainState::Closing;\n }\n\n // If we are destroying a stream before remote is complete and the connection does not support\n // multiplexing, we should disconnect since we don't want to wait around for the request to\n // finish.\n if (!filter_manager_.remoteDecodeComplete()) {\n if (connection_manager_.codec_->protocol() < Protocol::Http2) {\n connection_manager_.drain_state_ = DrainState::Closing;\n }\n\n connection_manager_.stats_.named_.downstream_rq_response_before_rq_complete_.inc();\n }\n\n if (connection_manager_.drain_state_ != DrainState::NotDraining &&\n connection_manager_.codec_->protocol() < Protocol::Http2) {\n // If the connection manager is draining send \"Connection: Close\" on HTTP/1.1 connections.\n // Do not do this for H2 (which drains via GOAWAY) or Upgrade or CONNECT (as the\n // payload is no longer HTTP/1.1)\n if (!Utility::isUpgrade(headers) &&\n !HeaderUtility::isConnectResponse(request_headers_.get(), *responseHeaders())) {\n headers.setReferenceConnection(Headers::get().ConnectionValues.Close);\n }\n }\n\n if (connection_manager_.config_.tracingConfig()) {\n if (connection_manager_.config_.tracingConfig()->operation_name_ ==\n Tracing::OperationName::Ingress) {\n // For ingress (inbound) responses, if the request headers do not include a\n // decorator operation (override), and the decorated operation should be\n // propagated, then pass the decorator's operation name (if defined)\n // as a response header to enable the client service to use it in its client span.\n if (decorated_operation_ && state_.decorated_propagate_) {\n headers.setEnvoyDecoratorOperation(*decorated_operation_);\n }\n } else if (connection_manager_.config_.tracingConfig()->operation_name_ ==\n Tracing::OperationName::Egress) {\n const HeaderEntry* resp_operation_override = headers.EnvoyDecoratorOperation();\n\n // For Egress (outbound) response, if a decorator operation name has been provided, it\n // should be used to override the active span's operation.\n if (resp_operation_override) {\n if (!resp_operation_override->value().empty() && active_span_) {\n active_span_->setOperation(resp_operation_override->value().getStringView());\n }\n // Remove header so not propagated to service.\n headers.removeEnvoyDecoratorOperation();\n }\n }\n }\n\n chargeStats(headers);\n\n ENVOY_STREAM_LOG(debug, \"encoding headers via codec (end_stream={}):\\n{}\", *this, end_stream,\n headers);\n\n // Now actually encode via the codec.\n filter_manager_.streamInfo().downstreamTiming().onFirstDownstreamTxByteSent(\n connection_manager_.time_source_);\n response_encoder_->encodeHeaders(headers, end_stream);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-43825", "cwe_id": "CWE-416" }, { "id": 2054, "func": "static GF_AV1Config* AV1_DuplicateConfig(GF_AV1Config const * const cfg) {\n\tu32 i = 0;\n\tGF_AV1Config *out = gf_malloc(sizeof(GF_AV1Config));\n\n\tout->marker = cfg->marker;\n\tout->version = cfg->version;\n\tout->seq_profile = cfg->seq_profile;\n\tout->seq_level_idx_0 = cfg->seq_level_idx_0;\n\tout->seq_tier_0 = cfg->seq_tier_0;\n\tout->high_bitdepth = cfg->high_bitdepth;\n\tout->twelve_bit = cfg->twelve_bit;\n\tout->monochrome = cfg->monochrome;\n\tout->chroma_subsampling_x = cfg->chroma_subsampling_x;\n\tout->chroma_subsampling_y = cfg->chroma_subsampling_y;\n\tout->chroma_sample_position = cfg->chroma_sample_position;\n\n\tout->initial_presentation_delay_present = cfg->initial_presentation_delay_present;\n\tout->initial_presentation_delay_minus_one = cfg->initial_presentation_delay_minus_one;\n\tout->obu_array = gf_list_new();\n\tfor (i = 0; iobu_array); ++i) {\n\t\tGF_AV1_OBUArrayEntry *dst = gf_malloc(sizeof(GF_AV1_OBUArrayEntry)), *src = gf_list_get(cfg->obu_array, i);\n\t\tdst->obu_length = src->obu_length;\n\t\tdst->obu_type = src->obu_type;\n\t\tdst->obu = gf_malloc((size_t)dst->obu_length);\n\t\tmemcpy(dst->obu, src->obu, (size_t)src->obu_length);\n\t\tgf_list_add(out->obu_array, dst);\n\t}\n\treturn out;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-31262", "cwe_id": "CWE-476" }, { "id": 2054, "func": "static GF_AV1Config* AV1_DuplicateConfig(GF_AV1Config const * const cfg)\n{\n\tu32 i = 0;\n\tGF_AV1Config *out = gf_malloc(sizeof(GF_AV1Config));\n\n\tout->marker = cfg->marker;\n\tout->version = cfg->version;\n\tout->seq_profile = cfg->seq_profile;\n\tout->seq_level_idx_0 = cfg->seq_level_idx_0;\n\tout->seq_tier_0 = cfg->seq_tier_0;\n\tout->high_bitdepth = cfg->high_bitdepth;\n\tout->twelve_bit = cfg->twelve_bit;\n\tout->monochrome = cfg->monochrome;\n\tout->chroma_subsampling_x = cfg->chroma_subsampling_x;\n\tout->chroma_subsampling_y = cfg->chroma_subsampling_y;\n\tout->chroma_sample_position = cfg->chroma_sample_position;\n\n\tout->initial_presentation_delay_present = cfg->initial_presentation_delay_present;\n\tout->initial_presentation_delay_minus_one = cfg->initial_presentation_delay_minus_one;\n\tout->obu_array = gf_list_new();\n\tfor (i = 0; iobu_array); ++i) {\n\t\tGF_AV1_OBUArrayEntry *dst = gf_malloc(sizeof(GF_AV1_OBUArrayEntry)), *src = gf_list_get(cfg->obu_array, i);\n\t\tdst->obu_length = src->obu_length;\n\t\tdst->obu_type = src->obu_type;\n\t\tdst->obu = gf_malloc((size_t)dst->obu_length);\n\t\tmemcpy(dst->obu, src->obu, (size_t)src->obu_length);\n\t\tgf_list_add(out->obu_array, dst);\n\t}\n\treturn out;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-31262", "cwe_id": "CWE-476" }, { "id": 1507, "func": "static void f2fs_put_super(struct super_block *sb)\n{\n\tstruct f2fs_sb_info *sbi = F2FS_SB(sb);\n\tint i;\n\n\tf2fs_quota_off_umount(sb);\n\n\t/* prevent remaining shrinker jobs */\n\tmutex_lock(&sbi->umount_mutex);\n\n\t/*\n\t * We don't need to do checkpoint when superblock is clean.\n\t * But, the previous checkpoint was not done by umount, it needs to do\n\t * clean checkpoint again.\n\t */\n\tif (is_sbi_flag_set(sbi, SBI_IS_DIRTY) ||\n\t\t\t!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) {\n\t\tstruct cp_control cpc = {\n\t\t\t.reason = CP_UMOUNT,\n\t\t};\n\t\twrite_checkpoint(sbi, &cpc);\n\t}\n\n\t/* be sure to wait for any on-going discard commands */\n\tf2fs_wait_discard_bios(sbi);\n\n\tif (f2fs_discard_en(sbi) && !sbi->discard_blks) {\n\t\tstruct cp_control cpc = {\n\t\t\t.reason = CP_UMOUNT | CP_TRIMMED,\n\t\t};\n\t\twrite_checkpoint(sbi, &cpc);\n\t}\n\n\t/* write_checkpoint can update stat informaion */\n\tf2fs_destroy_stats(sbi);\n\n\t/*\n\t * normally superblock is clean, so we need to release this.\n\t * In addition, EIO will skip do checkpoint, we need this as well.\n\t */\n\trelease_ino_entry(sbi, true);\n\n\tf2fs_leave_shrinker(sbi);\n\tmutex_unlock(&sbi->umount_mutex);\n\n\t/* our cp_error case, we can wait for any writeback page */\n\tf2fs_flush_merged_writes(sbi);\n\n\tiput(sbi->node_inode);\n\tiput(sbi->meta_inode);\n\n\t/* destroy f2fs internal modules */\n\tdestroy_node_manager(sbi);\n\tdestroy_segment_manager(sbi);\n\n\tkfree(sbi->ckpt);\n\n\tf2fs_unregister_sysfs(sbi);\n\n\tsb->s_fs_info = NULL;\n\tif (sbi->s_chksum_driver)\n\t\tcrypto_free_shash(sbi->s_chksum_driver);\n\tkfree(sbi->raw_super);\n\n\tdestroy_device_list(sbi);\n\tmempool_destroy(sbi->write_io_dummy);\n#ifdef CONFIG_QUOTA\n\tfor (i = 0; i < MAXQUOTAS; i++)\n\t\tkfree(sbi->s_qf_names[i]);\n#endif\n\tdestroy_percpu_info(sbi);\n\tfor (i = 0; i < NR_PAGE_TYPE; i++)\n\t\tkfree(sbi->write_io[i]);\n\tkfree(sbi);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-18200", "cwe_id": "CWE-20" }, { "id": 1507, "func": "static void f2fs_put_super(struct super_block *sb)\n{\n\tstruct f2fs_sb_info *sbi = F2FS_SB(sb);\n\tint i;\n\n\tf2fs_quota_off_umount(sb);\n\n\t/* prevent remaining shrinker jobs */\n\tmutex_lock(&sbi->umount_mutex);\n\n\t/*\n\t * We don't need to do checkpoint when superblock is clean.\n\t * But, the previous checkpoint was not done by umount, it needs to do\n\t * clean checkpoint again.\n\t */\n\tif (is_sbi_flag_set(sbi, SBI_IS_DIRTY) ||\n\t\t\t!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) {\n\t\tstruct cp_control cpc = {\n\t\t\t.reason = CP_UMOUNT,\n\t\t};\n\t\twrite_checkpoint(sbi, &cpc);\n\t}\n\n\t/* be sure to wait for any on-going discard commands */\n\tf2fs_wait_discard_bios(sbi, true);\n\n\tif (f2fs_discard_en(sbi) && !sbi->discard_blks) {\n\t\tstruct cp_control cpc = {\n\t\t\t.reason = CP_UMOUNT | CP_TRIMMED,\n\t\t};\n\t\twrite_checkpoint(sbi, &cpc);\n\t}\n\n\t/* write_checkpoint can update stat informaion */\n\tf2fs_destroy_stats(sbi);\n\n\t/*\n\t * normally superblock is clean, so we need to release this.\n\t * In addition, EIO will skip do checkpoint, we need this as well.\n\t */\n\trelease_ino_entry(sbi, true);\n\n\tf2fs_leave_shrinker(sbi);\n\tmutex_unlock(&sbi->umount_mutex);\n\n\t/* our cp_error case, we can wait for any writeback page */\n\tf2fs_flush_merged_writes(sbi);\n\n\tiput(sbi->node_inode);\n\tiput(sbi->meta_inode);\n\n\t/* destroy f2fs internal modules */\n\tdestroy_node_manager(sbi);\n\tdestroy_segment_manager(sbi);\n\n\tkfree(sbi->ckpt);\n\n\tf2fs_unregister_sysfs(sbi);\n\n\tsb->s_fs_info = NULL;\n\tif (sbi->s_chksum_driver)\n\t\tcrypto_free_shash(sbi->s_chksum_driver);\n\tkfree(sbi->raw_super);\n\n\tdestroy_device_list(sbi);\n\tmempool_destroy(sbi->write_io_dummy);\n#ifdef CONFIG_QUOTA\n\tfor (i = 0; i < MAXQUOTAS; i++)\n\t\tkfree(sbi->s_qf_names[i]);\n#endif\n\tdestroy_percpu_info(sbi);\n\tfor (i = 0; i < NR_PAGE_TYPE; i++)\n\t\tkfree(sbi->write_io[i]);\n\tkfree(sbi);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-18200", "cwe_id": "CWE-20" }, { "id": 1354, "func": "mark_context_stack(mrb_state *mrb, struct mrb_context *c)\n{\n size_t i;\n size_t e;\n\n if (c->stack == NULL) return;\n e = c->stack - c->stbase;\n if (c->ci) e += c->ci->nregs;\n if (c->stbase + e > c->stend) e = c->stend - c->stbase;\n for (i=0; istbase[i];\n\n if (!mrb_immediate_p(v)) {\n if (mrb_basic_ptr(v)->tt == MRB_TT_FREE) {\n c->stbase[i] = mrb_nil_value();\n }\n else {\n mrb_gc_mark(mrb, mrb_basic_ptr(v));\n }\n }\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-9527", "cwe_id": "CWE-416" }, { "id": 1354, "func": "mark_context_stack(mrb_state *mrb, struct mrb_context *c)\n{\n size_t i;\n size_t e;\n mrb_value nil;\n\n if (c->stack == NULL) return;\n e = c->stack - c->stbase;\n if (c->ci) e += c->ci->nregs;\n if (c->stbase + e > c->stend) e = c->stend - c->stbase;\n for (i=0; istbase[i];\n\n if (!mrb_immediate_p(v)) {\n mrb_gc_mark(mrb, mrb_basic_ptr(v));\n }\n }\n e = c->stend - c->stbase;\n nil = mrb_nil_value();\n for (; istbase[i] = nil;\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-9527", "cwe_id": "CWE-416" }, { "id": 14, "func": "static int list_devices(struct file *filp, struct dm_ioctl *param, size_t param_size)\n{\n\tunsigned int i;\n\tstruct hash_cell *hc;\n\tsize_t len, needed = 0;\n\tstruct gendisk *disk;\n\tstruct dm_name_list *orig_nl, *nl, *old_nl = NULL;\n\tuint32_t *event_nr;\n\n\tdown_write(&_hash_lock);\n\n\t/*\n\t * Loop through all the devices working out how much\n\t * space we need.\n\t */\n\tfor (i = 0; i < NUM_BUCKETS; i++) {\n\t\tlist_for_each_entry (hc, _name_buckets + i, name_list) {\n\t\t\tneeded += align_val(offsetof(struct dm_name_list, name) + strlen(hc->name) + 1);\n\t\t\tneeded += align_val(sizeof(uint32_t));\n\t\t}\n\t}\n\n\t/*\n\t * Grab our output buffer.\n\t */\n\tnl = orig_nl = get_result_buffer(param, param_size, &len);\n\tif (len < needed) {\n\t\tparam->flags |= DM_BUFFER_FULL_FLAG;\n\t\tgoto out;\n\t}\n\tparam->data_size = param->data_start + needed;\n\n\tnl->dev = 0;\t/* Flags no data */\n\n\t/*\n\t * Now loop through filling out the names.\n\t */\n\tfor (i = 0; i < NUM_BUCKETS; i++) {\n\t\tlist_for_each_entry (hc, _name_buckets + i, name_list) {\n\t\t\tif (old_nl)\n\t\t\t\told_nl->next = (uint32_t) ((void *) nl -\n\t\t\t\t\t\t\t (void *) old_nl);\n\t\t\tdisk = dm_disk(hc->md);\n\t\t\tnl->dev = huge_encode_dev(disk_devt(disk));\n\t\t\tnl->next = 0;\n\t\t\tstrcpy(nl->name, hc->name);\n\n\t\t\told_nl = nl;\n\t\t\tevent_nr = align_ptr(nl->name + strlen(hc->name) + 1);\n\t\t\t*event_nr = dm_get_event_nr(hc->md);\n\t\t\tnl = align_ptr(event_nr + 1);\n\t\t}\n\t}\n\t/*\n\t * If mismatch happens, security may be compromised due to buffer\n\t * overflow, so it's better to crash.\n\t */\n\tBUG_ON((char *)nl - (char *)orig_nl != needed);\n\n out:\n\tup_write(&_hash_lock);\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-31916", "cwe_id": "CWE-787" }, { "id": 14, "func": "static int list_devices(struct file *filp, struct dm_ioctl *param, size_t param_size)\n{\n\tunsigned int i;\n\tstruct hash_cell *hc;\n\tsize_t len, needed = 0;\n\tstruct gendisk *disk;\n\tstruct dm_name_list *orig_nl, *nl, *old_nl = NULL;\n\tuint32_t *event_nr;\n\n\tdown_write(&_hash_lock);\n\n\t/*\n\t * Loop through all the devices working out how much\n\t * space we need.\n\t */\n\tfor (i = 0; i < NUM_BUCKETS; i++) {\n\t\tlist_for_each_entry (hc, _name_buckets + i, name_list) {\n\t\t\tneeded += align_val(offsetof(struct dm_name_list, name) + strlen(hc->name) + 1);\n\t\t\tneeded += align_val(sizeof(uint32_t));\n\t\t}\n\t}\n\n\t/*\n\t * Grab our output buffer.\n\t */\n\tnl = orig_nl = get_result_buffer(param, param_size, &len);\n\tif (len < needed || len < sizeof(nl->dev)) {\n\t\tparam->flags |= DM_BUFFER_FULL_FLAG;\n\t\tgoto out;\n\t}\n\tparam->data_size = param->data_start + needed;\n\n\tnl->dev = 0;\t/* Flags no data */\n\n\t/*\n\t * Now loop through filling out the names.\n\t */\n\tfor (i = 0; i < NUM_BUCKETS; i++) {\n\t\tlist_for_each_entry (hc, _name_buckets + i, name_list) {\n\t\t\tif (old_nl)\n\t\t\t\told_nl->next = (uint32_t) ((void *) nl -\n\t\t\t\t\t\t\t (void *) old_nl);\n\t\t\tdisk = dm_disk(hc->md);\n\t\t\tnl->dev = huge_encode_dev(disk_devt(disk));\n\t\t\tnl->next = 0;\n\t\t\tstrcpy(nl->name, hc->name);\n\n\t\t\told_nl = nl;\n\t\t\tevent_nr = align_ptr(nl->name + strlen(hc->name) + 1);\n\t\t\t*event_nr = dm_get_event_nr(hc->md);\n\t\t\tnl = align_ptr(event_nr + 1);\n\t\t}\n\t}\n\t/*\n\t * If mismatch happens, security may be compromised due to buffer\n\t * overflow, so it's better to crash.\n\t */\n\tBUG_ON((char *)nl - (char *)orig_nl != needed);\n\n out:\n\tup_write(&_hash_lock);\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-31916", "cwe_id": "CWE-787" }, { "id": 1215, "func": "Ta3Grammar_FindDFA(grammar *g, int type)\n{\n dfa *d;\n#if 1\n /* Massive speed-up */\n d = &g->g_dfa[type - NT_OFFSET];\n assert(d->d_type == type);\n return d;\n#else\n /* Old, slow version */\n int i;\n\n for (i = g->g_ndfas, d = g->g_dfa; --i >= 0; d++) {\n if (d->d_type == type)\n return d;\n }\n assert(0);\n /* NOTREACHED */\n#endif\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1215, "func": "Ta3Grammar_FindDFA(grammar *g, int type)\n{\n dfa *d;\n#if 1\n /* Massive speed-up */\n d = &g->g_dfa[type - NT_OFFSET];\n assert(d->d_type == type);\n return d;\n#else\n /* Old, slow version */\n int i;\n\n for (i = g->g_ndfas, d = g->g_dfa; --i >= 0; d++) {\n if (d->d_type == type)\n return d;\n }\n abort();\n#endif\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2559, "func": "ParseNameValue(const char * buffer, int bufsize,\n struct NameValueParserData * data)\n{\n\tstruct xmlparser parser;\n\tdata->l_head = NULL;\n\tdata->portListing = NULL;\n\tdata->portListingLength = 0;\n\t/* init xmlparser object */\n\tparser.xmlstart = buffer;\n\tparser.xmlsize = bufsize;\n\tparser.data = data;\n\tparser.starteltfunc = NameValueParserStartElt;\n\tparser.endeltfunc = NameValueParserEndElt;\n\tparser.datafunc = NameValueParserGetData;\n\tparser.attfunc = 0;\n\tparsexml(&parser);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-1000494", "cwe_id": "CWE-119" }, { "id": 2559, "func": "ParseNameValue(const char * buffer, int bufsize,\n struct NameValueParserData * data)\n{\n\tstruct xmlparser parser;\n\tmemset(data, 0, sizeof(struct NameValueParserData));\n\t/* init xmlparser object */\n\tparser.xmlstart = buffer;\n\tparser.xmlsize = bufsize;\n\tparser.data = data;\n\tparser.starteltfunc = NameValueParserStartElt;\n\tparser.endeltfunc = NameValueParserEndElt;\n\tparser.datafunc = NameValueParserGetData;\n\tparser.attfunc = 0;\n\tparsexml(&parser);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-1000494", "cwe_id": "CWE-119" }, { "id": 109, "func": "testHuf (const std::string&)\n{\n try\n {\n\tcout << \"Testing Huffman encoder\" << endl;\n\n\tIMATH_NAMESPACE::Rand48 rand48 (0);\n\n\tconst int N = 1000000;\n\tArray raw (N);\n\n\tfill1 (raw, N, 1, rand48);\t // test various symbol distributions\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\tfill1 (raw, N, 10, rand48);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\tfill1 (raw, N, 100, rand48);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\tfill1 (raw, N, 1000, rand48);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\n\tfill2 (raw, N, 1, rand48);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\tfill2 (raw, N, 10, rand48);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\tfill2 (raw, N, 100, rand48);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\tfill2 (raw, N, 1000, rand48);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\n\tfill3 (raw, N, 0);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\tfill3 (raw, N, 1);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\tfill3 (raw, N, USHRT_MAX - 1);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\tfill3 (raw, N, USHRT_MAX);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\n\tfill4 (raw, USHRT_MAX + 1);\n compressVerify(raw, USHRT_MAX + 1, HUF_COMPRESS_DEK_HASH_FOR_FILL4_USHRT_MAX_PLUS_ONE);\n\tcompressUncompress (raw, USHRT_MAX + 1);\n\tcompressUncompressSubset (raw, USHRT_MAX + 1);\n\tfill4 (raw, N);\n compressVerify(raw, N, HUF_COMPRESS_DEK_HASH_FOR_FILL4_N);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\n\tfill4 (raw, 0);\n\tcompressUncompress (raw, 0);\t// test small input data sets\n\tfill4 (raw, 1);\n\tcompressUncompress (raw, 1);\n\tfill4 (raw, 2);\n\tcompressUncompress (raw, 2);\n\tfill4 (raw, 3);\n\tcompressUncompress (raw, 3);\n\n\tfill5 (raw, N);\t\t\t// test run-length coding of code table\n compressVerify(raw, N, HUF_COMPRESS_DEK_HASH_FOR_FILL5_N);\n\tcompressUncompress (raw, N);\n\tcompressUncompressSubset (raw, N);\n\n\tcout << \"ok\\n\" << endl;\n }\n catch (const std::exception &e)\n {\n\tcerr << \"ERROR -- caught exception: \" << e.what() << endl;\n\tassert (false);\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-20304", "cwe_id": "CWE-190" }, { "id": 109, "func": "testHuf (const std::string&)\n{\n try\n {\n\tcout << \"Testing Huffman encoder\" << endl;\n\n\tIMATH_NAMESPACE::Rand48 rand48 (0);\n\n //\n // FastHufDecoder is used for more than 128 bits, so first test with fewer than 128 bits,\n // then test FastHufDecoder\n //\n for (int pass = 0 ; pass < 2 ; ++pass)\n {\n\n int N = pass==0 ? 12 : 1000000;\n Array raw (N);\n\n fill1 (raw, N, 1, rand48);\t // test various symbol distributions\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n fill1 (raw, N, 10, rand48);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n fill1 (raw, N, 100, rand48);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n fill1 (raw, N, 1000, rand48);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n\n fill2 (raw, N, 1, rand48);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n fill2 (raw, N, 10, rand48);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n fill2 (raw, N, 100, rand48);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n fill2 (raw, N, 1000, rand48);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n\n fill3 (raw, N, 0);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n fill3 (raw, N, 1);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n fill3 (raw, N, USHRT_MAX - 1);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n fill3 (raw, N, USHRT_MAX);\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n\n if (pass==1)\n {\n fill4 (raw, USHRT_MAX + 1);\n compressVerify(raw, USHRT_MAX + 1, HUF_COMPRESS_DEK_HASH_FOR_FILL4_USHRT_MAX_PLUS_ONE);\n\n compressUncompress (raw, USHRT_MAX + 1);\n compressUncompressSubset (raw, USHRT_MAX + 1);\n fill4 (raw, N);\n compressVerify(raw, N, HUF_COMPRESS_DEK_HASH_FOR_FILL4_N);\n }\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n\n fill4 (raw, 0);\n compressUncompress (raw, 0);\t// test small input data sets\n fill4 (raw, 1);\n compressUncompress (raw, 1);\n fill4 (raw, 2);\n compressUncompress (raw, 2);\n fill4 (raw, 3);\n compressUncompress (raw, 3);\n\n fill5 (raw, N);\t\t\t// test run-length coding of code table\n if (pass==1)\n {\n compressVerify(raw, N, HUF_COMPRESS_DEK_HASH_FOR_FILL5_N);\n }\n compressUncompress (raw, N);\n compressUncompressSubset (raw, N);\n\n }\n\n\tcout << \"ok\\n\" << endl;\n }\n catch (const std::exception &e)\n {\n\tcerr << \"ERROR -- caught exception: \" << e.what() << endl;\n\tassert (false);\n }\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-20304", "cwe_id": "CWE-190" }, { "id": 2645, "func": "TfLiteStatus PopulatePrecomputedZPTimesWeightsWithBias(TfLiteContext* context,\n OpData* op_data,\n TfLiteNode* node) {\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n const TfLiteTensor* output_state =\n GetVariableInput(context, node, kOutputStateTensor);\n TF_LITE_ENSURE(context, output_state != nullptr);\n\n const int32_t input_zero_point = -input->params.zero_point;\n const int32_t output_state_zero_point = -output_state->params.zero_point;\n\n const TfLiteTensor* input_to_input_weights =\n GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);\n const TfLiteTensor* input_to_forget_weights =\n GetInput(context, node, kInputToForgetWeightsTensor);\n const TfLiteTensor* input_to_cell_weights =\n GetInput(context, node, kInputToCellWeightsTensor);\n const TfLiteTensor* input_to_output_weights =\n GetInput(context, node, kInputToOutputWeightsTensor);\n\n const TfLiteTensor* recurrent_to_input_weights =\n GetOptionalInputTensor(context, node, kRecurrentToInputWeightsTensor);\n const TfLiteTensor* recurrent_to_forget_weights =\n GetInput(context, node, kRecurrentToForgetWeightsTensor);\n const TfLiteTensor* recurrent_to_cell_weights =\n GetInput(context, node, kRecurrentToCellWeightsTensor);\n const TfLiteTensor* recurrent_to_output_weights =\n GetInput(context, node, kRecurrentToOutputWeightsTensor);\n\n const TfLiteTensor* projection_weights =\n GetOptionalInputTensor(context, node, kProjectionWeightsTensor);\n const TfLiteTensor* projection_bias =\n GetOptionalInputTensor(context, node, kProjectionBiasTensor);\n\n lstm_eval::IntegerLstmParameter* integer_lstm_params =\n &op_data->integer_lstm_param;\n\n const TfLiteTensor* intermediate =\n &context->tensors[node->intermediates->data[4]];\n const auto* params =\n static_cast(intermediate->quantization.params);\n const int32_t hidden_zp = params->zero_point->data[0];\n\n // Get bias and perform zero point calculation.\n // When there is layer normalization, the gate bias does not apply to matmul\n // directly:\n // y = ln(w * x + w * r + w * c) + b.\n const bool is_layer_norm = op_data->use_layer_norm;\n\n // Forget gate.\n const TfLiteTensor* forget_gate_bias =\n is_layer_norm ? nullptr : GetInput(context, node, kForgetGateBiasTensor);\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, input_zero_point, input_to_forget_weights, forget_gate_bias,\n &(integer_lstm_params->input_to_forget_effective_bias)));\n\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, output_state_zero_point, recurrent_to_forget_weights,\n nullptr, &(integer_lstm_params->recurrent_to_forget_effective_bias)));\n\n // Modulation gate.\n const TfLiteTensor* cell_gate_bias =\n is_layer_norm ? nullptr : GetInput(context, node, kCellGateBiasTensor);\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, input_zero_point, input_to_cell_weights, cell_gate_bias,\n &(integer_lstm_params->input_to_cell_effective_bias)));\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, output_state_zero_point, recurrent_to_cell_weights, nullptr,\n &(integer_lstm_params->recurrent_to_cell_effective_bias)));\n\n // Output gate.\n const TfLiteTensor* output_gate_bias =\n is_layer_norm ? nullptr : GetInput(context, node, kOutputGateBiasTensor);\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, input_zero_point, input_to_output_weights, output_gate_bias,\n &(integer_lstm_params->input_to_output_effective_bias)));\n\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, output_state_zero_point, recurrent_to_output_weights,\n nullptr, &(integer_lstm_params->recurrent_to_output_effective_bias)));\n\n // Input gate. The calculation is only meaningful for non-cifg case.\n const TfLiteTensor* input_gate_bias =\n is_layer_norm ? nullptr : GetInput(context, node, kInputGateBiasTensor);\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, input_zero_point, input_to_input_weights, input_gate_bias,\n &(integer_lstm_params->input_to_input_effective_bias)));\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, output_state_zero_point, recurrent_to_input_weights, nullptr,\n &(integer_lstm_params->recurrent_to_input_effective_bias)));\n\n // Projection bias. The calculation is only meaningful for with projection.\n TF_LITE_ENSURE_OK(context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, hidden_zp, projection_weights, projection_bias,\n &(integer_lstm_params->projection_effective_bias)));\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2645, "func": "TfLiteStatus PopulatePrecomputedZPTimesWeightsWithBias(TfLiteContext* context,\n OpData* op_data,\n TfLiteNode* node) {\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n const TfLiteTensor* output_state =\n GetVariableInput(context, node, kOutputStateTensor);\n TF_LITE_ENSURE(context, output_state != nullptr);\n\n const int32_t input_zero_point = -input->params.zero_point;\n const int32_t output_state_zero_point = -output_state->params.zero_point;\n\n const TfLiteTensor* input_to_input_weights =\n GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);\n const TfLiteTensor* input_to_forget_weights;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputToForgetWeightsTensor,\n &input_to_forget_weights));\n const TfLiteTensor* input_to_cell_weights;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputToCellWeightsTensor,\n &input_to_cell_weights));\n const TfLiteTensor* input_to_output_weights;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kInputToOutputWeightsTensor,\n &input_to_output_weights));\n\n const TfLiteTensor* recurrent_to_input_weights =\n GetOptionalInputTensor(context, node, kRecurrentToInputWeightsTensor);\n const TfLiteTensor* recurrent_to_forget_weights;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kRecurrentToForgetWeightsTensor,\n &recurrent_to_forget_weights));\n const TfLiteTensor* recurrent_to_cell_weights;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kRecurrentToCellWeightsTensor,\n &recurrent_to_cell_weights));\n const TfLiteTensor* recurrent_to_output_weights;\n TF_LITE_ENSURE_OK(context,\n GetInputSafe(context, node, kRecurrentToOutputWeightsTensor,\n &recurrent_to_output_weights));\n\n const TfLiteTensor* projection_weights =\n GetOptionalInputTensor(context, node, kProjectionWeightsTensor);\n const TfLiteTensor* projection_bias =\n GetOptionalInputTensor(context, node, kProjectionBiasTensor);\n\n lstm_eval::IntegerLstmParameter* integer_lstm_params =\n &op_data->integer_lstm_param;\n\n const TfLiteTensor* intermediate =\n &context->tensors[node->intermediates->data[4]];\n const auto* params =\n static_cast(intermediate->quantization.params);\n const int32_t hidden_zp = params->zero_point->data[0];\n\n // Get bias and perform zero point calculation.\n // When there is layer normalization, the gate bias does not apply to matmul\n // directly:\n // y = ln(w * x + w * r + w * c) + b.\n const bool is_layer_norm = op_data->use_layer_norm;\n\n // Forget gate.\n const TfLiteTensor* forget_gate_bias =\n is_layer_norm ? nullptr : GetInput(context, node, kForgetGateBiasTensor);\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, input_zero_point, input_to_forget_weights, forget_gate_bias,\n &(integer_lstm_params->input_to_forget_effective_bias)));\n\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, output_state_zero_point, recurrent_to_forget_weights,\n nullptr, &(integer_lstm_params->recurrent_to_forget_effective_bias)));\n\n // Modulation gate.\n const TfLiteTensor* cell_gate_bias =\n is_layer_norm ? nullptr : GetInput(context, node, kCellGateBiasTensor);\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, input_zero_point, input_to_cell_weights, cell_gate_bias,\n &(integer_lstm_params->input_to_cell_effective_bias)));\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, output_state_zero_point, recurrent_to_cell_weights, nullptr,\n &(integer_lstm_params->recurrent_to_cell_effective_bias)));\n\n // Output gate.\n const TfLiteTensor* output_gate_bias =\n is_layer_norm ? nullptr : GetInput(context, node, kOutputGateBiasTensor);\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, input_zero_point, input_to_output_weights, output_gate_bias,\n &(integer_lstm_params->input_to_output_effective_bias)));\n\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, output_state_zero_point, recurrent_to_output_weights,\n nullptr, &(integer_lstm_params->recurrent_to_output_effective_bias)));\n\n // Input gate. The calculation is only meaningful for non-cifg case.\n const TfLiteTensor* input_gate_bias =\n is_layer_norm ? nullptr : GetInput(context, node, kInputGateBiasTensor);\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, input_zero_point, input_to_input_weights, input_gate_bias,\n &(integer_lstm_params->input_to_input_effective_bias)));\n TF_LITE_ENSURE_OK(\n context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, output_state_zero_point, recurrent_to_input_weights, nullptr,\n &(integer_lstm_params->recurrent_to_input_effective_bias)));\n\n // Projection bias. The calculation is only meaningful for with projection.\n TF_LITE_ENSURE_OK(context,\n PrecomputeZeroPointTimesWeightWithBias(\n context, hidden_zp, projection_weights, projection_bias,\n &(integer_lstm_params->projection_effective_bias)));\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 108, "func": "void *ndpGetOption(uint8_t *options, size_t length, uint8_t type)\n{\n size_t i;\n NdpOption *option;\n\n //Point to the very first option of the NDP message\n i = 0;\n\n //Parse options\n while((i + sizeof(NdpOption)) <= length)\n {\n //Point to the current option\n option = (NdpOption *) (options + i);\n\n //Nodes must silently discard an NDP message that contains\n //an option with length zero\n if(option->length == 0)\n break;\n //Check option length\n if((i + option->length * 8) > length)\n break;\n\n //Current option type matches the specified one?\n if(option->type == type || type == NDP_OPT_ANY)\n return option;\n\n //Jump to next the next option\n i += option->length * 8;\n }\n\n //Specified option type not found\n return NULL;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 108, "func": "void *ndpGetOption(uint8_t *options, size_t length, uint8_t type)\n{\n size_t i;\n NdpOption *option;\n\n //Point to the very first option of the NDP message\n i = 0;\n\n //Parse options\n while((i + sizeof(NdpOption)) <= length)\n {\n //Point to the current option\n option = (NdpOption *) (options + i);\n\n //Nodes must silently discard an NDP message that contains\n //an option with length zero\n if(option->length == 0)\n break;\n //Check option length\n if((i + option->length * 8) > length)\n break;\n\n //Current option type matches the specified one?\n if(option->type == type || type == NDP_OPT_ANY)\n return option;\n\n //Jump to the next option\n i += option->length * 8;\n }\n\n //Specified option type not found\n return NULL;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-26788", "cwe_id": "CWE-20" }, { "id": 2953, "func": "void * pvPortMalloc( size_t xWantedSize )\r\n{\r\n BlockLink_t * pxBlock, * pxPreviousBlock, * pxNewBlockLink;\r\n static BaseType_t xHeapHasBeenInitialised = pdFALSE;\r\n void * pvReturn = NULL;\r\n\r\n vTaskSuspendAll();\r\n {\r\n /* If this is the first call to malloc then the heap will require\r\n * initialisation to setup the list of free blocks. */\r\n if( xHeapHasBeenInitialised == pdFALSE )\r\n {\r\n prvHeapInit();\r\n xHeapHasBeenInitialised = pdTRUE;\r\n }\r\n\r\n /* The wanted size is increased so it can contain a BlockLink_t\r\n * structure in addition to the requested amount of bytes. */\r\n if( xWantedSize > 0 )\r\n {\r\n xWantedSize += heapSTRUCT_SIZE;\r\n\r\n /* Ensure that blocks are always aligned to the required number of bytes. */\r\n if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0 )\r\n {\r\n /* Byte alignment required. */\r\n xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r\n }\r\n }\r\n\r\n if( ( xWantedSize > 0 ) && ( xWantedSize < configADJUSTED_HEAP_SIZE ) )\r\n {\r\n /* Blocks are stored in byte order - traverse the list from the start\r\n * (smallest) block until one of adequate size is found. */\r\n pxPreviousBlock = &xStart;\r\n pxBlock = xStart.pxNextFreeBlock;\r\n\r\n while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )\r\n {\r\n pxPreviousBlock = pxBlock;\r\n pxBlock = pxBlock->pxNextFreeBlock;\r\n }\r\n\r\n /* If we found the end marker then a block of adequate size was not found. */\r\n if( pxBlock != &xEnd )\r\n {\r\n /* Return the memory space - jumping over the BlockLink_t structure\r\n * at its start. */\r\n pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE );\r\n\r\n /* This block is being returned for use so must be taken out of the\r\n * list of free blocks. */\r\n pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;\r\n\r\n /* If the block is larger than required it can be split into two. */\r\n if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )\r\n {\r\n /* This block is to be split into two. Create a new block\r\n * following the number of bytes requested. The void cast is\r\n * used to prevent byte alignment warnings from the compiler. */\r\n pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );\r\n\r\n /* Calculate the sizes of two blocks split from the single\r\n * block. */\r\n pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;\r\n pxBlock->xBlockSize = xWantedSize;\r\n\r\n /* Insert the new block into the list of free blocks. */\r\n prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );\r\n }\r\n\r\n xFreeBytesRemaining -= pxBlock->xBlockSize;\r\n }\r\n }\r\n\r\n traceMALLOC( pvReturn, xWantedSize );\r\n }\r\n ( void ) xTaskResumeAll();\r\n\r\n #if ( configUSE_MALLOC_FAILED_HOOK == 1 )\r\n {\r\n if( pvReturn == NULL )\r\n {\r\n extern void vApplicationMallocFailedHook( void );\r\n vApplicationMallocFailedHook();\r\n }\r\n }\r\n #endif\r\n\r\n return pvReturn;\r\n}\r", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-32020", "cwe_id": "CWE-119" }, { "id": 2953, "func": "void * pvPortMalloc( size_t xWantedSize )\r\n{\r\n BlockLink_t * pxBlock, * pxPreviousBlock, * pxNewBlockLink;\r\n static BaseType_t xHeapHasBeenInitialised = pdFALSE;\r\n void * pvReturn = NULL;\r\n\r\n vTaskSuspendAll();\r\n {\r\n /* If this is the first call to malloc then the heap will require\r\n * initialisation to setup the list of free blocks. */\r\n if( xHeapHasBeenInitialised == pdFALSE )\r\n {\r\n prvHeapInit();\r\n xHeapHasBeenInitialised = pdTRUE;\r\n }\r\n\r\n /* The wanted size must be increased so it can contain a BlockLink_t\r\n * structure in addition to the requested amount of bytes. */\r\n if( ( xWantedSize > 0 ) && \r\n ( ( xWantedSize + heapSTRUCT_SIZE ) > xWantedSize ) ) /* Overflow check */\r\n {\r\n xWantedSize += heapSTRUCT_SIZE;\r\n\r\n /* Byte alignment required. Check for overflow. */\r\n if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ) \r\n > xWantedSize )\r\n {\r\n xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r\n configASSERT( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) == 0 );\r\n }\r\n else\r\n {\r\n xWantedSize = 0;\r\n } \r\n }\r\n else \r\n {\r\n xWantedSize = 0; \r\n }\r\n\r\n\r\n if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )\r\n {\r\n /* Blocks are stored in byte order - traverse the list from the start\r\n * (smallest) block until one of adequate size is found. */\r\n pxPreviousBlock = &xStart;\r\n pxBlock = xStart.pxNextFreeBlock;\r\n\r\n while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )\r\n {\r\n pxPreviousBlock = pxBlock;\r\n pxBlock = pxBlock->pxNextFreeBlock;\r\n }\r\n\r\n /* If we found the end marker then a block of adequate size was not found. */\r\n if( pxBlock != &xEnd )\r\n {\r\n /* Return the memory space - jumping over the BlockLink_t structure\r\n * at its start. */\r\n pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE );\r\n\r\n /* This block is being returned for use so must be taken out of the\r\n * list of free blocks. */\r\n pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;\r\n\r\n /* If the block is larger than required it can be split into two. */\r\n if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )\r\n {\r\n /* This block is to be split into two. Create a new block\r\n * following the number of bytes requested. The void cast is\r\n * used to prevent byte alignment warnings from the compiler. */\r\n pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );\r\n\r\n /* Calculate the sizes of two blocks split from the single\r\n * block. */\r\n pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;\r\n pxBlock->xBlockSize = xWantedSize;\r\n\r\n /* Insert the new block into the list of free blocks. */\r\n prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );\r\n }\r\n\r\n xFreeBytesRemaining -= pxBlock->xBlockSize;\r\n }\r\n }\r\n\r\n traceMALLOC( pvReturn, xWantedSize );\r\n }\r\n ( void ) xTaskResumeAll();\r\n\r\n #if ( configUSE_MALLOC_FAILED_HOOK == 1 )\r\n {\r\n if( pvReturn == NULL )\r\n {\r\n extern void vApplicationMallocFailedHook( void );\r\n vApplicationMallocFailedHook();\r\n }\r\n }\r\n #endif\r\n\r\n return pvReturn;\r\n}\r", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-32020", "cwe_id": "CWE-119" }, { "id": 1571, "func": "search_make_new(const struct search_state *const state, int n, const char *const base_name) {\n\tconst size_t base_len = strlen(base_name);\n\tconst char need_to_append_dot = base_name[base_len - 1] == '.' ? 0 : 1;\n\tstruct search_domain *dom;\n\n\tfor (dom = state->head; dom; dom = dom->next) {\n\t\tif (!n--) {\n\t\t\t/* this is the postfix we want */\n\t\t\t/* the actual postfix string is kept at the end of the structure */\n\t\t\tconst u8 *const postfix = ((u8 *) dom) + sizeof(struct search_domain);\n\t\t\tconst int postfix_len = dom->len;\n\t\t\tchar *const newname = (char *) mm_malloc(base_len + need_to_append_dot + postfix_len + 1);\n\t\t\tif (!newname) return NULL;\n\t\t\tmemcpy(newname, base_name, base_len);\n\t\t\tif (need_to_append_dot) newname[base_len] = '.';\n\t\t\tmemcpy(newname + base_len + need_to_append_dot, postfix, postfix_len);\n\t\t\tnewname[base_len + need_to_append_dot + postfix_len] = 0;\n\t\t\treturn newname;\n\t\t}\n\t}\n\n\t/* we ran off the end of the list and still didn't find the requested string */\n\tEVUTIL_ASSERT(0);\n\treturn NULL; /* unreachable; stops warnings in some compilers. */\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-10197", "cwe_id": "CWE-125" }, { "id": 1571, "func": "search_make_new(const struct search_state *const state, int n, const char *const base_name) {\n\tconst size_t base_len = strlen(base_name);\n\tchar need_to_append_dot;\n\tstruct search_domain *dom;\n\n\tif (!base_len) return NULL;\n\tneed_to_append_dot = base_name[base_len - 1] == '.' ? 0 : 1;\n\n\tfor (dom = state->head; dom; dom = dom->next) {\n\t\tif (!n--) {\n\t\t\t/* this is the postfix we want */\n\t\t\t/* the actual postfix string is kept at the end of the structure */\n\t\t\tconst u8 *const postfix = ((u8 *) dom) + sizeof(struct search_domain);\n\t\t\tconst int postfix_len = dom->len;\n\t\t\tchar *const newname = (char *) mm_malloc(base_len + need_to_append_dot + postfix_len + 1);\n\t\t\tif (!newname) return NULL;\n\t\t\tmemcpy(newname, base_name, base_len);\n\t\t\tif (need_to_append_dot) newname[base_len] = '.';\n\t\t\tmemcpy(newname + base_len + need_to_append_dot, postfix, postfix_len);\n\t\t\tnewname[base_len + need_to_append_dot + postfix_len] = 0;\n\t\t\treturn newname;\n\t\t}\n\t}\n\n\t/* we ran off the end of the list and still didn't find the requested string */\n\tEVUTIL_ASSERT(0);\n\treturn NULL; /* unreachable; stops warnings in some compilers. */\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-10197", "cwe_id": "CWE-125" }, { "id": 2517, "func": "static int __get_data_block(struct inode *inode, sector_t iblock,\n\t\t\tstruct buffer_head *bh, int create, int flag,\n\t\t\tpgoff_t *next_pgofs)\n{\n\tstruct f2fs_map_blocks map;\n\tint err;\n\n\tmap.m_lblk = iblock;\n\tmap.m_len = bh->b_size >> inode->i_blkbits;\n\tmap.m_next_pgofs = next_pgofs;\n\n\terr = f2fs_map_blocks(inode, &map, create, flag);\n\tif (!err) {\n\t\tmap_bh(bh, inode->i_sb, map.m_pblk);\n\t\tbh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags;\n\t\tbh->b_size = map.m_len << inode->i_blkbits;\n\t}\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-18257", "cwe_id": "CWE-190" }, { "id": 2517, "func": "static int __get_data_block(struct inode *inode, sector_t iblock,\n\t\t\tstruct buffer_head *bh, int create, int flag,\n\t\t\tpgoff_t *next_pgofs)\n{\n\tstruct f2fs_map_blocks map;\n\tint err;\n\n\tmap.m_lblk = iblock;\n\tmap.m_len = bh->b_size >> inode->i_blkbits;\n\tmap.m_next_pgofs = next_pgofs;\n\n\terr = f2fs_map_blocks(inode, &map, create, flag);\n\tif (!err) {\n\t\tmap_bh(bh, inode->i_sb, map.m_pblk);\n\t\tbh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags;\n\t\tbh->b_size = (u64)map.m_len << inode->i_blkbits;\n\t}\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-18257", "cwe_id": "CWE-190" }, { "id": 1540, "func": "int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)\n{\n\tstruct snd_ctl_elem_id id;\n\tunsigned int idx;\n\tint err = -EINVAL;\n\n\tif (! kcontrol)\n\t\treturn err;\n\tif (snd_BUG_ON(!card || !kcontrol->info))\n\t\tgoto error;\n\tid = kcontrol->id;\n\tdown_write(&card->controls_rwsem);\n\tif (snd_ctl_find_id(card, &id)) {\n\t\tup_write(&card->controls_rwsem);\n\t\tdev_err(card->dev, \"control %i:%i:%i:%s:%i is already present\\n\",\n\t\t\t\t\tid.iface,\n\t\t\t\t\tid.device,\n\t\t\t\t\tid.subdevice,\n\t\t\t\t\tid.name,\n\t\t\t\t\tid.index);\n\t\terr = -EBUSY;\n\t\tgoto error;\n\t}\n\tif (snd_ctl_find_hole(card, kcontrol->count) < 0) {\n\t\tup_write(&card->controls_rwsem);\n\t\terr = -ENOMEM;\n\t\tgoto error;\n\t}\n\tlist_add_tail(&kcontrol->list, &card->controls);\n\tcard->controls_count += kcontrol->count;\n\tkcontrol->id.numid = card->last_numid + 1;\n\tcard->last_numid += kcontrol->count;\n\tup_write(&card->controls_rwsem);\n\tfor (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++)\n\t\tsnd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);\n\treturn 0;\n\n error:\n\tsnd_ctl_free_one(kcontrol);\n\treturn err;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2014-4653", "cwe_id": "CWE-416" }, { "id": 1540, "func": "int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)\n{\n\tstruct snd_ctl_elem_id id;\n\tunsigned int idx;\n\tunsigned int count;\n\tint err = -EINVAL;\n\n\tif (! kcontrol)\n\t\treturn err;\n\tif (snd_BUG_ON(!card || !kcontrol->info))\n\t\tgoto error;\n\tid = kcontrol->id;\n\tdown_write(&card->controls_rwsem);\n\tif (snd_ctl_find_id(card, &id)) {\n\t\tup_write(&card->controls_rwsem);\n\t\tdev_err(card->dev, \"control %i:%i:%i:%s:%i is already present\\n\",\n\t\t\t\t\tid.iface,\n\t\t\t\t\tid.device,\n\t\t\t\t\tid.subdevice,\n\t\t\t\t\tid.name,\n\t\t\t\t\tid.index);\n\t\terr = -EBUSY;\n\t\tgoto error;\n\t}\n\tif (snd_ctl_find_hole(card, kcontrol->count) < 0) {\n\t\tup_write(&card->controls_rwsem);\n\t\terr = -ENOMEM;\n\t\tgoto error;\n\t}\n\tlist_add_tail(&kcontrol->list, &card->controls);\n\tcard->controls_count += kcontrol->count;\n\tkcontrol->id.numid = card->last_numid + 1;\n\tcard->last_numid += kcontrol->count;\n\tcount = kcontrol->count;\n\tup_write(&card->controls_rwsem);\n\tfor (idx = 0; idx < count; idx++, id.index++, id.numid++)\n\t\tsnd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);\n\treturn 0;\n\n error:\n\tsnd_ctl_free_one(kcontrol);\n\treturn err;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2014-4653", "cwe_id": "CWE-416" }, { "id": 1352, "func": "void jslTokenAsString(int token, char *str, size_t len) {\n // see JS_ERROR_TOKEN_BUF_SIZE\n if (token>32 && token<128) {\n assert(len>=4);\n str[0] = '\\'';\n str[1] = (char)token;\n str[2] = '\\'';\n str[3] = 0;\n return;\n }\n\n switch (token) {\n case LEX_EOF : strncpy(str, \"EOF\", len); return;\n case LEX_ID : strncpy(str, \"ID\", len); return;\n case LEX_INT : strncpy(str, \"INT\", len); return;\n case LEX_FLOAT : strncpy(str, \"FLOAT\", len); return;\n case LEX_STR : strncpy(str, \"STRING\", len); return;\n case LEX_UNFINISHED_STR : strncpy(str, \"UNFINISHED STRING\", len); return;\n case LEX_TEMPLATE_LITERAL : strncpy(str, \"TEMPLATE LITERAL\", len); return;\n case LEX_UNFINISHED_TEMPLATE_LITERAL : strncpy(str, \"UNFINISHED TEMPLATE LITERAL\", len); return;\n case LEX_REGEX : strncpy(str, \"REGEX\", len); return;\n case LEX_UNFINISHED_REGEX : strncpy(str, \"UNFINISHED REGEX\", len); return;\n case LEX_UNFINISHED_COMMENT : strncpy(str, \"UNFINISHED COMMENT\", len); return;\n }\n if (token>=_LEX_OPERATOR_START && token<_LEX_R_LIST_END) {\n const char tokenNames[] =\n /* LEX_EQUAL : */ \"==\\0\"\n /* LEX_TYPEEQUAL : */ \"===\\0\"\n /* LEX_NEQUAL : */ \"!=\\0\"\n /* LEX_NTYPEEQUAL : */ \"!==\\0\"\n /* LEX_LEQUAL : */ \"<=\\0\"\n /* LEX_LSHIFT : */ \"<<\\0\"\n /* LEX_LSHIFTEQUAL : */ \"<<=\\0\"\n /* LEX_GEQUAL : */ \">=\\0\"\n /* LEX_RSHIFT : */ \">>\\0\"\n /* LEX_RSHIFTUNSIGNED */ \">>>\\0\"\n /* LEX_RSHIFTEQUAL : */ \">>=\\0\"\n /* LEX_RSHIFTUNSIGNEDEQUAL */ \">>>=\\0\"\n /* LEX_PLUSEQUAL : */ \"+=\\0\"\n /* LEX_MINUSEQUAL : */ \"-=\\0\"\n /* LEX_PLUSPLUS : */ \"++\\0\"\n /* LEX_MINUSMINUS */ \"--\\0\"\n /* LEX_MULEQUAL : */ \"*=\\0\"\n /* LEX_DIVEQUAL : */ \"/=\\0\"\n /* LEX_MODEQUAL : */ \"%=\\0\"\n /* LEX_ANDEQUAL : */ \"&=\\0\"\n /* LEX_ANDAND : */ \"&&\\0\"\n /* LEX_OREQUAL : */ \"|=\\0\"\n /* LEX_OROR : */ \"||\\0\"\n /* LEX_XOREQUAL : */ \"^=\\0\"\n /* LEX_ARROW_FUNCTION */ \"=>\\0\"\n\n // reserved words\n /*LEX_R_IF : */ \"if\\0\"\n /*LEX_R_ELSE : */ \"else\\0\"\n /*LEX_R_DO : */ \"do\\0\"\n /*LEX_R_WHILE : */ \"while\\0\"\n /*LEX_R_FOR : */ \"for\\0\"\n /*LEX_R_BREAK : */ \"return\\0\"\n /*LEX_R_CONTINUE */ \"continue\\0\"\n /*LEX_R_FUNCTION */ \"function\\0\"\n /*LEX_R_RETURN */ \"return\\0\"\n /*LEX_R_VAR : */ \"var\\0\"\n /*LEX_R_LET : */ \"let\\0\"\n /*LEX_R_CONST : */ \"const\\0\"\n /*LEX_R_THIS : */ \"this\\0\"\n /*LEX_R_THROW : */ \"throw\\0\"\n /*LEX_R_TRY : */ \"try\\0\"\n /*LEX_R_CATCH : */ \"catch\\0\"\n /*LEX_R_FINALLY : */ \"finally\\0\"\n /*LEX_R_TRUE : */ \"true\\0\"\n /*LEX_R_FALSE : */ \"false\\0\"\n /*LEX_R_NULL : */ \"null\\0\"\n /*LEX_R_UNDEFINED */ \"undefined\\0\"\n /*LEX_R_NEW : */ \"new\\0\"\n /*LEX_R_IN : */ \"in\\0\"\n /*LEX_R_INSTANCEOF */ \"instanceof\\0\"\n /*LEX_R_SWITCH */ \"switch\\0\"\n /*LEX_R_CASE */ \"case\\0\"\n /*LEX_R_DEFAULT */ \"default\\0\"\n /*LEX_R_DELETE */ \"delete\\0\"\n /*LEX_R_TYPEOF : */ \"typeof\\0\"\n /*LEX_R_VOID : */ \"void\\0\"\n /*LEX_R_DEBUGGER : */ \"debugger\\0\"\n /*LEX_R_CLASS : */ \"class\\0\"\n /*LEX_R_EXTENDS : */ \"extends\\0\"\n /*LEX_R_SUPER : */ \"super\\0\"\n /*LEX_R_STATIC : */ \"static\\0\"\n ;\n unsigned int p = 0;\n int n = token-_LEX_OPERATOR_START;\n while (n>0 && p=10);\n espruino_snprintf(str, len, \"?[%d]\", token);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-11593", "cwe_id": "CWE-787" }, { "id": 1352, "func": "void jslTokenAsString(int token, char *str, size_t len) {\n assert(len>28); // size of largest string\n // see JS_ERROR_TOKEN_BUF_SIZE\n if (token>32 && token<128) {\n assert(len>=4);\n str[0] = '\\'';\n str[1] = (char)token;\n str[2] = '\\'';\n str[3] = 0;\n return;\n }\n\n\n switch (token) {\n case LEX_EOF : strcpy(str, \"EOF\"); return;\n case LEX_ID : strcpy(str, \"ID\"); return;\n case LEX_INT : strcpy(str, \"INT\"); return;\n case LEX_FLOAT : strcpy(str, \"FLOAT\"); return;\n case LEX_STR : strcpy(str, \"STRING\"); return;\n case LEX_UNFINISHED_STR : strcpy(str, \"UNFINISHED STRING\"); return;\n case LEX_TEMPLATE_LITERAL : strcpy(str, \"TEMPLATE LITERAL\"); return;\n case LEX_UNFINISHED_TEMPLATE_LITERAL : strcpy(str, \"UNFINISHED TEMPLATE LITERAL\"); return;\n case LEX_REGEX : strcpy(str, \"REGEX\"); return;\n case LEX_UNFINISHED_REGEX : strcpy(str, \"UNFINISHED REGEX\"); return;\n case LEX_UNFINISHED_COMMENT : strcpy(str, \"UNFINISHED COMMENT\"); return;\n }\n if (token>=_LEX_OPERATOR_START && token<_LEX_R_LIST_END) {\n const char tokenNames[] =\n /* LEX_EQUAL : */ \"==\\0\"\n /* LEX_TYPEEQUAL : */ \"===\\0\"\n /* LEX_NEQUAL : */ \"!=\\0\"\n /* LEX_NTYPEEQUAL : */ \"!==\\0\"\n /* LEX_LEQUAL : */ \"<=\\0\"\n /* LEX_LSHIFT : */ \"<<\\0\"\n /* LEX_LSHIFTEQUAL : */ \"<<=\\0\"\n /* LEX_GEQUAL : */ \">=\\0\"\n /* LEX_RSHIFT : */ \">>\\0\"\n /* LEX_RSHIFTUNSIGNED */ \">>>\\0\"\n /* LEX_RSHIFTEQUAL : */ \">>=\\0\"\n /* LEX_RSHIFTUNSIGNEDEQUAL */ \">>>=\\0\"\n /* LEX_PLUSEQUAL : */ \"+=\\0\"\n /* LEX_MINUSEQUAL : */ \"-=\\0\"\n /* LEX_PLUSPLUS : */ \"++\\0\"\n /* LEX_MINUSMINUS */ \"--\\0\"\n /* LEX_MULEQUAL : */ \"*=\\0\"\n /* LEX_DIVEQUAL : */ \"/=\\0\"\n /* LEX_MODEQUAL : */ \"%=\\0\"\n /* LEX_ANDEQUAL : */ \"&=\\0\"\n /* LEX_ANDAND : */ \"&&\\0\"\n /* LEX_OREQUAL : */ \"|=\\0\"\n /* LEX_OROR : */ \"||\\0\"\n /* LEX_XOREQUAL : */ \"^=\\0\"\n /* LEX_ARROW_FUNCTION */ \"=>\\0\"\n\n // reserved words\n /*LEX_R_IF : */ \"if\\0\"\n /*LEX_R_ELSE : */ \"else\\0\"\n /*LEX_R_DO : */ \"do\\0\"\n /*LEX_R_WHILE : */ \"while\\0\"\n /*LEX_R_FOR : */ \"for\\0\"\n /*LEX_R_BREAK : */ \"return\\0\"\n /*LEX_R_CONTINUE */ \"continue\\0\"\n /*LEX_R_FUNCTION */ \"function\\0\"\n /*LEX_R_RETURN */ \"return\\0\"\n /*LEX_R_VAR : */ \"var\\0\"\n /*LEX_R_LET : */ \"let\\0\"\n /*LEX_R_CONST : */ \"const\\0\"\n /*LEX_R_THIS : */ \"this\\0\"\n /*LEX_R_THROW : */ \"throw\\0\"\n /*LEX_R_TRY : */ \"try\\0\"\n /*LEX_R_CATCH : */ \"catch\\0\"\n /*LEX_R_FINALLY : */ \"finally\\0\"\n /*LEX_R_TRUE : */ \"true\\0\"\n /*LEX_R_FALSE : */ \"false\\0\"\n /*LEX_R_NULL : */ \"null\\0\"\n /*LEX_R_UNDEFINED */ \"undefined\\0\"\n /*LEX_R_NEW : */ \"new\\0\"\n /*LEX_R_IN : */ \"in\\0\"\n /*LEX_R_INSTANCEOF */ \"instanceof\\0\"\n /*LEX_R_SWITCH */ \"switch\\0\"\n /*LEX_R_CASE */ \"case\\0\"\n /*LEX_R_DEFAULT */ \"default\\0\"\n /*LEX_R_DELETE */ \"delete\\0\"\n /*LEX_R_TYPEOF : */ \"typeof\\0\"\n /*LEX_R_VOID : */ \"void\\0\"\n /*LEX_R_DEBUGGER : */ \"debugger\\0\"\n /*LEX_R_CLASS : */ \"class\\0\"\n /*LEX_R_EXTENDS : */ \"extends\\0\"\n /*LEX_R_SUPER : */ \"super\\0\"\n /*LEX_R_STATIC : */ \"static\\0\"\n ;\n unsigned int p = 0;\n int n = token-_LEX_OPERATOR_START;\n while (n>0 && pdev;\n\tif (netif_carrier_ok(dev)) {\n\t\trtnl_lock();\n\t\tnetif_carrier_off(dev); /* discard queued packets */\n\t\tif (netif_running(dev))\n\t\t\txenvif_down(vif);\n\t\trtnl_unlock();\n\t\txenvif_put(vif);\n\t}\n\n\tatomic_dec(&vif->refcnt);\n\twait_event(vif->waiting_to_free, atomic_read(&vif->refcnt) == 0);\n\n\tdel_timer_sync(&vif->credit_timeout);\n\n\tif (vif->irq)\n\t\tunbind_from_irqhandler(vif->irq, vif);\n\n\tunregister_netdev(vif->dev);\n\n\txen_netbk_unmap_frontend_rings(vif);\n\n\tfree_netdev(vif->dev);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-0216", "cwe_id": "CWE-20" }, { "id": 2164, "func": "void xenvif_disconnect(struct xenvif *vif)\n{\n\tif (netif_carrier_ok(vif->dev))\n\t\txenvif_carrier_off(vif);\n\n\tatomic_dec(&vif->refcnt);\n\twait_event(vif->waiting_to_free, atomic_read(&vif->refcnt) == 0);\n\n\tdel_timer_sync(&vif->credit_timeout);\n\n\tif (vif->irq)\n\t\tunbind_from_irqhandler(vif->irq, vif);\n\n\tunregister_netdev(vif->dev);\n\n\txen_netbk_unmap_frontend_rings(vif);\n\n\tfree_netdev(vif->dev);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-0216", "cwe_id": "CWE-20" }, { "id": 2478, "func": "BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2,\n BOOL compressed, UINT16* flags)\n{\n\tBYTE bitsPerPixelId;\n\n\tif (!Stream_EnsureRemainingCapacity(\n\t s, update_approximate_cache_bitmap_v2_order(cache_bitmap_v2, compressed, flags)))\n\t\treturn FALSE;\n\n\tbitsPerPixelId = BPP_CBR2[cache_bitmap_v2->bitmapBpp];\n\t*flags = (cache_bitmap_v2->cacheId & 0x0003) | (bitsPerPixelId << 3) |\n\t ((cache_bitmap_v2->flags << 7) & 0xFF80);\n\n\tif (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT)\n\t{\n\t\tStream_Write_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */\n\t\tStream_Write_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */\n\t}\n\n\tif (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH)\n\t{\n\t\tif (!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapWidth)) /* bitmapWidth */\n\t\t\treturn FALSE;\n\t}\n\telse\n\t{\n\t\tif (!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapWidth) || /* bitmapWidth */\n\t\t !update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapHeight)) /* bitmapHeight */\n\t\t\treturn FALSE;\n\t}\n\n\tif (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE)\n\t\tcache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX;\n\n\tif (!update_write_4byte_unsigned(s, cache_bitmap_v2->bitmapLength) || /* bitmapLength */\n\t !update_write_2byte_unsigned(s, cache_bitmap_v2->cacheIndex)) /* cacheIndex */\n\t\treturn FALSE;\n\n\tif (compressed)\n\t{\n\t\tif (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR))\n\t\t{\n\t\t\tStream_Write_UINT16(\n\t\t\t s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */\n\t\t\tStream_Write_UINT16(\n\t\t\t s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */\n\t\t\tStream_Write_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */\n\t\t\tStream_Write_UINT16(\n\t\t\t s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */\n\t\t\tcache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize;\n\t\t}\n\n\t\tif (!Stream_EnsureRemainingCapacity(s, cache_bitmap_v2->bitmapLength))\n\t\t\treturn FALSE;\n\n\t\tStream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);\n\t}\n\telse\n\t{\n\t\tif (!Stream_EnsureRemainingCapacity(s, cache_bitmap_v2->bitmapLength))\n\t\t\treturn FALSE;\n\n\t\tStream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);\n\t}\n\n\tcache_bitmap_v2->compressed = compressed;\n\treturn TRUE;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-11096", "cwe_id": "CWE-125" }, { "id": 2478, "func": "BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2,\n BOOL compressed, UINT16* flags)\n{\n\tBOOL rc;\n\tBYTE bitsPerPixelId;\n\n\tif (!Stream_EnsureRemainingCapacity(\n\t s, update_approximate_cache_bitmap_v2_order(cache_bitmap_v2, compressed, flags)))\n\t\treturn FALSE;\n\n\tbitsPerPixelId = get_bpp_bmf(cache_bitmap_v2->bitmapBpp, &rc);\n\tif (!rc)\n\t\treturn FALSE;\n\t*flags = (cache_bitmap_v2->cacheId & 0x0003) | (bitsPerPixelId << 3) |\n\t ((cache_bitmap_v2->flags << 7) & 0xFF80);\n\n\tif (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT)\n\t{\n\t\tStream_Write_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */\n\t\tStream_Write_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */\n\t}\n\n\tif (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH)\n\t{\n\t\tif (!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapWidth)) /* bitmapWidth */\n\t\t\treturn FALSE;\n\t}\n\telse\n\t{\n\t\tif (!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapWidth) || /* bitmapWidth */\n\t\t !update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapHeight)) /* bitmapHeight */\n\t\t\treturn FALSE;\n\t}\n\n\tif (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE)\n\t\tcache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX;\n\n\tif (!update_write_4byte_unsigned(s, cache_bitmap_v2->bitmapLength) || /* bitmapLength */\n\t !update_write_2byte_unsigned(s, cache_bitmap_v2->cacheIndex)) /* cacheIndex */\n\t\treturn FALSE;\n\n\tif (compressed)\n\t{\n\t\tif (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR))\n\t\t{\n\t\t\tStream_Write_UINT16(\n\t\t\t s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */\n\t\t\tStream_Write_UINT16(\n\t\t\t s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */\n\t\t\tStream_Write_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */\n\t\t\tStream_Write_UINT16(\n\t\t\t s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */\n\t\t\tcache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize;\n\t\t}\n\n\t\tif (!Stream_EnsureRemainingCapacity(s, cache_bitmap_v2->bitmapLength))\n\t\t\treturn FALSE;\n\n\t\tStream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);\n\t}\n\telse\n\t{\n\t\tif (!Stream_EnsureRemainingCapacity(s, cache_bitmap_v2->bitmapLength))\n\t\t\treturn FALSE;\n\n\t\tStream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength);\n\t}\n\n\tcache_bitmap_v2->compressed = compressed;\n\treturn TRUE;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-11096", "cwe_id": "CWE-125" }, { "id": 430, "func": "le64addr_string(netdissect_options *ndo, const u_char *ep)\n{\n\tconst unsigned int len = 8;\n\tregister u_int i;\n\tregister char *cp;\n\tregister struct enamemem *tp;\n\tchar buf[BUFSIZE];\n\n\ttp = lookup_bytestring(ndo, ep, len);\n\tif (tp->e_name)\n\t\treturn (tp->e_name);\n\n\tcp = buf;\n\tfor (i = len; i > 0 ; --i) {\n\t\t*cp++ = hex[*(ep + i - 1) >> 4];\n\t\t*cp++ = hex[*(ep + i - 1) & 0xf];\n\t\t*cp++ = ':';\n\t}\n\tcp --;\n\n\t*cp = '\\0';\n\n\ttp->e_name = strdup(buf);\n\tif (tp->e_name == NULL)\n\t\t(*ndo->ndo_error)(ndo, \"le64addr_string: strdup(buf)\");\n\n\treturn (tp->e_name);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-12894", "cwe_id": "CWE-125" }, { "id": 430, "func": "le64addr_string(netdissect_options *ndo, const u_char *ep)\n{\n\tconst unsigned int len = 8;\n\tregister u_int i;\n\tregister char *cp;\n\tregister struct bsnamemem *tp;\n\tchar buf[BUFSIZE];\n\n\ttp = lookup_bytestring(ndo, ep, len);\n\tif (tp->bs_name)\n\t\treturn (tp->bs_name);\n\n\tcp = buf;\n\tfor (i = len; i > 0 ; --i) {\n\t\t*cp++ = hex[*(ep + i - 1) >> 4];\n\t\t*cp++ = hex[*(ep + i - 1) & 0xf];\n\t\t*cp++ = ':';\n\t}\n\tcp --;\n\n\t*cp = '\\0';\n\n\ttp->bs_name = strdup(buf);\n\tif (tp->bs_name == NULL)\n\t\t(*ndo->ndo_error)(ndo, \"le64addr_string: strdup(buf)\");\n\n\treturn (tp->bs_name);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-12894", "cwe_id": "CWE-125" }, { "id": 3005, "func": "fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mrb_bool resume, mrb_bool vmexec)\n{\n struct mrb_context *c = fiber_check(mrb, self);\n struct mrb_context *old_c = mrb->c;\n mrb_value value;\n\n fiber_check_cfunc(mrb, c);\n if (resume && c->status == MRB_FIBER_TRANSFERRED) {\n mrb_raise(mrb, E_FIBER_ERROR, \"resuming transferred fiber\");\n }\n if (c->status == MRB_FIBER_RUNNING || c->status == MRB_FIBER_RESUMED) {\n mrb_raise(mrb, E_FIBER_ERROR, \"double resume (fib)\");\n }\n if (c->status == MRB_FIBER_TERMINATED) {\n mrb_raise(mrb, E_FIBER_ERROR, \"resuming dead fiber\");\n }\n mrb->c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;\n c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);\n if (c->status == MRB_FIBER_CREATED) {\n mrb_value *b, *e;\n\n if (len >= c->stend - c->stack) {\n mrb_raise(mrb, E_FIBER_ERROR, \"too many arguments to fiber\");\n }\n b = c->stack+1;\n e = b + len;\n while (bcibase->argc = (int)len;\n value = c->stack[0] = MRB_PROC_ENV(c->ci->proc)->stack[0];\n }\n else {\n value = fiber_result(mrb, a, len);\n }\n fiber_switch_context(mrb, c);\n\n if (vmexec) {\n c->vmexec = TRUE;\n value = mrb_vm_exec(mrb, c->ci[-1].proc, c->ci->pc);\n mrb->c = old_c;\n }\n else {\n MARK_CONTEXT_MODIFY(c);\n }\n return value;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-12248", "cwe_id": "CWE-125" }, { "id": 3005, "func": "fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mrb_bool resume, mrb_bool vmexec)\n{\n struct mrb_context *c = fiber_check(mrb, self);\n struct mrb_context *old_c = mrb->c;\n enum mrb_fiber_state status;\n mrb_value value;\n\n fiber_check_cfunc(mrb, c);\n status = c->status;\n if (resume && status == MRB_FIBER_TRANSFERRED) {\n mrb_raise(mrb, E_FIBER_ERROR, \"resuming transferred fiber\");\n }\n if (status == MRB_FIBER_RUNNING || status == MRB_FIBER_RESUMED) {\n mrb_raise(mrb, E_FIBER_ERROR, \"double resume (fib)\");\n }\n if (status == MRB_FIBER_TERMINATED) {\n mrb_raise(mrb, E_FIBER_ERROR, \"resuming dead fiber\");\n }\n old_c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;\n c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);\n fiber_switch_context(mrb, c);\n if (status == MRB_FIBER_CREATED) {\n mrb_value *b, *e;\n\n mrb_stack_extend(mrb, len+2); /* for receiver and (optional) block */\n b = c->stack+1;\n e = b + len;\n while (bcibase->argc = (int)len;\n value = c->stack[0] = MRB_PROC_ENV(c->ci->proc)->stack[0];\n }\n else {\n value = fiber_result(mrb, a, len);\n }\n\n if (vmexec) {\n c->vmexec = TRUE;\n value = mrb_vm_exec(mrb, c->ci[-1].proc, c->ci->pc);\n mrb->c = old_c;\n }\n else {\n MARK_CONTEXT_MODIFY(c);\n }\n return value;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-12248", "cwe_id": "CWE-125" }, { "id": 401, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n const TfLiteTensor* axis = GetInput(context, node, kAxis);\n // Make sure the axis is only 1 dimension.\n TF_LITE_ENSURE_EQ(context, NumElements(axis), 1);\n // Make sure the axis is only either int32 or int64.\n TF_LITE_ENSURE(context,\n axis->type == kTfLiteInt32 || axis->type == kTfLiteInt64);\n\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n auto* params = reinterpret_cast(node->builtin_data);\n switch (params->output_type) {\n case kTfLiteInt32:\n output->type = kTfLiteInt32;\n break;\n case kTfLiteInt64:\n output->type = kTfLiteInt64;\n break;\n default:\n context->ReportError(context, \"Unknown index output data type: %d\",\n params->output_type);\n return kTfLiteError;\n }\n\n // Check conditions for different types.\n switch (input->type) {\n case kTfLiteFloat32:\n case kTfLiteUInt8:\n case kTfLiteInt8:\n case kTfLiteInt32:\n break;\n\n default:\n context->ReportError(\n context,\n \"Unknown input type: %d, only float32 and int types are supported\",\n input->type);\n return kTfLiteError;\n }\n\n TF_LITE_ENSURE(context, NumDimensions(input) >= 1);\n\n if (IsConstantTensor(axis)) {\n TF_LITE_ENSURE_STATUS(ResizeOutput(context, input, axis, output));\n } else {\n SetTensorToDynamic(output);\n }\n\n return kTfLiteOk;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 401, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n const TfLiteTensor* axis;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kAxis, &axis));\n // Make sure the axis is only 1 dimension.\n TF_LITE_ENSURE_EQ(context, NumElements(axis), 1);\n // Make sure the axis is only either int32 or int64.\n TF_LITE_ENSURE(context,\n axis->type == kTfLiteInt32 || axis->type == kTfLiteInt64);\n\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n auto* params = reinterpret_cast(node->builtin_data);\n switch (params->output_type) {\n case kTfLiteInt32:\n output->type = kTfLiteInt32;\n break;\n case kTfLiteInt64:\n output->type = kTfLiteInt64;\n break;\n default:\n context->ReportError(context, \"Unknown index output data type: %d\",\n params->output_type);\n return kTfLiteError;\n }\n\n // Check conditions for different types.\n switch (input->type) {\n case kTfLiteFloat32:\n case kTfLiteUInt8:\n case kTfLiteInt8:\n case kTfLiteInt32:\n break;\n\n default:\n context->ReportError(\n context,\n \"Unknown input type: %d, only float32 and int types are supported\",\n input->type);\n return kTfLiteError;\n }\n\n TF_LITE_ENSURE(context, NumDimensions(input) >= 1);\n\n if (IsConstantTensor(axis)) {\n TF_LITE_ENSURE_STATUS(ResizeOutput(context, input, axis, output));\n } else {\n SetTensorToDynamic(output);\n }\n\n return kTfLiteOk;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1113, "func": "void jslTokenAsString(int token, char *str, size_t len) {\n // see JS_ERROR_TOKEN_BUF_SIZE\n if (token>32 && token<128) {\n assert(len>=4);\n str[0] = '\\'';\n str[1] = (char)token;\n str[2] = '\\'';\n str[3] = 0;\n return;\n }\n\n switch (token) {\n case LEX_EOF : strncpy(str, \"EOF\", len); return;\n case LEX_ID : strncpy(str, \"ID\", len); return;\n case LEX_INT : strncpy(str, \"INT\", len); return;\n case LEX_FLOAT : strncpy(str, \"FLOAT\", len); return;\n case LEX_STR : strncpy(str, \"STRING\", len); return;\n case LEX_UNFINISHED_STR : strncpy(str, \"UNFINISHED STRING\", len); return;\n case LEX_TEMPLATE_LITERAL : strncpy(str, \"TEMPLATE LITERAL\", len); return;\n case LEX_UNFINISHED_TEMPLATE_LITERAL : strncpy(str, \"UNFINISHED TEMPLATE LITERAL\", len); return;\n case LEX_REGEX : strncpy(str, \"REGEX\", len); return;\n case LEX_UNFINISHED_REGEX : strncpy(str, \"UNFINISHED REGEX\", len); return;\n case LEX_UNFINISHED_COMMENT : strncpy(str, \"UNFINISHED COMMENT\", len); return;\n }\n if (token>=_LEX_OPERATOR_START && token<_LEX_R_LIST_END) {\n const char tokenNames[] =\n /* LEX_EQUAL : */ \"==\\0\"\n /* LEX_TYPEEQUAL : */ \"===\\0\"\n /* LEX_NEQUAL : */ \"!=\\0\"\n /* LEX_NTYPEEQUAL : */ \"!==\\0\"\n /* LEX_LEQUAL : */ \"<=\\0\"\n /* LEX_LSHIFT : */ \"<<\\0\"\n /* LEX_LSHIFTEQUAL : */ \"<<=\\0\"\n /* LEX_GEQUAL : */ \">=\\0\"\n /* LEX_RSHIFT : */ \">>\\0\"\n /* LEX_RSHIFTUNSIGNED */ \">>>\\0\"\n /* LEX_RSHIFTEQUAL : */ \">>=\\0\"\n /* LEX_RSHIFTUNSIGNEDEQUAL */ \">>>=\\0\"\n /* LEX_PLUSEQUAL : */ \"+=\\0\"\n /* LEX_MINUSEQUAL : */ \"-=\\0\"\n /* LEX_PLUSPLUS : */ \"++\\0\"\n /* LEX_MINUSMINUS */ \"--\\0\"\n /* LEX_MULEQUAL : */ \"*=\\0\"\n /* LEX_DIVEQUAL : */ \"/=\\0\"\n /* LEX_MODEQUAL : */ \"%=\\0\"\n /* LEX_ANDEQUAL : */ \"&=\\0\"\n /* LEX_ANDAND : */ \"&&\\0\"\n /* LEX_OREQUAL : */ \"|=\\0\"\n /* LEX_OROR : */ \"||\\0\"\n /* LEX_XOREQUAL : */ \"^=\\0\"\n /* LEX_ARROW_FUNCTION */ \"=>\\0\"\n\n // reserved words\n /*LEX_R_IF : */ \"if\\0\"\n /*LEX_R_ELSE : */ \"else\\0\"\n /*LEX_R_DO : */ \"do\\0\"\n /*LEX_R_WHILE : */ \"while\\0\"\n /*LEX_R_FOR : */ \"for\\0\"\n /*LEX_R_BREAK : */ \"return\\0\"\n /*LEX_R_CONTINUE */ \"continue\\0\"\n /*LEX_R_FUNCTION */ \"function\\0\"\n /*LEX_R_RETURN */ \"return\\0\"\n /*LEX_R_VAR : */ \"var\\0\"\n /*LEX_R_LET : */ \"let\\0\"\n /*LEX_R_CONST : */ \"const\\0\"\n /*LEX_R_THIS : */ \"this\\0\"\n /*LEX_R_THROW : */ \"throw\\0\"\n /*LEX_R_TRY : */ \"try\\0\"\n /*LEX_R_CATCH : */ \"catch\\0\"\n /*LEX_R_FINALLY : */ \"finally\\0\"\n /*LEX_R_TRUE : */ \"true\\0\"\n /*LEX_R_FALSE : */ \"false\\0\"\n /*LEX_R_NULL : */ \"null\\0\"\n /*LEX_R_UNDEFINED */ \"undefined\\0\"\n /*LEX_R_NEW : */ \"new\\0\"\n /*LEX_R_IN : */ \"in\\0\"\n /*LEX_R_INSTANCEOF */ \"instanceof\\0\"\n /*LEX_R_SWITCH */ \"switch\\0\"\n /*LEX_R_CASE */ \"case\\0\"\n /*LEX_R_DEFAULT */ \"default\\0\"\n /*LEX_R_DELETE */ \"delete\\0\"\n /*LEX_R_TYPEOF : */ \"typeof\\0\"\n /*LEX_R_VOID : */ \"void\\0\"\n /*LEX_R_DEBUGGER : */ \"debugger\\0\"\n /*LEX_R_CLASS : */ \"class\\0\"\n /*LEX_R_EXTENDS : */ \"extends\\0\"\n /*LEX_R_SUPER : */ \"super\\0\"\n /*LEX_R_STATIC : */ \"static\\0\"\n ;\n unsigned int p = 0;\n int n = token-_LEX_OPERATOR_START;\n while (n>0 && p=10);\n strncpy(str, \"?[\",len);\n itostr(token, &str[2], 10);\n strncat(str, \"]\",len);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-11595", "cwe_id": "CWE-119" }, { "id": 1113, "func": "void jslTokenAsString(int token, char *str, size_t len) {\n // see JS_ERROR_TOKEN_BUF_SIZE\n if (token>32 && token<128) {\n assert(len>=4);\n str[0] = '\\'';\n str[1] = (char)token;\n str[2] = '\\'';\n str[3] = 0;\n return;\n }\n\n switch (token) {\n case LEX_EOF : strncpy(str, \"EOF\", len); return;\n case LEX_ID : strncpy(str, \"ID\", len); return;\n case LEX_INT : strncpy(str, \"INT\", len); return;\n case LEX_FLOAT : strncpy(str, \"FLOAT\", len); return;\n case LEX_STR : strncpy(str, \"STRING\", len); return;\n case LEX_UNFINISHED_STR : strncpy(str, \"UNFINISHED STRING\", len); return;\n case LEX_TEMPLATE_LITERAL : strncpy(str, \"TEMPLATE LITERAL\", len); return;\n case LEX_UNFINISHED_TEMPLATE_LITERAL : strncpy(str, \"UNFINISHED TEMPLATE LITERAL\", len); return;\n case LEX_REGEX : strncpy(str, \"REGEX\", len); return;\n case LEX_UNFINISHED_REGEX : strncpy(str, \"UNFINISHED REGEX\", len); return;\n case LEX_UNFINISHED_COMMENT : strncpy(str, \"UNFINISHED COMMENT\", len); return;\n }\n if (token>=_LEX_OPERATOR_START && token<_LEX_R_LIST_END) {\n const char tokenNames[] =\n /* LEX_EQUAL : */ \"==\\0\"\n /* LEX_TYPEEQUAL : */ \"===\\0\"\n /* LEX_NEQUAL : */ \"!=\\0\"\n /* LEX_NTYPEEQUAL : */ \"!==\\0\"\n /* LEX_LEQUAL : */ \"<=\\0\"\n /* LEX_LSHIFT : */ \"<<\\0\"\n /* LEX_LSHIFTEQUAL : */ \"<<=\\0\"\n /* LEX_GEQUAL : */ \">=\\0\"\n /* LEX_RSHIFT : */ \">>\\0\"\n /* LEX_RSHIFTUNSIGNED */ \">>>\\0\"\n /* LEX_RSHIFTEQUAL : */ \">>=\\0\"\n /* LEX_RSHIFTUNSIGNEDEQUAL */ \">>>=\\0\"\n /* LEX_PLUSEQUAL : */ \"+=\\0\"\n /* LEX_MINUSEQUAL : */ \"-=\\0\"\n /* LEX_PLUSPLUS : */ \"++\\0\"\n /* LEX_MINUSMINUS */ \"--\\0\"\n /* LEX_MULEQUAL : */ \"*=\\0\"\n /* LEX_DIVEQUAL : */ \"/=\\0\"\n /* LEX_MODEQUAL : */ \"%=\\0\"\n /* LEX_ANDEQUAL : */ \"&=\\0\"\n /* LEX_ANDAND : */ \"&&\\0\"\n /* LEX_OREQUAL : */ \"|=\\0\"\n /* LEX_OROR : */ \"||\\0\"\n /* LEX_XOREQUAL : */ \"^=\\0\"\n /* LEX_ARROW_FUNCTION */ \"=>\\0\"\n\n // reserved words\n /*LEX_R_IF : */ \"if\\0\"\n /*LEX_R_ELSE : */ \"else\\0\"\n /*LEX_R_DO : */ \"do\\0\"\n /*LEX_R_WHILE : */ \"while\\0\"\n /*LEX_R_FOR : */ \"for\\0\"\n /*LEX_R_BREAK : */ \"return\\0\"\n /*LEX_R_CONTINUE */ \"continue\\0\"\n /*LEX_R_FUNCTION */ \"function\\0\"\n /*LEX_R_RETURN */ \"return\\0\"\n /*LEX_R_VAR : */ \"var\\0\"\n /*LEX_R_LET : */ \"let\\0\"\n /*LEX_R_CONST : */ \"const\\0\"\n /*LEX_R_THIS : */ \"this\\0\"\n /*LEX_R_THROW : */ \"throw\\0\"\n /*LEX_R_TRY : */ \"try\\0\"\n /*LEX_R_CATCH : */ \"catch\\0\"\n /*LEX_R_FINALLY : */ \"finally\\0\"\n /*LEX_R_TRUE : */ \"true\\0\"\n /*LEX_R_FALSE : */ \"false\\0\"\n /*LEX_R_NULL : */ \"null\\0\"\n /*LEX_R_UNDEFINED */ \"undefined\\0\"\n /*LEX_R_NEW : */ \"new\\0\"\n /*LEX_R_IN : */ \"in\\0\"\n /*LEX_R_INSTANCEOF */ \"instanceof\\0\"\n /*LEX_R_SWITCH */ \"switch\\0\"\n /*LEX_R_CASE */ \"case\\0\"\n /*LEX_R_DEFAULT */ \"default\\0\"\n /*LEX_R_DELETE */ \"delete\\0\"\n /*LEX_R_TYPEOF : */ \"typeof\\0\"\n /*LEX_R_VOID : */ \"void\\0\"\n /*LEX_R_DEBUGGER : */ \"debugger\\0\"\n /*LEX_R_CLASS : */ \"class\\0\"\n /*LEX_R_EXTENDS : */ \"extends\\0\"\n /*LEX_R_SUPER : */ \"super\\0\"\n /*LEX_R_STATIC : */ \"static\\0\"\n ;\n unsigned int p = 0;\n int n = token-_LEX_OPERATOR_START;\n while (n>0 && p=10);\n espruino_snprintf(str, len, \"?[%d]\", token);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-11595", "cwe_id": "CWE-119" }, { "id": 2872, "func": "_PyMemoTable_Lookup(PyMemoTable *self, PyObject *key)\n{\n size_t i;\n size_t perturb;\n size_t mask = (size_t)self->mt_mask;\n PyMemoEntry *table = self->mt_table;\n PyMemoEntry *entry;\n Py_hash_t hash = (Py_hash_t)key >> 3;\n\n i = hash & mask;\n entry = &table[i];\n if (entry->me_key == NULL || entry->me_key == key)\n return entry;\n\n for (perturb = hash; ; perturb >>= PERTURB_SHIFT) {\n i = (i << 2) + i + perturb + 1;\n entry = &table[i & mask];\n if (entry->me_key == NULL || entry->me_key == key)\n return entry;\n }\n Py_UNREACHABLE();\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20406", "cwe_id": "CWE-190" }, { "id": 2872, "func": "_PyMemoTable_Lookup(PyMemoTable *self, PyObject *key)\n{\n size_t i;\n size_t perturb;\n size_t mask = self->mt_mask;\n PyMemoEntry *table = self->mt_table;\n PyMemoEntry *entry;\n Py_hash_t hash = (Py_hash_t)key >> 3;\n\n i = hash & mask;\n entry = &table[i];\n if (entry->me_key == NULL || entry->me_key == key)\n return entry;\n\n for (perturb = hash; ; perturb >>= PERTURB_SHIFT) {\n i = (i << 2) + i + perturb + 1;\n entry = &table[i & mask];\n if (entry->me_key == NULL || entry->me_key == key)\n return entry;\n }\n Py_UNREACHABLE();\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20406", "cwe_id": "CWE-190" }, { "id": 1428, "func": "int pdf_is_pdf(FILE *fp)\n{\n int is_pdf;\n char *header;\n\n header = get_header(fp);\n\n if (header && strstr(header, \"%PDF-\"))\n is_pdf = 1;\n else \n is_pdf = 0;\n\n free(header);\n return is_pdf;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-20740", "cwe_id": "CWE-787" }, { "id": 1428, "func": "int pdf_is_pdf(FILE *fp)\n{\n char *header;\n if (!(header = get_header(fp)))\n return 0;\n\n /* First 1024 bytes of doc must be header (1.7 spec pg 1102) */\n const char *c = strstr(header, \"%PDF-\");\n const int is_pdf = c && ((c - header+strlen(\"%PDF-M.m\")) < 1024);\n free(header);\n return is_pdf;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-20740", "cwe_id": "CWE-787" }, { "id": 1478, "func": "obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)\n{\n int isinstance;\n\n PyObject *tmp = NULL;\n int lineno;\n int col_offset;\n\n if (obj == Py_None) {\n *out = NULL;\n return 0;\n }\n if (_PyObject_HasAttrId(obj, &PyId_lineno)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_lineno);\n if (tmp == NULL) goto failed;\n res = obj2ast_int(tmp, &lineno, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"lineno\\\" missing from excepthandler\");\n return 1;\n }\n if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);\n if (tmp == NULL) goto failed;\n res = obj2ast_int(tmp, &col_offset, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"col_offset\\\" missing from excepthandler\");\n return 1;\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n expr_ty type;\n identifier name;\n asdl_seq* body;\n\n if (exists_not_none(obj, &PyId_type)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_type);\n if (tmp == NULL) goto failed;\n res = obj2ast_expr(tmp, &type, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n type = NULL;\n }\n if (exists_not_none(obj, &PyId_name)) {\n int res;\n tmp = _PyObject_GetAttrId(obj, &PyId_name);\n if (tmp == NULL) goto failed;\n res = obj2ast_identifier(tmp, &name, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n } else {\n name = NULL;\n }\n if (_PyObject_HasAttrId(obj, &PyId_body)) {\n int res;\n Py_ssize_t len;\n Py_ssize_t i;\n tmp = _PyObject_GetAttrId(obj, &PyId_body);\n if (tmp == NULL) goto failed;\n if (!PyList_Check(tmp)) {\n PyErr_Format(PyExc_TypeError, \"ExceptHandler field \\\"body\\\" must be a list, not a %.200s\", tmp->ob_type->tp_name);\n goto failed;\n }\n len = PyList_GET_SIZE(tmp);\n body = _Ta3_asdl_seq_new(len, arena);\n if (body == NULL) goto failed;\n for (i = 0; i < len; i++) {\n stmt_ty value;\n res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);\n if (res != 0) goto failed;\n if (len != PyList_GET_SIZE(tmp)) {\n PyErr_SetString(PyExc_RuntimeError, \"ExceptHandler field \\\"body\\\" changed size during iteration\");\n goto failed;\n }\n asdl_seq_SET(body, i, value);\n }\n Py_CLEAR(tmp);\n } else {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"body\\\" missing from ExceptHandler\");\n return 1;\n }\n *out = ExceptHandler(type, name, body, lineno, col_offset, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n\n PyErr_Format(PyExc_TypeError, \"expected some sort of excepthandler, but got %R\", obj);\n failed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1478, "func": "obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)\n{\n int isinstance;\n\n PyObject *tmp = NULL;\n int lineno;\n int col_offset;\n\n if (obj == Py_None) {\n *out = NULL;\n return 0;\n }\n if (lookup_attr_id(obj, &PyId_lineno, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"lineno\\\" missing from excepthandler\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &lineno, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (lookup_attr_id(obj, &PyId_col_offset, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"col_offset\\\" missing from excepthandler\");\n return 1;\n }\n else {\n int res;\n res = obj2ast_int(tmp, &col_offset, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type);\n if (isinstance == -1) {\n return 1;\n }\n if (isinstance) {\n expr_ty type;\n identifier name;\n asdl_seq* body;\n\n if (lookup_attr_id(obj, &PyId_type, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL || tmp == Py_None) {\n Py_CLEAR(tmp);\n type = NULL;\n }\n else {\n int res;\n res = obj2ast_expr(tmp, &type, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (lookup_attr_id(obj, &PyId_name, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL || tmp == Py_None) {\n Py_CLEAR(tmp);\n name = NULL;\n }\n else {\n int res;\n res = obj2ast_identifier(tmp, &name, arena);\n if (res != 0) goto failed;\n Py_CLEAR(tmp);\n }\n if (lookup_attr_id(obj, &PyId_body, &tmp) < 0) {\n return 1;\n }\n if (tmp == NULL) {\n PyErr_SetString(PyExc_TypeError, \"required field \\\"body\\\" missing from ExceptHandler\");\n return 1;\n }\n else {\n int res;\n Py_ssize_t len;\n Py_ssize_t i;\n if (!PyList_Check(tmp)) {\n PyErr_Format(PyExc_TypeError, \"ExceptHandler field \\\"body\\\" must be a list, not a %.200s\", tmp->ob_type->tp_name);\n goto failed;\n }\n len = PyList_GET_SIZE(tmp);\n body = _Ta3_asdl_seq_new(len, arena);\n if (body == NULL) goto failed;\n for (i = 0; i < len; i++) {\n stmt_ty val;\n res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val, arena);\n if (res != 0) goto failed;\n if (len != PyList_GET_SIZE(tmp)) {\n PyErr_SetString(PyExc_RuntimeError, \"ExceptHandler field \\\"body\\\" changed size during iteration\");\n goto failed;\n }\n asdl_seq_SET(body, i, val);\n }\n Py_CLEAR(tmp);\n }\n *out = ExceptHandler(type, name, body, lineno, col_offset, arena);\n if (*out == NULL) goto failed;\n return 0;\n }\n\n PyErr_Format(PyExc_TypeError, \"expected some sort of excepthandler, but got %R\", obj);\n failed:\n Py_XDECREF(tmp);\n return 1;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2201, "func": "mcs_parse_domain_params(STREAM s)\n{\n\tint length;\n\n\tber_parse_header(s, MCS_TAG_DOMAIN_PARAMS, &length);\n\tin_uint8s(s, length);\n\n\treturn s_check(s);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20174", "cwe_id": "CWE-125" }, { "id": 2201, "func": "mcs_parse_domain_params(STREAM s)\n{\n\tuint32 length;\n\tstruct stream packet = *s;\n\n\tber_parse_header(s, MCS_TAG_DOMAIN_PARAMS, &length);\n\n\tif (!s_check_rem(s, length))\n\t{\n\t\trdp_protocol_error(\"mcs_parse_domain_params(), consume domain params from stream would overrun\", &packet);\n\t}\n\n\tin_uint8s(s, length);\n\n\treturn s_check(s);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20174", "cwe_id": "CWE-125" }, { "id": 1809, "func": "num_stmts(const node *n)\n{\n int i, l;\n node *ch;\n\n switch (TYPE(n)) {\n case single_input:\n if (TYPE(CHILD(n, 0)) == NEWLINE)\n return 0;\n else\n return num_stmts(CHILD(n, 0));\n case file_input:\n l = 0;\n for (i = 0; i < NCH(n); i++) {\n ch = CHILD(n, i);\n if (TYPE(ch) == stmt)\n l += num_stmts(ch);\n }\n return l;\n case stmt:\n return num_stmts(CHILD(n, 0));\n case compound_stmt:\n return 1;\n case simple_stmt:\n return NCH(n) / 2; /* Divide by 2 to remove count of semi-colons */\n case suite:\n if (NCH(n) == 1)\n return num_stmts(CHILD(n, 0));\n else {\n l = 0;\n for (i = 2; i < (NCH(n) - 1); i++)\n l += num_stmts(CHILD(n, i));\n return l;\n }\n default: {\n char buf[128];\n\n sprintf(buf, \"Non-statement found: %d %d\",\n TYPE(n), NCH(n));\n Py_FatalError(buf);\n }\n }\n Py_UNREACHABLE();\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 1809, "func": "num_stmts(const node *n)\n{\n int i, l;\n node *ch;\n\n switch (TYPE(n)) {\n case single_input:\n if (TYPE(CHILD(n, 0)) == NEWLINE)\n return 0;\n else\n return num_stmts(CHILD(n, 0));\n case file_input:\n l = 0;\n for (i = 0; i < NCH(n); i++) {\n ch = CHILD(n, i);\n if (TYPE(ch) == stmt)\n l += num_stmts(ch);\n }\n return l;\n case stmt:\n return num_stmts(CHILD(n, 0));\n case compound_stmt:\n return 1;\n case simple_stmt:\n return NCH(n) / 2; /* Divide by 2 to remove count of semi-colons */\n case suite:\n case func_body_suite:\n /* func_body_suite: simple_stmt | NEWLINE [TYPE_COMMENT NEWLINE] INDENT stmt+ DEDENT */\n /* suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT */\n if (NCH(n) == 1)\n return num_stmts(CHILD(n, 0));\n else {\n i = 2;\n l = 0;\n if (TYPE(CHILD(n, 1)) == TYPE_COMMENT)\n i += 2;\n for (; i < (NCH(n) - 1); i++)\n l += num_stmts(CHILD(n, i));\n return l;\n }\n default: {\n char buf[128];\n\n sprintf(buf, \"Non-statement found: %d %d\",\n TYPE(n), NCH(n));\n Py_FatalError(buf);\n }\n }\n Py_UNREACHABLE();\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 766, "func": "ip_optprint(netdissect_options *ndo,\n register const u_char *cp, u_int length)\n{\n\tregister u_int option_len;\n\tconst char *sep = \"\";\n\n\tfor (; length > 0; cp += option_len, length -= option_len) {\n\t\tu_int option_code;\n\n\t\tND_PRINT((ndo, \"%s\", sep));\n\t\tsep = \",\";\n\n\t\tND_TCHECK(*cp);\n\t\toption_code = *cp;\n\n\t\tND_PRINT((ndo, \"%s\",\n\t\t tok2str(ip_option_values,\"unknown %u\",option_code)));\n\n\t\tif (option_code == IPOPT_NOP ||\n option_code == IPOPT_EOL)\n\t\t\toption_len = 1;\n\n\t\telse {\n\t\t\tND_TCHECK(cp[1]);\n\t\t\toption_len = cp[1];\n\t\t\tif (option_len < 2) {\n\t\t\t\tND_PRINT((ndo, \" [bad length %u]\", option_len));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (option_len > length) {\n\t\t\tND_PRINT((ndo, \" [bad length %u]\", option_len));\n\t\t\treturn;\n\t\t}\n\n\t\tND_TCHECK2(*cp, option_len);\n\n\t\tswitch (option_code) {\n\t\tcase IPOPT_EOL:\n\t\t\treturn;\n\n\t\tcase IPOPT_TS:\n\t\t\tip_printts(ndo, cp, option_len);\n\t\t\tbreak;\n\n\t\tcase IPOPT_RR: /* fall through */\n\t\tcase IPOPT_SSRR:\n\t\tcase IPOPT_LSRR:\n\t\t\tip_printroute(ndo, cp, option_len);\n\t\t\tbreak;\n\n\t\tcase IPOPT_RA:\n\t\t\tif (option_len < 4) {\n\t\t\t\tND_PRINT((ndo, \" [bad length %u]\", option_len));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tND_TCHECK(cp[3]);\n\t\t\tif (EXTRACT_16BITS(&cp[2]) != 0)\n\t\t\t\tND_PRINT((ndo, \" value %u\", EXTRACT_16BITS(&cp[2])));\n\t\t\tbreak;\n\n\t\tcase IPOPT_NOP: /* nothing to print - fall through */\n\t\tcase IPOPT_SECURITY:\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn;\n\ntrunc:\n\tND_PRINT((ndo, \"%s\", tstr));\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-13022", "cwe_id": "CWE-125" }, { "id": 766, "func": "ip_optprint(netdissect_options *ndo,\n register const u_char *cp, u_int length)\n{\n\tregister u_int option_len;\n\tconst char *sep = \"\";\n\n\tfor (; length > 0; cp += option_len, length -= option_len) {\n\t\tu_int option_code;\n\n\t\tND_PRINT((ndo, \"%s\", sep));\n\t\tsep = \",\";\n\n\t\tND_TCHECK(*cp);\n\t\toption_code = *cp;\n\n\t\tND_PRINT((ndo, \"%s\",\n\t\t tok2str(ip_option_values,\"unknown %u\",option_code)));\n\n\t\tif (option_code == IPOPT_NOP ||\n option_code == IPOPT_EOL)\n\t\t\toption_len = 1;\n\n\t\telse {\n\t\t\tND_TCHECK(cp[1]);\n\t\t\toption_len = cp[1];\n\t\t\tif (option_len < 2) {\n\t\t\t\tND_PRINT((ndo, \" [bad length %u]\", option_len));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (option_len > length) {\n\t\t\tND_PRINT((ndo, \" [bad length %u]\", option_len));\n\t\t\treturn;\n\t\t}\n\n\t\tND_TCHECK2(*cp, option_len);\n\n\t\tswitch (option_code) {\n\t\tcase IPOPT_EOL:\n\t\t\treturn;\n\n\t\tcase IPOPT_TS:\n\t\t\tip_printts(ndo, cp, option_len);\n\t\t\tbreak;\n\n\t\tcase IPOPT_RR: /* fall through */\n\t\tcase IPOPT_SSRR:\n\t\tcase IPOPT_LSRR:\n\t\t\tif (ip_printroute(ndo, cp, option_len) == -1)\n\t\t\t\tgoto trunc;\n\t\t\tbreak;\n\n\t\tcase IPOPT_RA:\n\t\t\tif (option_len < 4) {\n\t\t\t\tND_PRINT((ndo, \" [bad length %u]\", option_len));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tND_TCHECK(cp[3]);\n\t\t\tif (EXTRACT_16BITS(&cp[2]) != 0)\n\t\t\t\tND_PRINT((ndo, \" value %u\", EXTRACT_16BITS(&cp[2])));\n\t\t\tbreak;\n\n\t\tcase IPOPT_NOP: /* nothing to print - fall through */\n\t\tcase IPOPT_SECURITY:\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn;\n\ntrunc:\n\tND_PRINT((ndo, \"%s\", tstr));\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-13022", "cwe_id": "CWE-125" }, { "id": 2414, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input = GetInput(context, node, kInputTensor);\n TfLiteTensor* output = GetOutput(context, node, kOutputTensor);\n\n TF_LITE_ENSURE_EQ(context, NumDimensions(input), 4);\n\n TF_LITE_ENSURE_TYPES_EQ(context, output->type, kTfLiteFloat32);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n TfLiteIntArray* output_size = TfLiteIntArrayCreate(4);\n output_size->data[0] = input->dims->data[0];\n output_size->data[1] = input->dims->data[1];\n output_size->data[2] = input->dims->data[2];\n output_size->data[3] = input->dims->data[3];\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 2414, "func": "TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {\n TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);\n TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);\n\n const TfLiteTensor* input;\n TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));\n TfLiteTensor* output;\n TF_LITE_ENSURE_OK(context,\n GetOutputSafe(context, node, kOutputTensor, &output));\n\n TF_LITE_ENSURE_EQ(context, NumDimensions(input), 4);\n\n TF_LITE_ENSURE_TYPES_EQ(context, output->type, kTfLiteFloat32);\n TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type);\n\n TfLiteIntArray* output_size = TfLiteIntArrayCreate(4);\n output_size->data[0] = input->dims->data[0];\n output_size->data[1] = input->dims->data[1];\n output_size->data[2] = input->dims->data[2];\n output_size->data[3] = input->dims->data[3];\n\n return context->ResizeTensor(context, output, output_size);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 1409, "func": "long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)\n{\n\tstruct key *key;\n\tkey_ref_t key_ref;\n\tlong ret;\n\n\t/* find the key first */\n\tkey_ref = lookup_user_key(keyid, 0, 0);\n\tif (IS_ERR(key_ref)) {\n\t\tret = -ENOKEY;\n\t\tgoto error;\n\t}\n\n\tkey = key_ref_to_ptr(key_ref);\n\n\t/* see if we can read it directly */\n\tret = key_permission(key_ref, KEY_NEED_READ);\n\tif (ret == 0)\n\t\tgoto can_read_key;\n\tif (ret != -EACCES)\n\t\tgoto error;\n\n\t/* we can't; see if it's searchable from this process's keyrings\n\t * - we automatically take account of the fact that it may be\n\t * dangling off an instantiation key\n\t */\n\tif (!is_key_possessed(key_ref)) {\n\t\tret = -EACCES;\n\t\tgoto error2;\n\t}\n\n\t/* the key is probably readable - now try to read it */\ncan_read_key:\n\tret = key_validate(key);\n\tif (ret == 0) {\n\t\tret = -EOPNOTSUPP;\n\t\tif (key->type->read) {\n\t\t\t/* read the data with the semaphore held (since we\n\t\t\t * might sleep) */\n\t\t\tdown_read(&key->sem);\n\t\t\tret = key->type->read(key, buffer, buflen);\n\t\t\tup_read(&key->sem);\n\t\t}\n\t}\n\nerror2:\n\tkey_put(key);\nerror:\n\treturn ret;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2015-7550", "cwe_id": "CWE-362" }, { "id": 1409, "func": "long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)\n{\n\tstruct key *key;\n\tkey_ref_t key_ref;\n\tlong ret;\n\n\t/* find the key first */\n\tkey_ref = lookup_user_key(keyid, 0, 0);\n\tif (IS_ERR(key_ref)) {\n\t\tret = -ENOKEY;\n\t\tgoto error;\n\t}\n\n\tkey = key_ref_to_ptr(key_ref);\n\n\t/* see if we can read it directly */\n\tret = key_permission(key_ref, KEY_NEED_READ);\n\tif (ret == 0)\n\t\tgoto can_read_key;\n\tif (ret != -EACCES)\n\t\tgoto error;\n\n\t/* we can't; see if it's searchable from this process's keyrings\n\t * - we automatically take account of the fact that it may be\n\t * dangling off an instantiation key\n\t */\n\tif (!is_key_possessed(key_ref)) {\n\t\tret = -EACCES;\n\t\tgoto error2;\n\t}\n\n\t/* the key is probably readable - now try to read it */\ncan_read_key:\n\tret = -EOPNOTSUPP;\n\tif (key->type->read) {\n\t\t/* Read the data with the semaphore held (since we might sleep)\n\t\t * to protect against the key being updated or revoked.\n\t\t */\n\t\tdown_read(&key->sem);\n\t\tret = key_validate(key);\n\t\tif (ret == 0)\n\t\t\tret = key->type->read(key, buffer, buflen);\n\t\tup_read(&key->sem);\n\t}\n\nerror2:\n\tkey_put(key);\nerror:\n\treturn ret;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2015-7550", "cwe_id": "CWE-362" }, { "id": 2320, "func": "compile_nested_function(exarg_T *eap, cctx_T *cctx)\n{\n int\t\tis_global = *eap->arg == 'g' && eap->arg[1] == ':';\n char_u\t*name_start = eap->arg;\n char_u\t*name_end = to_name_end(eap->arg, TRUE);\n char_u\t*lambda_name;\n ufunc_T\t*ufunc;\n int\t\tr = FAIL;\n compiletype_T compile_type;\n\n if (eap->forceit)\n {\n\temsg(_(e_cannot_use_bang_with_nested_def));\n\treturn NULL;\n }\n\n if (*name_start == '/')\n {\n\tname_end = skip_regexp(name_start + 1, '/', TRUE);\n\tif (*name_end == '/')\n\t ++name_end;\n\tset_nextcmd(eap, name_end);\n }\n if (name_end == name_start || *skipwhite(name_end) != '(')\n {\n\tif (!ends_excmd2(name_start, name_end))\n\t{\n\t semsg(_(e_invalid_command_str), eap->cmd);\n\t return NULL;\n\t}\n\n\t// \"def\" or \"def Name\": list functions\n\tif (generate_DEF(cctx, name_start, name_end - name_start) == FAIL)\n\t return NULL;\n\treturn eap->nextcmd == NULL ? (char_u *)\"\" : eap->nextcmd;\n }\n\n // Only g:Func() can use a namespace.\n if (name_start[1] == ':' && !is_global)\n {\n\tsemsg(_(e_namespace_not_supported_str), name_start);\n\treturn NULL;\n }\n if (check_defined(name_start, name_end - name_start, cctx, FALSE) == FAIL)\n\treturn NULL;\n\n eap->arg = name_end;\n fill_exarg_from_cctx(eap, cctx);\n\n eap->forceit = FALSE;\n // We use the special 99 name, but it's not really a lambda.\n lambda_name = vim_strsave(get_lambda_name());\n if (lambda_name == NULL)\n\treturn NULL;\n ufunc = define_function(eap, lambda_name);\n\n if (ufunc == NULL)\n {\n\tr = eap->skip ? OK : FAIL;\n\tgoto theend;\n }\n\n // copy over the block scope IDs before compiling\n if (!is_global && cctx->ctx_ufunc->uf_block_depth > 0)\n {\n\tint block_depth = cctx->ctx_ufunc->uf_block_depth;\n\n\tufunc->uf_block_ids = ALLOC_MULT(int, block_depth);\n\tif (ufunc->uf_block_ids != NULL)\n\t{\n\t mch_memmove(ufunc->uf_block_ids, cctx->ctx_ufunc->uf_block_ids,\n\t\t\t\t\t\t sizeof(int) * block_depth);\n\t ufunc->uf_block_depth = block_depth;\n\t}\n }\n\n compile_type = COMPILE_TYPE(ufunc);\n#ifdef FEAT_PROFILE\n // If the outer function is profiled, also compile the nested function for\n // profiling.\n if (cctx->ctx_compile_type == CT_PROFILE)\n\tcompile_type = CT_PROFILE;\n#endif\n if (func_needs_compiling(ufunc, compile_type)\n\t && compile_def_function(ufunc, TRUE, compile_type, cctx) == FAIL)\n {\n\tfunc_ptr_unref(ufunc);\n\tgoto theend;\n }\n\n#ifdef FEAT_PROFILE\n // When the outer function is compiled for profiling, the nested function\n // may be called without profiling. Compile it here in the right context.\n if (compile_type == CT_PROFILE && func_needs_compiling(ufunc, CT_NONE))\n\tcompile_def_function(ufunc, FALSE, CT_NONE, cctx);\n#endif\n\n if (is_global)\n {\n\tchar_u *func_name = vim_strnsave(name_start + 2,\n\t\t\t\t\t\t name_end - name_start - 2);\n\n\tif (func_name == NULL)\n\t r = FAIL;\n\telse\n\t{\n\t r = generate_NEWFUNC(cctx, lambda_name, func_name);\n\t lambda_name = NULL;\n\t}\n }\n else\n {\n\t// Define a local variable for the function reference.\n\tlvar_T\t*lvar = reserve_local(cctx, name_start, name_end - name_start,\n\t\t\t\t\t\t TRUE, ufunc->uf_func_type);\n\n\tif (lvar == NULL)\n\t goto theend;\n\tif (generate_FUNCREF(cctx, ufunc) == FAIL)\n\t goto theend;\n\tr = generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL);\n }\n\ntheend:\n vim_free(lambda_name);\n return r == FAIL ? NULL : (char_u *)\"\";\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-4173", "cwe_id": "CWE-416" }, { "id": 2320, "func": "compile_nested_function(exarg_T *eap, cctx_T *cctx, char_u **line_to_free)\n{\n int\t\tis_global = *eap->arg == 'g' && eap->arg[1] == ':';\n char_u\t*name_start = eap->arg;\n char_u\t*name_end = to_name_end(eap->arg, TRUE);\n int\t\toff;\n char_u\t*func_name;\n char_u\t*lambda_name;\n ufunc_T\t*ufunc;\n int\t\tr = FAIL;\n compiletype_T compile_type;\n\n if (eap->forceit)\n {\n\temsg(_(e_cannot_use_bang_with_nested_def));\n\treturn NULL;\n }\n\n if (*name_start == '/')\n {\n\tname_end = skip_regexp(name_start + 1, '/', TRUE);\n\tif (*name_end == '/')\n\t ++name_end;\n\tset_nextcmd(eap, name_end);\n }\n if (name_end == name_start || *skipwhite(name_end) != '(')\n {\n\tif (!ends_excmd2(name_start, name_end))\n\t{\n\t semsg(_(e_invalid_command_str), eap->cmd);\n\t return NULL;\n\t}\n\n\t// \"def\" or \"def Name\": list functions\n\tif (generate_DEF(cctx, name_start, name_end - name_start) == FAIL)\n\t return NULL;\n\treturn eap->nextcmd == NULL ? (char_u *)\"\" : eap->nextcmd;\n }\n\n // Only g:Func() can use a namespace.\n if (name_start[1] == ':' && !is_global)\n {\n\tsemsg(_(e_namespace_not_supported_str), name_start);\n\treturn NULL;\n }\n if (check_defined(name_start, name_end - name_start, cctx, FALSE) == FAIL)\n\treturn NULL;\n\n eap->arg = name_end;\n fill_exarg_from_cctx(eap, cctx);\n\n eap->forceit = FALSE;\n // We use the special 99 name, but it's not really a lambda.\n lambda_name = vim_strsave(get_lambda_name());\n if (lambda_name == NULL)\n\treturn NULL;\n\n // This may free the current line, make a copy of the name.\n off = is_global ? 2 : 0;\n func_name = vim_strnsave(name_start + off, name_end - name_start - off);\n if (func_name == NULL)\n {\n\tr = FAIL;\n\tgoto theend;\n }\n\n ufunc = define_function(eap, lambda_name, line_to_free);\n\n if (ufunc == NULL)\n {\n\tr = eap->skip ? OK : FAIL;\n\tgoto theend;\n }\n\n // copy over the block scope IDs before compiling\n if (!is_global && cctx->ctx_ufunc->uf_block_depth > 0)\n {\n\tint block_depth = cctx->ctx_ufunc->uf_block_depth;\n\n\tufunc->uf_block_ids = ALLOC_MULT(int, block_depth);\n\tif (ufunc->uf_block_ids != NULL)\n\t{\n\t mch_memmove(ufunc->uf_block_ids, cctx->ctx_ufunc->uf_block_ids,\n\t\t\t\t\t\t sizeof(int) * block_depth);\n\t ufunc->uf_block_depth = block_depth;\n\t}\n }\n\n compile_type = COMPILE_TYPE(ufunc);\n#ifdef FEAT_PROFILE\n // If the outer function is profiled, also compile the nested function for\n // profiling.\n if (cctx->ctx_compile_type == CT_PROFILE)\n\tcompile_type = CT_PROFILE;\n#endif\n if (func_needs_compiling(ufunc, compile_type)\n\t && compile_def_function(ufunc, TRUE, compile_type, cctx) == FAIL)\n {\n\tfunc_ptr_unref(ufunc);\n\tgoto theend;\n }\n\n#ifdef FEAT_PROFILE\n // When the outer function is compiled for profiling, the nested function\n // may be called without profiling. Compile it here in the right context.\n if (compile_type == CT_PROFILE && func_needs_compiling(ufunc, CT_NONE))\n\tcompile_def_function(ufunc, FALSE, CT_NONE, cctx);\n#endif\n\n if (is_global)\n {\n\tr = generate_NEWFUNC(cctx, lambda_name, func_name);\n\tfunc_name = NULL;\n\tlambda_name = NULL;\n }\n else\n {\n\t// Define a local variable for the function reference.\n\tlvar_T\t*lvar = reserve_local(cctx, func_name, name_end - name_start,\n\t\t\t\t\t\t TRUE, ufunc->uf_func_type);\n\n\tif (lvar == NULL)\n\t goto theend;\n\tif (generate_FUNCREF(cctx, ufunc) == FAIL)\n\t goto theend;\n\tr = generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL);\n }\n\ntheend:\n vim_free(lambda_name);\n vim_free(func_name);\n return r == FAIL ? NULL : (char_u *)\"\";\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-4173", "cwe_id": "CWE-416" }, { "id": 2674, "func": "TEST_CASE_METHOD(TestFixture, \"ECDSA AES keygen and signature test\", \"[ecdsa-aes-key-sig-gen]\") {\n vector errMsg(BUF_LEN, 0);\n int errStatus = 0;\n vector encrPrivKey(BUF_LEN, 0);\n vector pubKeyX(BUF_LEN, 0);\n vector pubKeyY(BUF_LEN, 0);\n\n uint32_t encLen = 0;\n PRINT_SRC_LINE\n auto status = trustedGenerateEcdsaKeyAES(eid, &errStatus, errMsg.data(), encrPrivKey.data(), &encLen,\n pubKeyX.data(),\n pubKeyY.data());\n REQUIRE(status == SGX_SUCCESS);\n REQUIRE(errStatus == SGX_SUCCESS);\n\n string hex = SAMPLE_HEX_HASH;\n vector signatureR(BUF_LEN, 0);\n vector signatureS(BUF_LEN, 0);\n uint8_t signatureV = 0;\n\n\n for (int i = 0; i < 50; i++) {\n PRINT_SRC_LINE\n status = trustedEcdsaSignAES(eid, &errStatus, errMsg.data(), encrPrivKey.data(), encLen,\n hex.data(),\n signatureR.data(),\n signatureS.data(), &signatureV, 16);\n REQUIRE(status == SGX_SUCCESS);\n REQUIRE(errStatus == SGX_SUCCESS);\n }\n\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-36218", "cwe_id": "CWE-787" }, { "id": 2674, "func": "TEST_CASE_METHOD(TestFixture, \"ECDSA AES keygen and signature test\", \"[ecdsa-aes-key-sig-gen]\") {\n vector errMsg(BUF_LEN, 0);\n int errStatus = 0;\n vector encrPrivKey(BUF_LEN, 0);\n vector pubKeyX(BUF_LEN, 0);\n vector pubKeyY(BUF_LEN, 0);\n\n uint64_t encLen = 0;\n PRINT_SRC_LINE\n auto status = trustedGenerateEcdsaKeyAES(eid, &errStatus, errMsg.data(), encrPrivKey.data(), &encLen,\n pubKeyX.data(),\n pubKeyY.data());\n REQUIRE(status == SGX_SUCCESS);\n REQUIRE(errStatus == SGX_SUCCESS);\n\n string hex = SAMPLE_HEX_HASH;\n vector signatureR(BUF_LEN, 0);\n vector signatureS(BUF_LEN, 0);\n uint8_t signatureV = 0;\n\n\n for (int i = 0; i < 50; i++) {\n PRINT_SRC_LINE\n status = trustedEcdsaSignAES(eid, &errStatus, errMsg.data(), encrPrivKey.data(), encLen,\n hex.data(),\n signatureR.data(),\n signatureS.data(), &signatureV, 16);\n REQUIRE(status == SGX_SUCCESS);\n REQUIRE(errStatus == SGX_SUCCESS);\n }\n\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-36218", "cwe_id": "CWE-787" }, { "id": 487, "func": "TfLiteTensor* GetOutput(TfLiteContext* context, const TfLiteNode* node,\n int index) {\n if (context->tensors != nullptr) {\n return &context->tensors[node->outputs->data[index]];\n } else {\n return context->GetTensor(context, node->outputs->data[index]);\n }\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 487, "func": "TfLiteTensor* GetOutput(TfLiteContext* context, const TfLiteNode* node,\n int index) {\n if (index >= 0 && index < node->outputs->size) {\n const int tensor_index = node->outputs->data[index];\n if (tensor_index != kTfLiteOptionalTensor) {\n if (context->tensors != nullptr) {\n return &context->tensors[tensor_index];\n } else {\n return context->GetTensor(context, tensor_index);\n }\n }\n }\n return nullptr;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2020-15211", "cwe_id": "CWE-125" }, { "id": 3156, "func": "static int parseOperand(RAsm *a, const char *str, Operand *op, bool isrepop) {\n\tsize_t pos, nextpos = 0;\n\tx86newTokenType last_type;\n\tint size_token = 1;\n\tbool explicit_size = false;\n\tint reg_index = 0;\n\t// Reset type\n\top->type = 0;\n\t// Consume tokens denoting the operand size\n\twhile (size_token) {\n\t\tpos = nextpos;\n\t\tlast_type = getToken (str, &pos, &nextpos);\n\n\t\t// Token may indicate size: then skip\n\t\tif (!r_str_ncasecmp (str + pos, \"ptr\", 3)) {\n\t\t\tcontinue;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"byte\", 4)) {\n\t\t\top->type |= OT_MEMORY | OT_BYTE;\n\t\t\top->dest_size = OT_BYTE;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"word\", 4)) {\n\t\t\top->type |= OT_MEMORY | OT_WORD;\n\t\t\top->dest_size = OT_WORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"dword\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_DWORD;\n\t\t\top->dest_size = OT_DWORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"qword\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_QWORD;\n\t\t\top->dest_size = OT_QWORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"oword\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_OWORD;\n\t\t\top->dest_size = OT_OWORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"tbyte\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_TBYTE;\n\t\t\top->dest_size = OT_TBYTE;\n\t\t\texplicit_size = true;\n\t\t} else { // the current token doesn't denote a size\n\t\t\tsize_token = 0;\n\t\t}\n\t}\n\n\t// Next token: register, immediate, or '['\n\tif (str[pos] == '[') {\n\t\t// Don't care about size, if none is given.\n\t\tif (!op->type) {\n\t\t\top->type = OT_MEMORY;\n\t\t}\n\t\t// At the moment, we only accept plain linear combinations:\n\t\t// part := address | [factor *] register\n\t\t// address := part {+ part}*\n\t\top->offset = op->scale[0] = op->scale[1] = 0;\n\n\t\tut64 temp = 1;\n\t\tRegister reg = X86R_UNDEFINED;\n\t\tbool first_reg = true;\n\t\twhile (str[pos] != ']') {\n\t\t\tif (pos > nextpos) {\n\t\t\t//\teprintf (\"Error parsing instruction\\n\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpos = nextpos;\n\t\t\tif (!str[pos]) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlast_type = getToken (str, &pos, &nextpos);\n\n\t\t\tif (last_type == TT_SPECIAL) {\n\t\t\t\tif (str[pos] == '+' || str[pos] == '-' || str[pos] == ']') {\n\t\t\t\t\tif (reg != X86R_UNDEFINED) {\n\t\t\t\t\t\top->regs[reg_index] = reg;\n\t\t\t\t\t\top->scale[reg_index] = temp;\n\t\t\t\t\t\t++reg_index;\n\t\t\t\t\t} else {\n\t\t\t\t\t\top->offset += temp;\n\t\t\t\t\t\top->regs[reg_index] = X86R_UNDEFINED;\n\t\t\t\t\t}\n\n\t\t\t\t\ttemp = 1;\n\t\t\t\t\treg = X86R_UNDEFINED;\n\t\t\t\t} else if (str[pos] == '*') {\n\t\t\t\t\t// go to ], + or - to get scale\n\n\t\t\t\t\t// Something to do here?\n\t\t\t\t\t// Seems we are just ignoring '*' or assuming it implicitly.\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (last_type == TT_WORD) {\n\t\t\t\tut32 reg_type = 0;\n\n\t\t\t\t// We can't multiply registers\n\t\t\t\tif (reg != X86R_UNDEFINED) {\n\t\t\t\t\top->type = 0;\t// Make the result invalid\n\t\t\t\t}\n\n\t\t\t\t// Reset nextpos: parseReg wants to parse from the beginning\n\t\t\t\tnextpos = pos;\n\t\t\t\treg = parseReg (a, str, &nextpos, ®_type);\n\n\t\t\t\tif (first_reg) {\n\t\t\t\t\top->extended = false;\n\t\t\t\t\tif (reg > 8) {\n\t\t\t\t\t\top->extended = true;\n\t\t\t\t\t\top->reg = reg - 9;\n\t\t\t\t\t}\n\t\t\t\t\tfirst_reg = false;\n\t\t\t\t} else if (reg > 8) {\n\t\t\t\t\top->reg = reg - 9;\n\t\t\t\t}\n\t\t\t\tif (reg_type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\t\t\top->reg = reg;\n\t\t\t\t\top->type = reg_type;\n\t\t\t\t\tparse_segment_offset (a, str, &nextpos, op, reg_index);\n\t\t\t\t\treturn nextpos;\n\t\t\t\t}\n\n\t\t\t\t// Still going to need to know the size if not specified\n\t\t\t\tif (!explicit_size) {\n\t\t\t\t\top->type |= reg_type;\n\t\t\t\t}\n\t\t\t\top->reg_size = reg_type;\n\t\t\t\top->explicit_size = explicit_size;\n\n\t\t\t\t// Addressing only via general purpose registers\n\t\t\t\tif (!(reg_type & OT_GPREG)) {\n\t\t\t\t\top->type = 0;\t// Make the result invalid\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tchar *p = strchr (str, '+');\n\t\t\t\top->offset_sign = 1;\n\t\t\t\tif (!p) {\n\t\t\t\t\tp = strchr (str, '-');\n\t\t\t\t\tif (p) {\n\t\t\t\t\t\top->offset_sign = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//with SIB notation, we need to consider the right sign\n\t\t\t\tchar * plus = strchr (str, '+');\n\t\t\t\tchar * minus = strchr (str, '-');\n\t\t\t\tchar * closeB = strchr (str, ']');\n\t\t\t\tif (plus && minus && plus < closeB && minus < closeB) {\n\t\t\t\t\top->offset_sign = -1;\n\t\t\t\t}\n\t\t\t\t// If there's a scale, we don't want to parse out the\n\t\t\t\t// scale with the offset (scale + offset) otherwise the scale\n\t\t\t\t// will be the sum of the two. This splits the numbers\n\t\t\t\tchar *tmp;\n\t\t\t\ttmp = malloc (strlen (str + pos) + 1);\n\t\t\t\tstrcpy (tmp, str + pos);\n\t\t\t\tstrtok (tmp, \"+-\");\n\t\t\t\tst64 read = getnum (a, tmp);\n\t\t\t\tfree (tmp);\n\t\t\t\ttemp *= read;\n\t\t\t}\n\t\t}\n\t} else if (last_type == TT_WORD) { // register\n\t\tnextpos = pos;\n\t\tRFlagItem *flag;\n\n\t\tif (isrepop) {\n\t\t\top->is_good_flag = false;\n\t\t\tstrncpy (op->rep_op, str, MAX_REPOP_LENGTH - 1);\n\t\t\top->rep_op[MAX_REPOP_LENGTH - 1] = '\\0';\n\t\t\treturn nextpos;\n\t\t}\n\n\t\top->reg = parseReg (a, str, &nextpos, &op->type);\n\n\t\top->extended = false;\n\t\tif (op->reg > 8) {\n\t\t\top->extended = true;\n\t\t\top->reg -= 9;\n\t\t}\n\t\tif (op->type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\tparse_segment_offset (a, str, &nextpos, op, reg_index);\n\t\t\treturn nextpos;\n\t\t}\n\t\tif (op->reg == X86R_UNDEFINED) {\n\t\t\top->is_good_flag = false;\n\t\t\tif (a->num && a->num->value == 0) {\n\t\t\t\treturn nextpos;\n\t\t\t}\n\t\t\top->type = OT_CONSTANT;\n\t\t\tRCore *core = a->num? (RCore *)(a->num->userptr): NULL;\n\t\t\tif (core && (flag = r_flag_get (core->flags, str))) {\n\t\t\t\top->is_good_flag = true;\n\t\t\t}\n\n\t\t\tchar *p = strchr (str, '-');\n\t\t\tif (p) {\n\t\t\t\top->sign = -1;\n\t\t\t\tstr = ++p;\n\t\t\t}\n\t\t\top->immediate = getnum (a, str);\n\t\t} else if (op->reg < X86R_UNDEFINED) {\n\t\t\tstrncpy (op->rep_op, str, MAX_REPOP_LENGTH - 1);\n\t\t\top->rep_op[MAX_REPOP_LENGTH - 1] = '\\0';\n\t\t}\n\t} else { // immediate\n\t\t// We don't know the size, so let's just set no size flag.\n\t\top->type = OT_CONSTANT;\n\t\top->sign = 1;\n\t\tchar *p = strchr (str, '-');\n\t\tif (p) {\n\t\t\top->sign = -1;\n\t\t\tstr = ++p;\n\t\t}\n\t\top->immediate = getnum (a, str);\n\t}\n\n\treturn nextpos;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2018-20455", "cwe_id": "CWE-787" }, { "id": 3156, "func": "static int parseOperand(RAsm *a, const char *str, Operand *op, bool isrepop) {\n\tsize_t pos, nextpos = 0;\n\tx86newTokenType last_type;\n\tint size_token = 1;\n\tbool explicit_size = false;\n\tint reg_index = 0;\n\t// Reset type\n\top->type = 0;\n\t// Consume tokens denoting the operand size\n\twhile (size_token) {\n\t\tpos = nextpos;\n\t\tlast_type = getToken (str, &pos, &nextpos);\n\n\t\t// Token may indicate size: then skip\n\t\tif (!r_str_ncasecmp (str + pos, \"ptr\", 3)) {\n\t\t\tcontinue;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"byte\", 4)) {\n\t\t\top->type |= OT_MEMORY | OT_BYTE;\n\t\t\top->dest_size = OT_BYTE;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"word\", 4)) {\n\t\t\top->type |= OT_MEMORY | OT_WORD;\n\t\t\top->dest_size = OT_WORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"dword\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_DWORD;\n\t\t\top->dest_size = OT_DWORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"qword\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_QWORD;\n\t\t\top->dest_size = OT_QWORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"oword\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_OWORD;\n\t\t\top->dest_size = OT_OWORD;\n\t\t\texplicit_size = true;\n\t\t} else if (!r_str_ncasecmp (str + pos, \"tbyte\", 5)) {\n\t\t\top->type |= OT_MEMORY | OT_TBYTE;\n\t\t\top->dest_size = OT_TBYTE;\n\t\t\texplicit_size = true;\n\t\t} else { // the current token doesn't denote a size\n\t\t\tsize_token = 0;\n\t\t}\n\t}\n\n\t// Next token: register, immediate, or '['\n\tif (str[pos] == '[') {\n\t\t// Don't care about size, if none is given.\n\t\tif (!op->type) {\n\t\t\top->type = OT_MEMORY;\n\t\t}\n\t\t// At the moment, we only accept plain linear combinations:\n\t\t// part := address | [factor *] register\n\t\t// address := part {+ part}*\n\t\top->offset = op->scale[0] = op->scale[1] = 0;\n\n\t\tut64 temp = 1;\n\t\tRegister reg = X86R_UNDEFINED;\n\t\tbool first_reg = true;\n\t\twhile (str[pos] != ']') {\n\t\t\tif (pos > nextpos) {\n\t\t\t//\teprintf (\"Error parsing instruction\\n\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpos = nextpos;\n\t\t\tif (!str[pos]) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlast_type = getToken (str, &pos, &nextpos);\n\n\t\t\tif (last_type == TT_SPECIAL) {\n\t\t\t\tif (str[pos] == '+' || str[pos] == '-' || str[pos] == ']') {\n\t\t\t\t\tif (reg != X86R_UNDEFINED) {\n\t\t\t\t\t\tif (reg_index < 2) {\n\t\t\t\t\t\t\top->regs[reg_index] = reg;\n\t\t\t\t\t\t\top->scale[reg_index] = temp;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t++reg_index;\n\t\t\t\t\t} else {\n\t\t\t\t\t\top->offset += temp;\n\t\t\t\t\t\tif (reg_index < 2) {\n\t\t\t\t\t\t\top->regs[reg_index] = X86R_UNDEFINED;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttemp = 1;\n\t\t\t\t\treg = X86R_UNDEFINED;\n\t\t\t\t} else if (str[pos] == '*') {\n\t\t\t\t\t// go to ], + or - to get scale\n\n\t\t\t\t\t// Something to do here?\n\t\t\t\t\t// Seems we are just ignoring '*' or assuming it implicitly.\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (last_type == TT_WORD) {\n\t\t\t\tut32 reg_type = 0;\n\n\t\t\t\t// We can't multiply registers\n\t\t\t\tif (reg != X86R_UNDEFINED) {\n\t\t\t\t\top->type = 0;\t// Make the result invalid\n\t\t\t\t}\n\n\t\t\t\t// Reset nextpos: parseReg wants to parse from the beginning\n\t\t\t\tnextpos = pos;\n\t\t\t\treg = parseReg (a, str, &nextpos, ®_type);\n\n\t\t\t\tif (first_reg) {\n\t\t\t\t\top->extended = false;\n\t\t\t\t\tif (reg > 8) {\n\t\t\t\t\t\top->extended = true;\n\t\t\t\t\t\top->reg = reg - 9;\n\t\t\t\t\t}\n\t\t\t\t\tfirst_reg = false;\n\t\t\t\t} else if (reg > 8) {\n\t\t\t\t\top->reg = reg - 9;\n\t\t\t\t}\n\t\t\t\tif (reg_type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\t\t\top->reg = reg;\n\t\t\t\t\top->type = reg_type;\n\t\t\t\t\tparse_segment_offset (a, str, &nextpos, op, reg_index);\n\t\t\t\t\treturn nextpos;\n\t\t\t\t}\n\n\t\t\t\t// Still going to need to know the size if not specified\n\t\t\t\tif (!explicit_size) {\n\t\t\t\t\top->type |= reg_type;\n\t\t\t\t}\n\t\t\t\top->reg_size = reg_type;\n\t\t\t\top->explicit_size = explicit_size;\n\n\t\t\t\t// Addressing only via general purpose registers\n\t\t\t\tif (!(reg_type & OT_GPREG)) {\n\t\t\t\t\top->type = 0;\t// Make the result invalid\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tchar *p = strchr (str, '+');\n\t\t\t\top->offset_sign = 1;\n\t\t\t\tif (!p) {\n\t\t\t\t\tp = strchr (str, '-');\n\t\t\t\t\tif (p) {\n\t\t\t\t\t\top->offset_sign = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//with SIB notation, we need to consider the right sign\n\t\t\t\tchar * plus = strchr (str, '+');\n\t\t\t\tchar * minus = strchr (str, '-');\n\t\t\t\tchar * closeB = strchr (str, ']');\n\t\t\t\tif (plus && minus && plus < closeB && minus < closeB) {\n\t\t\t\t\top->offset_sign = -1;\n\t\t\t\t}\n\t\t\t\t// If there's a scale, we don't want to parse out the\n\t\t\t\t// scale with the offset (scale + offset) otherwise the scale\n\t\t\t\t// will be the sum of the two. This splits the numbers\n\t\t\t\tchar *tmp;\n\t\t\t\ttmp = malloc (strlen (str + pos) + 1);\n\t\t\t\tstrcpy (tmp, str + pos);\n\t\t\t\tstrtok (tmp, \"+-\");\n\t\t\t\tst64 read = getnum (a, tmp);\n\t\t\t\tfree (tmp);\n\t\t\t\ttemp *= read;\n\t\t\t}\n\t\t}\n\t} else if (last_type == TT_WORD) { // register\n\t\tnextpos = pos;\n\t\tRFlagItem *flag;\n\n\t\tif (isrepop) {\n\t\t\top->is_good_flag = false;\n\t\t\tstrncpy (op->rep_op, str, MAX_REPOP_LENGTH - 1);\n\t\t\top->rep_op[MAX_REPOP_LENGTH - 1] = '\\0';\n\t\t\treturn nextpos;\n\t\t}\n\n\t\top->reg = parseReg (a, str, &nextpos, &op->type);\n\n\t\top->extended = false;\n\t\tif (op->reg > 8) {\n\t\t\top->extended = true;\n\t\t\top->reg -= 9;\n\t\t}\n\t\tif (op->type & OT_REGTYPE & OT_SEGMENTREG) {\n\t\t\tparse_segment_offset (a, str, &nextpos, op, reg_index);\n\t\t\treturn nextpos;\n\t\t}\n\t\tif (op->reg == X86R_UNDEFINED) {\n\t\t\top->is_good_flag = false;\n\t\t\tif (a->num && a->num->value == 0) {\n\t\t\t\treturn nextpos;\n\t\t\t}\n\t\t\top->type = OT_CONSTANT;\n\t\t\tRCore *core = a->num? (RCore *)(a->num->userptr): NULL;\n\t\t\tif (core && (flag = r_flag_get (core->flags, str))) {\n\t\t\t\top->is_good_flag = true;\n\t\t\t}\n\n\t\t\tchar *p = strchr (str, '-');\n\t\t\tif (p) {\n\t\t\t\top->sign = -1;\n\t\t\t\tstr = ++p;\n\t\t\t}\n\t\t\top->immediate = getnum (a, str);\n\t\t} else if (op->reg < X86R_UNDEFINED) {\n\t\t\tstrncpy (op->rep_op, str, MAX_REPOP_LENGTH - 1);\n\t\t\top->rep_op[MAX_REPOP_LENGTH - 1] = '\\0';\n\t\t}\n\t} else { // immediate\n\t\t// We don't know the size, so let's just set no size flag.\n\t\top->type = OT_CONSTANT;\n\t\top->sign = 1;\n\t\tchar *p = strchr (str, '-');\n\t\tif (p) {\n\t\t\top->sign = -1;\n\t\t\tstr = ++p;\n\t\t}\n\t\top->immediate = getnum (a, str);\n\t}\n\n\treturn nextpos;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2018-20455", "cwe_id": "CWE-787" }, { "id": 1534, "func": "void rose_stop_timer(struct sock *sk)\n{\n\tdel_timer(&rose_sk(sk)->timer);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2022-2318", "cwe_id": "CWE-416" }, { "id": 1534, "func": "void rose_stop_timer(struct sock *sk)\n{\n\tsk_stop_timer(sk, &rose_sk(sk)->timer);\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2022-2318", "cwe_id": "CWE-416" }, { "id": 556, "func": "static int append_key_value(smart_str* loc_name, HashTable* hash_arr, char* key_name)\n{\n\tzval**\tele_value\t= NULL;\n\n\tif(zend_hash_find(hash_arr , key_name , strlen(key_name) + 1 ,(void **)&ele_value ) == SUCCESS ) {\n\t\tif(Z_TYPE_PP(ele_value)!= IS_STRING ){\n\t\t\t/* element value is not a string */\n\t\t\treturn FAILURE;\n\t\t}\n\t\tif(strcmp(key_name, LOC_LANG_TAG) != 0 && \n\t\t strcmp(key_name, LOC_GRANDFATHERED_LANG_TAG)!=0 ) {\n\t\t\t/* not lang or grandfathered tag */\n\t\t\tsmart_str_appendl(loc_name, SEPARATOR , sizeof(SEPARATOR)-1);\n\t\t}\n\t\tsmart_str_appendl(loc_name, Z_STRVAL_PP(ele_value) , Z_STRLEN_PP(ele_value));\n\t\treturn SUCCESS;\n\t}\n\n\treturn LOC_NOT_FOUND;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2016-5093", "cwe_id": "CWE-125" }, { "id": 556, "func": "static int append_key_value(smart_str* loc_name, HashTable* hash_arr, char* key_name)\n{\n\tzval**\tele_value\t= NULL;\n\n\tif(zend_hash_find(hash_arr , key_name , strlen(key_name) + 1 ,(void **)&ele_value ) == SUCCESS ) {\n\t\tif(Z_TYPE_PP(ele_value)!= IS_STRING ){\n\t\t\t/* element value is not a string */\n\t\t\treturn FAILURE;\n\t\t}\n\t\tif(strcmp(key_name, LOC_LANG_TAG) != 0 &&\n\t\t strcmp(key_name, LOC_GRANDFATHERED_LANG_TAG)!=0 ) {\n\t\t\t/* not lang or grandfathered tag */\n\t\t\tsmart_str_appendl(loc_name, SEPARATOR , sizeof(SEPARATOR)-1);\n\t\t}\n\t\tsmart_str_appendl(loc_name, Z_STRVAL_PP(ele_value) , Z_STRLEN_PP(ele_value));\n\t\treturn SUCCESS;\n\t}\n\n\treturn LOC_NOT_FOUND;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2016-5093", "cwe_id": "CWE-125" }, { "id": 3216, "func": "static int vt_k_ioctl(struct tty_struct *tty, unsigned int cmd,\n\t\tunsigned long arg, bool perm)\n{\n\tstruct vc_data *vc = tty->driver_data;\n\tvoid __user *up = (void __user *)arg;\n\tunsigned int console = vc->vc_num;\n\tint ret;\n\n\tswitch (cmd) {\n\tcase KIOCSOUND:\n\t\tif (!perm)\n\t\t\treturn -EPERM;\n\t\t/*\n\t\t * The use of PIT_TICK_RATE is historic, it used to be\n\t\t * the platform-dependent CLOCK_TICK_RATE between 2.6.12\n\t\t * and 2.6.36, which was a minor but unfortunate ABI\n\t\t * change. kd_mksound is locked by the input layer.\n\t\t */\n\t\tif (arg)\n\t\t\targ = PIT_TICK_RATE / arg;\n\t\tkd_mksound(arg, 0);\n\t\tbreak;\n\n\tcase KDMKTONE:\n\t\tif (!perm)\n\t\t\treturn -EPERM;\n\t{\n\t\tunsigned int ticks, count;\n\n\t\t/*\n\t\t * Generate the tone for the appropriate number of ticks.\n\t\t * If the time is zero, turn off sound ourselves.\n\t\t */\n\t\tticks = msecs_to_jiffies((arg >> 16) & 0xffff);\n\t\tcount = ticks ? (arg & 0xffff) : 0;\n\t\tif (count)\n\t\t\tcount = PIT_TICK_RATE / count;\n\t\tkd_mksound(count, ticks);\n\t\tbreak;\n\t}\n\n\tcase KDGKBTYPE:\n\t\t/*\n\t\t * this is na\u00efve.\n\t\t */\n\t\treturn put_user(KB_101, (char __user *)arg);\n\n\t\t/*\n\t\t * These cannot be implemented on any machine that implements\n\t\t * ioperm() in user level (such as Alpha PCs) or not at all.\n\t\t *\n\t\t * XXX: you should never use these, just call ioperm directly..\n\t\t */\n#ifdef CONFIG_X86\n\tcase KDADDIO:\n\tcase KDDELIO:\n\t\t/*\n\t\t * KDADDIO and KDDELIO may be able to add ports beyond what\n\t\t * we reject here, but to be safe...\n\t\t *\n\t\t * These are locked internally via sys_ioperm\n\t\t */\n\t\tif (arg < GPFIRST || arg > GPLAST)\n\t\t\treturn -EINVAL;\n\n\t\treturn ksys_ioperm(arg, 1, (cmd == KDADDIO)) ? -ENXIO : 0;\n\n\tcase KDENABIO:\n\tcase KDDISABIO:\n\t\treturn ksys_ioperm(GPFIRST, GPNUM,\n\t\t\t\t (cmd == KDENABIO)) ? -ENXIO : 0;\n#endif\n\n\t/* Linux m68k/i386 interface for setting the keyboard delay/repeat rate */\n\n\tcase KDKBDREP:\n\t{\n\t\tstruct kbd_repeat kbrep;\n\n\t\tif (!capable(CAP_SYS_TTY_CONFIG))\n\t\t\treturn -EPERM;\n\n\t\tif (copy_from_user(&kbrep, up, sizeof(struct kbd_repeat)))\n\t\t\treturn -EFAULT;\n\n\t\tret = kbd_rate(&kbrep);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tif (copy_to_user(up, &kbrep, sizeof(struct kbd_repeat)))\n\t\t\treturn -EFAULT;\n\t\tbreak;\n\t}\n\n\tcase KDSETMODE:\n\t\tif (!perm)\n\t\t\treturn -EPERM;\n\n\t\treturn vt_kdsetmode(vc, arg);\n\n\tcase KDGETMODE:\n\t\treturn put_user(vc->vc_mode, (int __user *)arg);\n\n\tcase KDMAPDISP:\n\tcase KDUNMAPDISP:\n\t\t/*\n\t\t * these work like a combination of mmap and KDENABIO.\n\t\t * this could be easily finished.\n\t\t */\n\t\treturn -EINVAL;\n\n\tcase KDSKBMODE:\n\t\tif (!perm)\n\t\t\treturn -EPERM;\n\t\tret = vt_do_kdskbmode(console, arg);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\ttty_ldisc_flush(tty);\n\t\tbreak;\n\n\tcase KDGKBMODE:\n\t\treturn put_user(vt_do_kdgkbmode(console), (int __user *)arg);\n\n\t/* this could be folded into KDSKBMODE, but for compatibility\n\t reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */\n\tcase KDSKBMETA:\n\t\treturn vt_do_kdskbmeta(console, arg);\n\n\tcase KDGKBMETA:\n\t\t/* FIXME: should review whether this is worth locking */\n\t\treturn put_user(vt_do_kdgkbmeta(console), (int __user *)arg);\n\n\tcase KDGETKEYCODE:\n\tcase KDSETKEYCODE:\n\t\tif(!capable(CAP_SYS_TTY_CONFIG))\n\t\t\tperm = 0;\n\t\treturn vt_do_kbkeycode_ioctl(cmd, up, perm);\n\n\tcase KDGKBENT:\n\tcase KDSKBENT:\n\t\treturn vt_do_kdsk_ioctl(cmd, up, perm, console);\n\n\tcase KDGKBSENT:\n\tcase KDSKBSENT:\n\t\treturn vt_do_kdgkb_ioctl(cmd, up, perm);\n\n\t/* Diacritical processing. Handled in keyboard.c as it has\n\t to operate on the keyboard locks and structures */\n\tcase KDGKBDIACR:\n\tcase KDGKBDIACRUC:\n\tcase KDSKBDIACR:\n\tcase KDSKBDIACRUC:\n\t\treturn vt_do_diacrit(cmd, up, perm);\n\n\t/* the ioctls below read/set the flags usually shown in the leds */\n\t/* don't use them - they will go away without warning */\n\tcase KDGKBLED:\n\tcase KDSKBLED:\n\tcase KDGETLED:\n\tcase KDSETLED:\n\t\treturn vt_do_kdskled(console, cmd, arg, perm);\n\n\t/*\n\t * A process can indicate its willingness to accept signals\n\t * generated by pressing an appropriate key combination.\n\t * Thus, one can have a daemon that e.g. spawns a new console\n\t * upon a keypress and then changes to it.\n\t * See also the kbrequest field of inittab(5).\n\t */\n\tcase KDSIGACCEPT:\n\t\tif (!perm || !capable(CAP_KILL))\n\t\t\treturn -EPERM;\n\t\tif (!valid_signal(arg) || arg < 1 || arg == SIGKILL)\n\t\t\treturn -EINVAL;\n\n\t\tspin_lock_irq(&vt_spawn_con.lock);\n\t\tput_pid(vt_spawn_con.pid);\n\t\tvt_spawn_con.pid = get_pid(task_pid(current));\n\t\tvt_spawn_con.sig = arg;\n\t\tspin_unlock_irq(&vt_spawn_con.lock);\n\t\tbreak;\n\n\tcase KDFONTOP: {\n\t\tstruct console_font_op op;\n\n\t\tif (copy_from_user(&op, up, sizeof(op)))\n\t\t\treturn -EFAULT;\n\t\tif (!perm && op.op != KD_FONT_OP_GET)\n\t\t\treturn -EPERM;\n\t\tret = con_font_op(vc, &op);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tif (copy_to_user(up, &op, sizeof(op)))\n\t\t\treturn -EFAULT;\n\t\tbreak;\n\t}\n\n\tdefault:\n\t\treturn -ENOIOCTLCMD;\n\t}\n\n\treturn 0;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2021-3753", "cwe_id": "CWE-362" }, { "id": 3216, "func": "static int vt_k_ioctl(struct tty_struct *tty, unsigned int cmd,\n\t\tunsigned long arg, bool perm)\n{\n\tstruct vc_data *vc = tty->driver_data;\n\tvoid __user *up = (void __user *)arg;\n\tunsigned int console = vc->vc_num;\n\tint ret;\n\n\tswitch (cmd) {\n\tcase KIOCSOUND:\n\t\tif (!perm)\n\t\t\treturn -EPERM;\n\t\t/*\n\t\t * The use of PIT_TICK_RATE is historic, it used to be\n\t\t * the platform-dependent CLOCK_TICK_RATE between 2.6.12\n\t\t * and 2.6.36, which was a minor but unfortunate ABI\n\t\t * change. kd_mksound is locked by the input layer.\n\t\t */\n\t\tif (arg)\n\t\t\targ = PIT_TICK_RATE / arg;\n\t\tkd_mksound(arg, 0);\n\t\tbreak;\n\n\tcase KDMKTONE:\n\t\tif (!perm)\n\t\t\treturn -EPERM;\n\t{\n\t\tunsigned int ticks, count;\n\n\t\t/*\n\t\t * Generate the tone for the appropriate number of ticks.\n\t\t * If the time is zero, turn off sound ourselves.\n\t\t */\n\t\tticks = msecs_to_jiffies((arg >> 16) & 0xffff);\n\t\tcount = ticks ? (arg & 0xffff) : 0;\n\t\tif (count)\n\t\t\tcount = PIT_TICK_RATE / count;\n\t\tkd_mksound(count, ticks);\n\t\tbreak;\n\t}\n\n\tcase KDGKBTYPE:\n\t\t/*\n\t\t * this is na\u00efve.\n\t\t */\n\t\treturn put_user(KB_101, (char __user *)arg);\n\n\t\t/*\n\t\t * These cannot be implemented on any machine that implements\n\t\t * ioperm() in user level (such as Alpha PCs) or not at all.\n\t\t *\n\t\t * XXX: you should never use these, just call ioperm directly..\n\t\t */\n#ifdef CONFIG_X86\n\tcase KDADDIO:\n\tcase KDDELIO:\n\t\t/*\n\t\t * KDADDIO and KDDELIO may be able to add ports beyond what\n\t\t * we reject here, but to be safe...\n\t\t *\n\t\t * These are locked internally via sys_ioperm\n\t\t */\n\t\tif (arg < GPFIRST || arg > GPLAST)\n\t\t\treturn -EINVAL;\n\n\t\treturn ksys_ioperm(arg, 1, (cmd == KDADDIO)) ? -ENXIO : 0;\n\n\tcase KDENABIO:\n\tcase KDDISABIO:\n\t\treturn ksys_ioperm(GPFIRST, GPNUM,\n\t\t\t\t (cmd == KDENABIO)) ? -ENXIO : 0;\n#endif\n\n\t/* Linux m68k/i386 interface for setting the keyboard delay/repeat rate */\n\n\tcase KDKBDREP:\n\t{\n\t\tstruct kbd_repeat kbrep;\n\n\t\tif (!capable(CAP_SYS_TTY_CONFIG))\n\t\t\treturn -EPERM;\n\n\t\tif (copy_from_user(&kbrep, up, sizeof(struct kbd_repeat)))\n\t\t\treturn -EFAULT;\n\n\t\tret = kbd_rate(&kbrep);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tif (copy_to_user(up, &kbrep, sizeof(struct kbd_repeat)))\n\t\t\treturn -EFAULT;\n\t\tbreak;\n\t}\n\n\tcase KDSETMODE:\n\t\tif (!perm)\n\t\t\treturn -EPERM;\n\n\t\tconsole_lock();\n\t\tret = vt_kdsetmode(vc, arg);\n\t\tconsole_unlock();\n\t\treturn ret;\n\n\tcase KDGETMODE:\n\t\treturn put_user(vc->vc_mode, (int __user *)arg);\n\n\tcase KDMAPDISP:\n\tcase KDUNMAPDISP:\n\t\t/*\n\t\t * these work like a combination of mmap and KDENABIO.\n\t\t * this could be easily finished.\n\t\t */\n\t\treturn -EINVAL;\n\n\tcase KDSKBMODE:\n\t\tif (!perm)\n\t\t\treturn -EPERM;\n\t\tret = vt_do_kdskbmode(console, arg);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\ttty_ldisc_flush(tty);\n\t\tbreak;\n\n\tcase KDGKBMODE:\n\t\treturn put_user(vt_do_kdgkbmode(console), (int __user *)arg);\n\n\t/* this could be folded into KDSKBMODE, but for compatibility\n\t reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */\n\tcase KDSKBMETA:\n\t\treturn vt_do_kdskbmeta(console, arg);\n\n\tcase KDGKBMETA:\n\t\t/* FIXME: should review whether this is worth locking */\n\t\treturn put_user(vt_do_kdgkbmeta(console), (int __user *)arg);\n\n\tcase KDGETKEYCODE:\n\tcase KDSETKEYCODE:\n\t\tif(!capable(CAP_SYS_TTY_CONFIG))\n\t\t\tperm = 0;\n\t\treturn vt_do_kbkeycode_ioctl(cmd, up, perm);\n\n\tcase KDGKBENT:\n\tcase KDSKBENT:\n\t\treturn vt_do_kdsk_ioctl(cmd, up, perm, console);\n\n\tcase KDGKBSENT:\n\tcase KDSKBSENT:\n\t\treturn vt_do_kdgkb_ioctl(cmd, up, perm);\n\n\t/* Diacritical processing. Handled in keyboard.c as it has\n\t to operate on the keyboard locks and structures */\n\tcase KDGKBDIACR:\n\tcase KDGKBDIACRUC:\n\tcase KDSKBDIACR:\n\tcase KDSKBDIACRUC:\n\t\treturn vt_do_diacrit(cmd, up, perm);\n\n\t/* the ioctls below read/set the flags usually shown in the leds */\n\t/* don't use them - they will go away without warning */\n\tcase KDGKBLED:\n\tcase KDSKBLED:\n\tcase KDGETLED:\n\tcase KDSETLED:\n\t\treturn vt_do_kdskled(console, cmd, arg, perm);\n\n\t/*\n\t * A process can indicate its willingness to accept signals\n\t * generated by pressing an appropriate key combination.\n\t * Thus, one can have a daemon that e.g. spawns a new console\n\t * upon a keypress and then changes to it.\n\t * See also the kbrequest field of inittab(5).\n\t */\n\tcase KDSIGACCEPT:\n\t\tif (!perm || !capable(CAP_KILL))\n\t\t\treturn -EPERM;\n\t\tif (!valid_signal(arg) || arg < 1 || arg == SIGKILL)\n\t\t\treturn -EINVAL;\n\n\t\tspin_lock_irq(&vt_spawn_con.lock);\n\t\tput_pid(vt_spawn_con.pid);\n\t\tvt_spawn_con.pid = get_pid(task_pid(current));\n\t\tvt_spawn_con.sig = arg;\n\t\tspin_unlock_irq(&vt_spawn_con.lock);\n\t\tbreak;\n\n\tcase KDFONTOP: {\n\t\tstruct console_font_op op;\n\n\t\tif (copy_from_user(&op, up, sizeof(op)))\n\t\t\treturn -EFAULT;\n\t\tif (!perm && op.op != KD_FONT_OP_GET)\n\t\t\treturn -EPERM;\n\t\tret = con_font_op(vc, &op);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tif (copy_to_user(up, &op, sizeof(op)))\n\t\t\treturn -EFAULT;\n\t\tbreak;\n\t}\n\n\tdefault:\n\t\treturn -ENOIOCTLCMD;\n\t}\n\n\treturn 0;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2021-3753", "cwe_id": "CWE-362" }, { "id": 1444, "func": "int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)\n{\n\tstruct rose_neigh *rose_neigh, *new_neigh;\n\tstruct rose_route *rose_route;\n\tstruct rose_facilities_struct facilities;\n\trose_address *src_addr, *dest_addr;\n\tstruct sock *sk;\n\tunsigned short frametype;\n\tunsigned int lci, new_lci;\n\tunsigned char cause, diagnostic;\n\tstruct net_device *dev;\n\tint len, res = 0;\n\tchar buf[11];\n\n#if 0\n\tif (call_in_firewall(PF_ROSE, skb->dev, skb->data, NULL, &skb) != FW_ACCEPT)\n\t\treturn res;\n#endif\n\n\tframetype = skb->data[2];\n\tlci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);\n\tsrc_addr = (rose_address *)(skb->data + 9);\n\tdest_addr = (rose_address *)(skb->data + 4);\n\n\tspin_lock_bh(&rose_neigh_list_lock);\n\tspin_lock_bh(&rose_route_list_lock);\n\n\trose_neigh = rose_neigh_list;\n\twhile (rose_neigh != NULL) {\n\t\tif (ax25cmp(&ax25->dest_addr, &rose_neigh->callsign) == 0 &&\n\t\t ax25->ax25_dev->dev == rose_neigh->dev)\n\t\t\tbreak;\n\t\trose_neigh = rose_neigh->next;\n\t}\n\n\tif (rose_neigh == NULL) {\n\t\tprintk(\"rose_route : unknown neighbour or device %s\\n\",\n\t\t ax2asc(buf, &ax25->dest_addr));\n\t\tgoto out;\n\t}\n\n\t/*\n\t *\tObviously the link is working, halt the ftimer.\n\t */\n\trose_stop_ftimer(rose_neigh);\n\n\t/*\n\t *\tLCI of zero is always for us, and its always a restart\n\t * \tframe.\n\t */\n\tif (lci == 0) {\n\t\trose_link_rx_restart(skb, rose_neigh, frametype);\n\t\tgoto out;\n\t}\n\n\t/*\n\t *\tFind an existing socket.\n\t */\n\tif ((sk = rose_find_socket(lci, rose_neigh)) != NULL) {\n\t\tif (frametype == ROSE_CALL_REQUEST) {\n\t\t\tstruct rose_sock *rose = rose_sk(sk);\n\n\t\t\t/* Remove an existing unused socket */\n\t\t\trose_clear_queues(sk);\n\t\t\trose->cause\t = ROSE_NETWORK_CONGESTION;\n\t\t\trose->diagnostic = 0;\n\t\t\trose->neighbour->use--;\n\t\t\trose->neighbour\t = NULL;\n\t\t\trose->lci\t = 0;\n\t\t\trose->state\t = ROSE_STATE_0;\n\t\t\tsk->sk_state\t = TCP_CLOSE;\n\t\t\tsk->sk_err\t = 0;\n\t\t\tsk->sk_shutdown\t |= SEND_SHUTDOWN;\n\t\t\tif (!sock_flag(sk, SOCK_DEAD)) {\n\t\t\t\tsk->sk_state_change(sk);\n\t\t\t\tsock_set_flag(sk, SOCK_DEAD);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tskb_reset_transport_header(skb);\n\t\t\tres = rose_process_rx_frame(sk, skb);\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\t/*\n\t *\tIs is a Call Request and is it for us ?\n\t */\n\tif (frametype == ROSE_CALL_REQUEST)\n\t\tif ((dev = rose_dev_get(dest_addr)) != NULL) {\n\t\t\tres = rose_rx_call_request(skb, dev, rose_neigh, lci);\n\t\t\tdev_put(dev);\n\t\t\tgoto out;\n\t\t}\n\n\tif (!sysctl_rose_routing_control) {\n\t\trose_transmit_clear_request(rose_neigh, lci, ROSE_NOT_OBTAINABLE, 0);\n\t\tgoto out;\n\t}\n\n\t/*\n\t *\tRoute it to the next in line if we have an entry for it.\n\t */\n\trose_route = rose_route_list;\n\twhile (rose_route != NULL) {\n\t\tif (rose_route->lci1 == lci &&\n\t\t rose_route->neigh1 == rose_neigh) {\n\t\t\tif (frametype == ROSE_CALL_REQUEST) {\n\t\t\t\t/* F6FBB - Remove an existing unused route */\n\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tbreak;\n\t\t\t} else if (rose_route->neigh2 != NULL) {\n\t\t\t\tskb->data[0] &= 0xF0;\n\t\t\t\tskb->data[0] |= (rose_route->lci2 >> 8) & 0x0F;\n\t\t\t\tskb->data[1] = (rose_route->lci2 >> 0) & 0xFF;\n\t\t\t\trose_transmit_link(skb, rose_route->neigh2);\n\t\t\t\tif (frametype == ROSE_CLEAR_CONFIRMATION)\n\t\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tres = 1;\n\t\t\t\tgoto out;\n\t\t\t} else {\n\t\t\t\tif (frametype == ROSE_CLEAR_CONFIRMATION)\n\t\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t\tif (rose_route->lci2 == lci &&\n\t\t rose_route->neigh2 == rose_neigh) {\n\t\t\tif (frametype == ROSE_CALL_REQUEST) {\n\t\t\t\t/* F6FBB - Remove an existing unused route */\n\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tbreak;\n\t\t\t} else if (rose_route->neigh1 != NULL) {\n\t\t\t\tskb->data[0] &= 0xF0;\n\t\t\t\tskb->data[0] |= (rose_route->lci1 >> 8) & 0x0F;\n\t\t\t\tskb->data[1] = (rose_route->lci1 >> 0) & 0xFF;\n\t\t\t\trose_transmit_link(skb, rose_route->neigh1);\n\t\t\t\tif (frametype == ROSE_CLEAR_CONFIRMATION)\n\t\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tres = 1;\n\t\t\t\tgoto out;\n\t\t\t} else {\n\t\t\t\tif (frametype == ROSE_CLEAR_CONFIRMATION)\n\t\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t\trose_route = rose_route->next;\n\t}\n\n\t/*\n\t *\tWe know that:\n\t *\t1. The frame isn't for us,\n\t *\t2. It isn't \"owned\" by any existing route.\n\t */\n\tif (frametype != ROSE_CALL_REQUEST) {\t/* XXX */\n\t\tres = 0;\n\t\tgoto out;\n\t}\n\n\tlen = (((skb->data[3] >> 4) & 0x0F) + 1) >> 1;\n\tlen += (((skb->data[3] >> 0) & 0x0F) + 1) >> 1;\n\n\tmemset(&facilities, 0x00, sizeof(struct rose_facilities_struct));\n\n\tif (!rose_parse_facilities(skb->data + len + 4, &facilities)) {\n\t\trose_transmit_clear_request(rose_neigh, lci, ROSE_INVALID_FACILITY, 76);\n\t\tgoto out;\n\t}\n\n\t/*\n\t *\tCheck for routing loops.\n\t */\n\trose_route = rose_route_list;\n\twhile (rose_route != NULL) {\n\t\tif (rose_route->rand == facilities.rand &&\n\t\t rosecmp(src_addr, &rose_route->src_addr) == 0 &&\n\t\t ax25cmp(&facilities.dest_call, &rose_route->src_call) == 0 &&\n\t\t ax25cmp(&facilities.source_call, &rose_route->dest_call) == 0) {\n\t\t\trose_transmit_clear_request(rose_neigh, lci, ROSE_NOT_OBTAINABLE, 120);\n\t\t\tgoto out;\n\t\t}\n\t\trose_route = rose_route->next;\n\t}\n\n\tif ((new_neigh = rose_get_neigh(dest_addr, &cause, &diagnostic, 1)) == NULL) {\n\t\trose_transmit_clear_request(rose_neigh, lci, cause, diagnostic);\n\t\tgoto out;\n\t}\n\n\tif ((new_lci = rose_new_lci(new_neigh)) == 0) {\n\t\trose_transmit_clear_request(rose_neigh, lci, ROSE_NETWORK_CONGESTION, 71);\n\t\tgoto out;\n\t}\n\n\tif ((rose_route = kmalloc(sizeof(*rose_route), GFP_ATOMIC)) == NULL) {\n\t\trose_transmit_clear_request(rose_neigh, lci, ROSE_NETWORK_CONGESTION, 120);\n\t\tgoto out;\n\t}\n\n\trose_route->lci1 = lci;\n\trose_route->src_addr = *src_addr;\n\trose_route->dest_addr = *dest_addr;\n\trose_route->src_call = facilities.dest_call;\n\trose_route->dest_call = facilities.source_call;\n\trose_route->rand = facilities.rand;\n\trose_route->neigh1 = rose_neigh;\n\trose_route->lci2 = new_lci;\n\trose_route->neigh2 = new_neigh;\n\n\trose_route->neigh1->use++;\n\trose_route->neigh2->use++;\n\n\trose_route->next = rose_route_list;\n\trose_route_list = rose_route;\n\n\tskb->data[0] &= 0xF0;\n\tskb->data[0] |= (rose_route->lci2 >> 8) & 0x0F;\n\tskb->data[1] = (rose_route->lci2 >> 0) & 0xFF;\n\n\trose_transmit_link(skb, rose_route->neigh2);\n\tres = 1;\n\nout:\n\tspin_unlock_bh(&rose_route_list_lock);\n\tspin_unlock_bh(&rose_neigh_list_lock);\n\n\treturn res;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2011-4914", "cwe_id": "CWE-20" }, { "id": 1444, "func": "int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)\n{\n\tstruct rose_neigh *rose_neigh, *new_neigh;\n\tstruct rose_route *rose_route;\n\tstruct rose_facilities_struct facilities;\n\trose_address *src_addr, *dest_addr;\n\tstruct sock *sk;\n\tunsigned short frametype;\n\tunsigned int lci, new_lci;\n\tunsigned char cause, diagnostic;\n\tstruct net_device *dev;\n\tint res = 0;\n\tchar buf[11];\n\n#if 0\n\tif (call_in_firewall(PF_ROSE, skb->dev, skb->data, NULL, &skb) != FW_ACCEPT)\n\t\treturn res;\n#endif\n\n\tif (skb->len < ROSE_MIN_LEN)\n\t\treturn res;\n\tframetype = skb->data[2];\n\tlci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);\n\tif (frametype == ROSE_CALL_REQUEST &&\n\t (skb->len <= ROSE_CALL_REQ_FACILITIES_OFF ||\n\t skb->data[ROSE_CALL_REQ_ADDR_LEN_OFF] !=\n\t ROSE_CALL_REQ_ADDR_LEN_VAL))\n\t\treturn res;\n\tsrc_addr = (rose_address *)(skb->data + ROSE_CALL_REQ_SRC_ADDR_OFF);\n\tdest_addr = (rose_address *)(skb->data + ROSE_CALL_REQ_DEST_ADDR_OFF);\n\n\tspin_lock_bh(&rose_neigh_list_lock);\n\tspin_lock_bh(&rose_route_list_lock);\n\n\trose_neigh = rose_neigh_list;\n\twhile (rose_neigh != NULL) {\n\t\tif (ax25cmp(&ax25->dest_addr, &rose_neigh->callsign) == 0 &&\n\t\t ax25->ax25_dev->dev == rose_neigh->dev)\n\t\t\tbreak;\n\t\trose_neigh = rose_neigh->next;\n\t}\n\n\tif (rose_neigh == NULL) {\n\t\tprintk(\"rose_route : unknown neighbour or device %s\\n\",\n\t\t ax2asc(buf, &ax25->dest_addr));\n\t\tgoto out;\n\t}\n\n\t/*\n\t *\tObviously the link is working, halt the ftimer.\n\t */\n\trose_stop_ftimer(rose_neigh);\n\n\t/*\n\t *\tLCI of zero is always for us, and its always a restart\n\t * \tframe.\n\t */\n\tif (lci == 0) {\n\t\trose_link_rx_restart(skb, rose_neigh, frametype);\n\t\tgoto out;\n\t}\n\n\t/*\n\t *\tFind an existing socket.\n\t */\n\tif ((sk = rose_find_socket(lci, rose_neigh)) != NULL) {\n\t\tif (frametype == ROSE_CALL_REQUEST) {\n\t\t\tstruct rose_sock *rose = rose_sk(sk);\n\n\t\t\t/* Remove an existing unused socket */\n\t\t\trose_clear_queues(sk);\n\t\t\trose->cause\t = ROSE_NETWORK_CONGESTION;\n\t\t\trose->diagnostic = 0;\n\t\t\trose->neighbour->use--;\n\t\t\trose->neighbour\t = NULL;\n\t\t\trose->lci\t = 0;\n\t\t\trose->state\t = ROSE_STATE_0;\n\t\t\tsk->sk_state\t = TCP_CLOSE;\n\t\t\tsk->sk_err\t = 0;\n\t\t\tsk->sk_shutdown\t |= SEND_SHUTDOWN;\n\t\t\tif (!sock_flag(sk, SOCK_DEAD)) {\n\t\t\t\tsk->sk_state_change(sk);\n\t\t\t\tsock_set_flag(sk, SOCK_DEAD);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tskb_reset_transport_header(skb);\n\t\t\tres = rose_process_rx_frame(sk, skb);\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\t/*\n\t *\tIs is a Call Request and is it for us ?\n\t */\n\tif (frametype == ROSE_CALL_REQUEST)\n\t\tif ((dev = rose_dev_get(dest_addr)) != NULL) {\n\t\t\tres = rose_rx_call_request(skb, dev, rose_neigh, lci);\n\t\t\tdev_put(dev);\n\t\t\tgoto out;\n\t\t}\n\n\tif (!sysctl_rose_routing_control) {\n\t\trose_transmit_clear_request(rose_neigh, lci, ROSE_NOT_OBTAINABLE, 0);\n\t\tgoto out;\n\t}\n\n\t/*\n\t *\tRoute it to the next in line if we have an entry for it.\n\t */\n\trose_route = rose_route_list;\n\twhile (rose_route != NULL) {\n\t\tif (rose_route->lci1 == lci &&\n\t\t rose_route->neigh1 == rose_neigh) {\n\t\t\tif (frametype == ROSE_CALL_REQUEST) {\n\t\t\t\t/* F6FBB - Remove an existing unused route */\n\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tbreak;\n\t\t\t} else if (rose_route->neigh2 != NULL) {\n\t\t\t\tskb->data[0] &= 0xF0;\n\t\t\t\tskb->data[0] |= (rose_route->lci2 >> 8) & 0x0F;\n\t\t\t\tskb->data[1] = (rose_route->lci2 >> 0) & 0xFF;\n\t\t\t\trose_transmit_link(skb, rose_route->neigh2);\n\t\t\t\tif (frametype == ROSE_CLEAR_CONFIRMATION)\n\t\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tres = 1;\n\t\t\t\tgoto out;\n\t\t\t} else {\n\t\t\t\tif (frametype == ROSE_CLEAR_CONFIRMATION)\n\t\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t\tif (rose_route->lci2 == lci &&\n\t\t rose_route->neigh2 == rose_neigh) {\n\t\t\tif (frametype == ROSE_CALL_REQUEST) {\n\t\t\t\t/* F6FBB - Remove an existing unused route */\n\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tbreak;\n\t\t\t} else if (rose_route->neigh1 != NULL) {\n\t\t\t\tskb->data[0] &= 0xF0;\n\t\t\t\tskb->data[0] |= (rose_route->lci1 >> 8) & 0x0F;\n\t\t\t\tskb->data[1] = (rose_route->lci1 >> 0) & 0xFF;\n\t\t\t\trose_transmit_link(skb, rose_route->neigh1);\n\t\t\t\tif (frametype == ROSE_CLEAR_CONFIRMATION)\n\t\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tres = 1;\n\t\t\t\tgoto out;\n\t\t\t} else {\n\t\t\t\tif (frametype == ROSE_CLEAR_CONFIRMATION)\n\t\t\t\t\trose_remove_route(rose_route);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t}\n\t\trose_route = rose_route->next;\n\t}\n\n\t/*\n\t *\tWe know that:\n\t *\t1. The frame isn't for us,\n\t *\t2. It isn't \"owned\" by any existing route.\n\t */\n\tif (frametype != ROSE_CALL_REQUEST) {\t/* XXX */\n\t\tres = 0;\n\t\tgoto out;\n\t}\n\n\tmemset(&facilities, 0x00, sizeof(struct rose_facilities_struct));\n\n\tif (!rose_parse_facilities(skb->data + ROSE_CALL_REQ_FACILITIES_OFF,\n\t\t\t\t skb->len - ROSE_CALL_REQ_FACILITIES_OFF,\n\t\t\t\t &facilities)) {\n\t\trose_transmit_clear_request(rose_neigh, lci, ROSE_INVALID_FACILITY, 76);\n\t\tgoto out;\n\t}\n\n\t/*\n\t *\tCheck for routing loops.\n\t */\n\trose_route = rose_route_list;\n\twhile (rose_route != NULL) {\n\t\tif (rose_route->rand == facilities.rand &&\n\t\t rosecmp(src_addr, &rose_route->src_addr) == 0 &&\n\t\t ax25cmp(&facilities.dest_call, &rose_route->src_call) == 0 &&\n\t\t ax25cmp(&facilities.source_call, &rose_route->dest_call) == 0) {\n\t\t\trose_transmit_clear_request(rose_neigh, lci, ROSE_NOT_OBTAINABLE, 120);\n\t\t\tgoto out;\n\t\t}\n\t\trose_route = rose_route->next;\n\t}\n\n\tif ((new_neigh = rose_get_neigh(dest_addr, &cause, &diagnostic, 1)) == NULL) {\n\t\trose_transmit_clear_request(rose_neigh, lci, cause, diagnostic);\n\t\tgoto out;\n\t}\n\n\tif ((new_lci = rose_new_lci(new_neigh)) == 0) {\n\t\trose_transmit_clear_request(rose_neigh, lci, ROSE_NETWORK_CONGESTION, 71);\n\t\tgoto out;\n\t}\n\n\tif ((rose_route = kmalloc(sizeof(*rose_route), GFP_ATOMIC)) == NULL) {\n\t\trose_transmit_clear_request(rose_neigh, lci, ROSE_NETWORK_CONGESTION, 120);\n\t\tgoto out;\n\t}\n\n\trose_route->lci1 = lci;\n\trose_route->src_addr = *src_addr;\n\trose_route->dest_addr = *dest_addr;\n\trose_route->src_call = facilities.dest_call;\n\trose_route->dest_call = facilities.source_call;\n\trose_route->rand = facilities.rand;\n\trose_route->neigh1 = rose_neigh;\n\trose_route->lci2 = new_lci;\n\trose_route->neigh2 = new_neigh;\n\n\trose_route->neigh1->use++;\n\trose_route->neigh2->use++;\n\n\trose_route->next = rose_route_list;\n\trose_route_list = rose_route;\n\n\tskb->data[0] &= 0xF0;\n\tskb->data[0] |= (rose_route->lci2 >> 8) & 0x0F;\n\tskb->data[1] = (rose_route->lci2 >> 0) & 0xFF;\n\n\trose_transmit_link(skb, rose_route->neigh2);\n\tres = 1;\n\nout:\n\tspin_unlock_bh(&rose_route_list_lock);\n\tspin_unlock_bh(&rose_neigh_list_lock);\n\n\treturn res;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2011-4914", "cwe_id": "CWE-20" }, { "id": 2246, "func": "zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)\n{\n\tzend_lex_state original_lex_state;\n\tzend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array));\n\tzend_op_array *original_active_op_array = CG(active_op_array);\n\tzend_op_array *retval;\n\tzval tmp;\n\tint compiler_result;\n\tzend_bool original_in_compilation = CG(in_compilation);\n\n\tif (source_string->value.str.len==0) {\n\t\tefree(op_array);\n\t\treturn NULL;\n\t}\n\n\tCG(in_compilation) = 1;\n\n\ttmp = *source_string;\n\tzval_copy_ctor(&tmp);\n\tconvert_to_string(&tmp);\n\tsource_string = &tmp;\n\n\tzend_save_lexical_state(&original_lex_state TSRMLS_CC);\n\tif (zend_prepare_string_for_scanning(source_string, filename TSRMLS_CC)==FAILURE) {\n\t\tefree(op_array);\n\t\tretval = NULL;\n\t} else {\n\t\tzend_bool orig_interactive = CG(interactive);\n\n\t\tCG(interactive) = 0;\n\t\tinit_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE TSRMLS_CC);\n\t\tCG(interactive) = orig_interactive;\n\t\tCG(active_op_array) = op_array;\n\t\tzend_stack_push(&CG(context_stack), (void *) &CG(context), sizeof(CG(context)));\n\t\tzend_init_compiler_context(TSRMLS_C);\n\t\tBEGIN(ST_IN_SCRIPTING);\n\t\tcompiler_result = zendparse(TSRMLS_C);\n\n\t\tif (SCNG(script_filtered)) {\n\t\t\tefree(SCNG(script_filtered));\n\t\t\tSCNG(script_filtered) = NULL;\n\t\t}\n\n\t\tif (compiler_result==1) {\n\t\t\tCG(active_op_array) = original_active_op_array;\n\t\t\tCG(unclean_shutdown)=1;\n\t\t\tdestroy_op_array(op_array TSRMLS_CC);\n\t\t\tefree(op_array);\n\t\t\tretval = NULL;\n\t\t} else {\n\t\t\tzend_do_return(NULL, 0 TSRMLS_CC);\n\t\t\tCG(active_op_array) = original_active_op_array;\n\t\t\tpass_two(op_array TSRMLS_CC);\n\t\t\tzend_release_labels(0 TSRMLS_CC);\n\t\t\tretval = op_array;\n\t\t}\n\t}\n\tzend_restore_lexical_state(&original_lex_state TSRMLS_CC);\n\tzval_dtor(&tmp);\n\tCG(in_compilation) = original_in_compilation;\n\treturn retval;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-3735", "cwe_id": "CWE-20" }, { "id": 2246, "func": "zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)\n{\n\tzend_lex_state original_lex_state;\n\tzend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array));\n\tzend_op_array *original_active_op_array = CG(active_op_array);\n\tzend_op_array *retval;\n\tzval tmp;\n\tint compiler_result;\n\tzend_bool original_in_compilation = CG(in_compilation);\n\n\tif (source_string->value.str.len==0) {\n\t\tefree(op_array);\n\t\treturn NULL;\n\t}\n\n\tCG(in_compilation) = 1;\n\n\ttmp = *source_string;\n\tzval_copy_ctor(&tmp);\n\tconvert_to_string(&tmp);\n\tsource_string = &tmp;\n\n\tzend_save_lexical_state(&original_lex_state TSRMLS_CC);\n\tif (zend_prepare_string_for_scanning(source_string, filename TSRMLS_CC)==FAILURE) {\n\t\tefree(op_array);\n\t\tretval = NULL;\n\t} else {\n\t\tzend_bool orig_interactive = CG(interactive);\n\n\t\tCG(interactive) = 0;\n\t\tinit_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE TSRMLS_CC);\n\t\tCG(interactive) = orig_interactive;\n\t\tCG(active_op_array) = op_array;\n\t\tzend_stack_push(&CG(context_stack), (void *) &CG(context), sizeof(CG(context)));\n\t\tzend_init_compiler_context(TSRMLS_C);\n\t\tBEGIN(ST_IN_SCRIPTING);\n\t\tcompiler_result = zendparse(TSRMLS_C);\n\n\t\tif (SCNG(script_filtered)) {\n\t\t\tefree(SCNG(script_filtered));\n\t\t\tSCNG(script_filtered) = NULL;\n\t\t}\n\n\t\tif (compiler_result != 0) {\n\t\t\tCG(active_op_array) = original_active_op_array;\n\t\t\tCG(unclean_shutdown)=1;\n\t\t\tdestroy_op_array(op_array TSRMLS_CC);\n\t\t\tefree(op_array);\n\t\t\tretval = NULL;\n\t\t} else {\n\t\t\tzend_do_return(NULL, 0 TSRMLS_CC);\n\t\t\tCG(active_op_array) = original_active_op_array;\n\t\t\tpass_two(op_array TSRMLS_CC);\n\t\t\tzend_release_labels(0 TSRMLS_CC);\n\t\t\tretval = op_array;\n\t\t}\n\t}\n\tzend_restore_lexical_state(&original_lex_state TSRMLS_CC);\n\tzval_dtor(&tmp);\n\tCG(in_compilation) = original_in_compilation;\n\treturn retval;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-3735", "cwe_id": "CWE-20" }, { "id": 2612, "func": "decode_unicode_with_escapes(struct compiling *c, const node *n, const char *s,\n size_t len)\n{\n PyObject *u;\n char *buf;\n char *p;\n const char *end;\n\n /* check for integer overflow */\n if (len > SIZE_MAX / 6)\n return NULL;\n /* \"\u00e4\" (2 bytes) may become \"\\U000000E4\" (10 bytes), or 1:5\n \"\\\u00e4\" (3 bytes) may become \"\\u005c\\U000000E4\" (16 bytes), or ~1:6 */\n u = PyBytes_FromStringAndSize((char *)NULL, len * 6);\n if (u == NULL)\n return NULL;\n p = buf = PyBytes_AsString(u);\n end = s + len;\n while (s < end) {\n if (*s == '\\\\') {\n *p++ = *s++;\n if (*s & 0x80) {\n strcpy(p, \"u005c\");\n p += 5;\n }\n }\n if (*s & 0x80) { /* XXX inefficient */\n PyObject *w;\n int kind;\n void *data;\n Py_ssize_t len, i;\n w = decode_utf8(c, &s, end);\n if (w == NULL) {\n Py_DECREF(u);\n return NULL;\n }\n kind = PyUnicode_KIND(w);\n data = PyUnicode_DATA(w);\n len = PyUnicode_GET_LENGTH(w);\n for (i = 0; i < len; i++) {\n Py_UCS4 chr = PyUnicode_READ(kind, data, i);\n sprintf(p, \"\\\\U%08x\", chr);\n p += 10;\n }\n /* Should be impossible to overflow */\n assert(p - buf <= Py_SIZE(u));\n Py_DECREF(w);\n } else {\n *p++ = *s++;\n }\n }\n len = p - buf;\n s = buf;\n\n return PyUnicode_DecodeUnicodeEscape(s, len, NULL);\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2612, "func": "decode_unicode_with_escapes(struct compiling *c, const node *n, const char *s,\n size_t len)\n{\n PyObject *v, *u;\n char *buf;\n char *p;\n const char *end;\n const char *first_invalid_escape;\n\n /* check for integer overflow */\n if (len > SIZE_MAX / 6)\n return NULL;\n /* \"\u00e4\" (2 bytes) may become \"\\U000000E4\" (10 bytes), or 1:5\n \"\\\u00e4\" (3 bytes) may become \"\\u005c\\U000000E4\" (16 bytes), or ~1:6 */\n u = PyBytes_FromStringAndSize((char *)NULL, len * 6);\n if (u == NULL)\n return NULL;\n p = buf = PyBytes_AsString(u);\n end = s + len;\n while (s < end) {\n if (*s == '\\\\') {\n *p++ = *s++;\n if (s >= end || *s & 0x80) {\n strcpy(p, \"u005c\");\n p += 5;\n if (s >= end)\n break;\n }\n }\n if (*s & 0x80) { /* XXX inefficient */\n PyObject *w;\n int kind;\n void *data;\n Py_ssize_t len, i;\n w = decode_utf8(c, &s, end);\n if (w == NULL) {\n Py_DECREF(u);\n return NULL;\n }\n kind = PyUnicode_KIND(w);\n data = PyUnicode_DATA(w);\n len = PyUnicode_GET_LENGTH(w);\n for (i = 0; i < len; i++) {\n Py_UCS4 chr = PyUnicode_READ(kind, data, i);\n sprintf(p, \"\\\\U%08x\", chr);\n p += 10;\n }\n /* Should be impossible to overflow */\n assert(p - buf <= PyBytes_GET_SIZE(u));\n Py_DECREF(w);\n } else {\n *p++ = *s++;\n }\n }\n len = p - buf;\n s = buf;\n\n v = _PyUnicode_DecodeUnicodeEscape(s, len, NULL, &first_invalid_escape);\n\n if (v != NULL && first_invalid_escape != NULL) {\n if (warn_invalid_escape_sequence(c, n, *first_invalid_escape) < 0) {\n /* We have not decref u before because first_invalid_escape points\n inside u. */\n Py_XDECREF(u);\n Py_DECREF(v);\n return NULL;\n }\n }\n Py_XDECREF(u);\n return v;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2019-19274", "cwe_id": "CWE-125" }, { "id": 2832, "func": "\nstatic void __skb_complete_tx_timestamp(struct sk_buff *skb,\n\t\t\t\t\tstruct sock *sk,\n\t\t\t\t\tint tstype)\n{\n\tstruct sock_exterr_skb *serr;\n\tint err;\n\n\tserr = SKB_EXT_ERR(skb);\n\tmemset(serr, 0, sizeof(*serr));\n\tserr->ee.ee_errno = ENOMSG;\n\tserr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING;\n\tserr->ee.ee_info = tstype;\n\tif (sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID) {\n\t\tserr->ee.ee_data = skb_shinfo(skb)->tskey;\n\t\tif (sk->sk_protocol == IPPROTO_TCP &&\n\t\t sk->sk_type == SOCK_STREAM)\n\t\t\tserr->ee.ee_data -= sk->sk_tskey;\n\t}\n\n\terr = sock_queue_err_skb(sk, skb);\n\n\tif (err)\n\t\tkfree_skb(skb);", "label": 0, "text_label": "benign", "cve_id": "CVE-2017-7277", "cwe_id": "CWE-125" }, { "id": 2832, "func": "\nstatic void __skb_complete_tx_timestamp(struct sk_buff *skb,\n\t\t\t\t\tstruct sock *sk,\n\t\t\t\t\tint tstype,\n\t\t\t\t\tbool opt_stats)\n{\n\tstruct sock_exterr_skb *serr;\n\tint err;\n\n\tBUILD_BUG_ON(sizeof(struct sock_exterr_skb) > sizeof(skb->cb));\n\n\tserr = SKB_EXT_ERR(skb);\n\tmemset(serr, 0, sizeof(*serr));\n\tserr->ee.ee_errno = ENOMSG;\n\tserr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING;\n\tserr->ee.ee_info = tstype;\n\tserr->opt_stats = opt_stats;\n\tif (sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID) {\n\t\tserr->ee.ee_data = skb_shinfo(skb)->tskey;\n\t\tif (sk->sk_protocol == IPPROTO_TCP &&\n\t\t sk->sk_type == SOCK_STREAM)\n\t\t\tserr->ee.ee_data -= sk->sk_tskey;\n\t}\n\n\terr = sock_queue_err_skb(sk, skb);\n\n\tif (err)\n\t\tkfree_skb(skb);", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2017-7277", "cwe_id": "CWE-125" }, { "id": 1181, "func": "static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)\n{\n\tint i;\n\tunsigned char max_level = 0;\n\tint unix_sock_count = 0;\n\n\tfor (i = scm->fp->count - 1; i >= 0; i--) {\n\t\tstruct sock *sk = unix_get_socket(scm->fp->fp[i]);\n\n\t\tif (sk) {\n\t\t\tunix_sock_count++;\n\t\t\tmax_level = max(max_level,\n\t\t\t\t\tunix_sk(sk)->recursion_level);\n\t\t}\n\t}\n\tif (unlikely(max_level > MAX_RECURSION_LEVEL))\n\t\treturn -ETOOMANYREFS;\n\n\t/*\n\t * Need to duplicate file references for the sake of garbage\n\t * collection. Otherwise a socket in the fps might become a\n\t * candidate for GC while the skb is not yet queued.\n\t */\n\tUNIXCB(skb).fp = scm_fp_dup(scm->fp);\n\tif (!UNIXCB(skb).fp)\n\t\treturn -ENOMEM;\n\n\tif (unix_sock_count) {\n\t\tfor (i = scm->fp->count - 1; i >= 0; i--)\n\t\t\tunix_inflight(scm->fp->fp[i]);\n\t}\n\treturn max_level;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2013-4312", "cwe_id": "CWE-119" }, { "id": 1181, "func": "static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)\n{\n\tint i;\n\tunsigned char max_level = 0;\n\tint unix_sock_count = 0;\n\n\tif (too_many_unix_fds(current))\n\t\treturn -ETOOMANYREFS;\n\n\tfor (i = scm->fp->count - 1; i >= 0; i--) {\n\t\tstruct sock *sk = unix_get_socket(scm->fp->fp[i]);\n\n\t\tif (sk) {\n\t\t\tunix_sock_count++;\n\t\t\tmax_level = max(max_level,\n\t\t\t\t\tunix_sk(sk)->recursion_level);\n\t\t}\n\t}\n\tif (unlikely(max_level > MAX_RECURSION_LEVEL))\n\t\treturn -ETOOMANYREFS;\n\n\t/*\n\t * Need to duplicate file references for the sake of garbage\n\t * collection. Otherwise a socket in the fps might become a\n\t * candidate for GC while the skb is not yet queued.\n\t */\n\tUNIXCB(skb).fp = scm_fp_dup(scm->fp);\n\tif (!UNIXCB(skb).fp)\n\t\treturn -ENOMEM;\n\n\tfor (i = scm->fp->count - 1; i >= 0; i--)\n\t\tunix_inflight(scm->fp->fp[i]);\n\treturn max_level;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2013-4312", "cwe_id": "CWE-119" }, { "id": 701, "func": "ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,\n\t\t\tstruct ext4_map_blocks *map,\n\t\t\tstruct ext4_ext_path *path, int flags,\n\t\t\tunsigned int allocated, ext4_fsblk_t newblock)\n{\n\tint ret = 0;\n\tint err = 0;\n\text4_io_end_t *io = ext4_inode_aio(inode);\n\n\text_debug(\"ext4_ext_handle_uninitialized_extents: inode %lu, logical \"\n\t\t \"block %llu, max_blocks %u, flags %x, allocated %u\\n\",\n\t\t inode->i_ino, (unsigned long long)map->m_lblk, map->m_len,\n\t\t flags, allocated);\n\text4_ext_show_leaf(inode, path);\n\n\ttrace_ext4_ext_handle_uninitialized_extents(inode, map, allocated,\n\t\t\t\t\t\t newblock);\n\n\t/* get_block() before submit the IO, split the extent */\n\tif ((flags & EXT4_GET_BLOCKS_PRE_IO)) {\n\t\tret = ext4_split_unwritten_extents(handle, inode, map,\n\t\t\t\t\t\t path, flags);\n\t\tif (ret <= 0)\n\t\t\tgoto out;\n\t\t/*\n\t\t * Flag the inode(non aio case) or end_io struct (aio case)\n\t\t * that this IO needs to conversion to written when IO is\n\t\t * completed\n\t\t */\n\t\tif (io)\n\t\t\text4_set_io_unwritten_flag(inode, io);\n\t\telse\n\t\t\text4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN);\n\t\tif (ext4_should_dioread_nolock(inode))\n\t\t\tmap->m_flags |= EXT4_MAP_UNINIT;\n\t\tgoto out;\n\t}\n\t/* IO end_io complete, convert the filled extent to written */\n\tif ((flags & EXT4_GET_BLOCKS_CONVERT)) {\n\t\tret = ext4_convert_unwritten_extents_endio(handle, inode,\n\t\t\t\t\t\t\tpath);\n\t\tif (ret >= 0) {\n\t\t\text4_update_inode_fsync_trans(handle, inode, 1);\n\t\t\terr = check_eofblocks_fl(handle, inode, map->m_lblk,\n\t\t\t\t\t\t path, map->m_len);\n\t\t} else\n\t\t\terr = ret;\n\t\tgoto out2;\n\t}\n\t/* buffered IO case */\n\t/*\n\t * repeat fallocate creation request\n\t * we already have an unwritten extent\n\t */\n\tif (flags & EXT4_GET_BLOCKS_UNINIT_EXT)\n\t\tgoto map_out;\n\n\t/* buffered READ or buffered write_begin() lookup */\n\tif ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {\n\t\t/*\n\t\t * We have blocks reserved already. We\n\t\t * return allocated blocks so that delalloc\n\t\t * won't do block reservation for us. But\n\t\t * the buffer head will be unmapped so that\n\t\t * a read from the block returns 0s.\n\t\t */\n\t\tmap->m_flags |= EXT4_MAP_UNWRITTEN;\n\t\tgoto out1;\n\t}\n\n\t/* buffered write, writepage time, convert*/\n\tret = ext4_ext_convert_to_initialized(handle, inode, map, path);\n\tif (ret >= 0)\n\t\text4_update_inode_fsync_trans(handle, inode, 1);\nout:\n\tif (ret <= 0) {\n\t\terr = ret;\n\t\tgoto out2;\n\t} else\n\t\tallocated = ret;\n\tmap->m_flags |= EXT4_MAP_NEW;\n\t/*\n\t * if we allocated more blocks than requested\n\t * we need to make sure we unmap the extra block\n\t * allocated. The actual needed block will get\n\t * unmapped later when we find the buffer_head marked\n\t * new.\n\t */\n\tif (allocated > map->m_len) {\n\t\tunmap_underlying_metadata_blocks(inode->i_sb->s_bdev,\n\t\t\t\t\tnewblock + map->m_len,\n\t\t\t\t\tallocated - map->m_len);\n\t\tallocated = map->m_len;\n\t}\n\n\t/*\n\t * If we have done fallocate with the offset that is already\n\t * delayed allocated, we would have block reservation\n\t * and quota reservation done in the delayed write path.\n\t * But fallocate would have already updated quota and block\n\t * count for this offset. So cancel these reservation\n\t */\n\tif (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) {\n\t\tunsigned int reserved_clusters;\n\t\treserved_clusters = get_reserved_cluster_alloc(inode,\n\t\t\t\tmap->m_lblk, map->m_len);\n\t\tif (reserved_clusters)\n\t\t\text4_da_update_reserve_space(inode,\n\t\t\t\t\t\t reserved_clusters,\n\t\t\t\t\t\t 0);\n\t}\n\nmap_out:\n\tmap->m_flags |= EXT4_MAP_MAPPED;\n\tif ((flags & EXT4_GET_BLOCKS_KEEP_SIZE) == 0) {\n\t\terr = check_eofblocks_fl(handle, inode, map->m_lblk, path,\n\t\t\t\t\t map->m_len);\n\t\tif (err < 0)\n\t\t\tgoto out2;\n\t}\nout1:\n\tif (allocated > map->m_len)\n\t\tallocated = map->m_len;\n\text4_ext_show_leaf(inode, path);\n\tmap->m_pblk = newblock;\n\tmap->m_len = allocated;\nout2:\n\tif (path) {\n\t\text4_ext_drop_refs(path);\n\t\tkfree(path);\n\t}\n\treturn err ? err : allocated;\n}", "label": 0, "text_label": "benign", "cve_id": "CVE-2012-4508", "cwe_id": "CWE-362" }, { "id": 701, "func": "ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,\n\t\t\tstruct ext4_map_blocks *map,\n\t\t\tstruct ext4_ext_path *path, int flags,\n\t\t\tunsigned int allocated, ext4_fsblk_t newblock)\n{\n\tint ret = 0;\n\tint err = 0;\n\text4_io_end_t *io = ext4_inode_aio(inode);\n\n\text_debug(\"ext4_ext_handle_uninitialized_extents: inode %lu, logical \"\n\t\t \"block %llu, max_blocks %u, flags %x, allocated %u\\n\",\n\t\t inode->i_ino, (unsigned long long)map->m_lblk, map->m_len,\n\t\t flags, allocated);\n\text4_ext_show_leaf(inode, path);\n\n\ttrace_ext4_ext_handle_uninitialized_extents(inode, map, allocated,\n\t\t\t\t\t\t newblock);\n\n\t/* get_block() before submit the IO, split the extent */\n\tif ((flags & EXT4_GET_BLOCKS_PRE_IO)) {\n\t\tret = ext4_split_unwritten_extents(handle, inode, map,\n\t\t\t\t\t\t path, flags);\n\t\tif (ret <= 0)\n\t\t\tgoto out;\n\t\t/*\n\t\t * Flag the inode(non aio case) or end_io struct (aio case)\n\t\t * that this IO needs to conversion to written when IO is\n\t\t * completed\n\t\t */\n\t\tif (io)\n\t\t\text4_set_io_unwritten_flag(inode, io);\n\t\telse\n\t\t\text4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN);\n\t\tif (ext4_should_dioread_nolock(inode))\n\t\t\tmap->m_flags |= EXT4_MAP_UNINIT;\n\t\tgoto out;\n\t}\n\t/* IO end_io complete, convert the filled extent to written */\n\tif ((flags & EXT4_GET_BLOCKS_CONVERT)) {\n\t\tret = ext4_convert_unwritten_extents_endio(handle, inode, map,\n\t\t\t\t\t\t\tpath);\n\t\tif (ret >= 0) {\n\t\t\text4_update_inode_fsync_trans(handle, inode, 1);\n\t\t\terr = check_eofblocks_fl(handle, inode, map->m_lblk,\n\t\t\t\t\t\t path, map->m_len);\n\t\t} else\n\t\t\terr = ret;\n\t\tgoto out2;\n\t}\n\t/* buffered IO case */\n\t/*\n\t * repeat fallocate creation request\n\t * we already have an unwritten extent\n\t */\n\tif (flags & EXT4_GET_BLOCKS_UNINIT_EXT)\n\t\tgoto map_out;\n\n\t/* buffered READ or buffered write_begin() lookup */\n\tif ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {\n\t\t/*\n\t\t * We have blocks reserved already. We\n\t\t * return allocated blocks so that delalloc\n\t\t * won't do block reservation for us. But\n\t\t * the buffer head will be unmapped so that\n\t\t * a read from the block returns 0s.\n\t\t */\n\t\tmap->m_flags |= EXT4_MAP_UNWRITTEN;\n\t\tgoto out1;\n\t}\n\n\t/* buffered write, writepage time, convert*/\n\tret = ext4_ext_convert_to_initialized(handle, inode, map, path);\n\tif (ret >= 0)\n\t\text4_update_inode_fsync_trans(handle, inode, 1);\nout:\n\tif (ret <= 0) {\n\t\terr = ret;\n\t\tgoto out2;\n\t} else\n\t\tallocated = ret;\n\tmap->m_flags |= EXT4_MAP_NEW;\n\t/*\n\t * if we allocated more blocks than requested\n\t * we need to make sure we unmap the extra block\n\t * allocated. The actual needed block will get\n\t * unmapped later when we find the buffer_head marked\n\t * new.\n\t */\n\tif (allocated > map->m_len) {\n\t\tunmap_underlying_metadata_blocks(inode->i_sb->s_bdev,\n\t\t\t\t\tnewblock + map->m_len,\n\t\t\t\t\tallocated - map->m_len);\n\t\tallocated = map->m_len;\n\t}\n\n\t/*\n\t * If we have done fallocate with the offset that is already\n\t * delayed allocated, we would have block reservation\n\t * and quota reservation done in the delayed write path.\n\t * But fallocate would have already updated quota and block\n\t * count for this offset. So cancel these reservation\n\t */\n\tif (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) {\n\t\tunsigned int reserved_clusters;\n\t\treserved_clusters = get_reserved_cluster_alloc(inode,\n\t\t\t\tmap->m_lblk, map->m_len);\n\t\tif (reserved_clusters)\n\t\t\text4_da_update_reserve_space(inode,\n\t\t\t\t\t\t reserved_clusters,\n\t\t\t\t\t\t 0);\n\t}\n\nmap_out:\n\tmap->m_flags |= EXT4_MAP_MAPPED;\n\tif ((flags & EXT4_GET_BLOCKS_KEEP_SIZE) == 0) {\n\t\terr = check_eofblocks_fl(handle, inode, map->m_lblk, path,\n\t\t\t\t\t map->m_len);\n\t\tif (err < 0)\n\t\t\tgoto out2;\n\t}\nout1:\n\tif (allocated > map->m_len)\n\t\tallocated = map->m_len;\n\text4_ext_show_leaf(inode, path);\n\tmap->m_pblk = newblock;\n\tmap->m_len = allocated;\nout2:\n\tif (path) {\n\t\text4_ext_drop_refs(path);\n\t\tkfree(path);\n\t}\n\treturn err ? err : allocated;\n}", "label": 1, "text_label": "vulnerable", "cve_id": "CVE-2012-4508", "cwe_id": "CWE-362" } ]