- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试清除链接列表时出现此错误
=================================================================
==4574==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000000050 at pc 0x7fcb73b40682 bp 0x7ffffcfd8370 sp 0x7ffffcfd8368
READ of size 8 at 0x603000000050 thread T0
#0 0x7fcb73b40681 in clear_dict ../src/utils_dict.c:83
#1 0x7fcb73b4193c in morsec ../src/morsec.c:37
#2 0x7fcb73b419e2 in main ../src/morsec.c:45
#3 0x7fcb72b8409a in __libc_start_main ../csu/libc-start.c:308
#4 0x7fcb73b40189 in _start (/mnt/c/Code/WEC-01/morsec+0x2189)
0x603000000050 is located 16 bytes inside of 24-byte region [0x603000000040,0x603000000058)
freed by thread T0 here:
#0 0x7fcb72e18fb0 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe8fb0)
#1 0x7fcb73b405d7 in del_node ../src/utils_dict.c:70
#2 0x7fcb73b40698 in clear_dict ../src/utils_dict.c:84
#3 0x7fcb73b4193c in morsec ../src/morsec.c:37
#4 0x7fcb73b419e2 in main ../src/morsec.c:45
#5 0x7fcb72b8409a in __libc_start_main ../csu/libc-start.c:308
previously allocated by thread T0 here:
#0 0x7fcb72e19330 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7fcb73b40266 in new_node ../src/utils_dict.c:20
#2 0x7fcb73b416aa in get_dict ../src/parser.c:50
#3 0x7fcb73b4186d in morsec ../src/morsec.c:19
#4 0x7fcb73b419e2 in main ../src/morsec.c:45
#5 0x7fcb72b8409a in __libc_start_main ../csu/libc-start.c:308
SUMMARY: AddressSanitizer: heap-use-after-free ../src/utils_dict.c:83 in clear_dict
Shadow bytes around the buggy address:
0x0c067fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c067fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c067fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c067fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c067fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c067fff8000: fa fa fd fd fd fa fa fa fd fd[fd]fa fa fa 00 00
0x0c067fff8010: 00 fa fa fa 00 00 00 fa fa fa 00 00 00 fa fa fa
0x0c067fff8020: 00 00 00 fa fa fa 00 00 00 06 fa fa 00 00 00 fa
0x0c067fff8030: fa fa 00 00 00 fa fa fa 00 00 00 fa fa fa 00 00
0x0c067fff8040: 01 fa fa fa 00 00 00 fa fa fa 00 00 00 fa fa fa
0x0c067fff8050: 00 00 00 fa fa fa 00 00 00 fa fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==4574==ABORTING
struct s_dict
{
char *word;
char *symb;
struct s_dict *next;
};
typedef struct s_dict t_dict;
t_dict *new_node(char *word, char *symb)
{
t_dict *new;
new = NULL;
if (!(new = (t_dict*)malloc(sizeof(t_dict))))
return (NULL);
new->word = word;
new->symb = symb;
new->next = NULL;
return (new);
}
void del_node(t_dict *node)
{
if (node->word)
free(node->word);
node->word = NULL;
if (node->symb)
free(node->symb);
node->symb = NULL;
if (node->next)
free(node->next);
node->next = NULL;
if (node)
free(node);
node = NULL;
}
void clear_dict(t_dict **chain)
{
t_dict *tmp;
while (chain && *chain)
{
tmp = (*chain)->next; << line 83 in my code
del_node(*chain);
*chain = tmp;
}
}
free(): double free detected in tcache 2
[1] 4601 abort (core dumped)
最佳答案
该错误(实际上有几个)在您的 del_node()
中:它不应该触及 next
节点。
照原样删除 node->next
, 孤儿 node->next->word
等,并在下一次迭代中设置双重删除。
附言此检查和分配在 del_node()
:
if (node) // useless
free(node);
node = NULL; // useless
node
是 NULL,你早就崩溃了。赋值是无用的,因为它会在从函数返回之前立即修改局部变量。
关于runtime-error - 地址 sanitizer : heap-use-after-free ANSI C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61149072/
我目前使用以下代码在存储字符串之前对其进行清理: ERB::Util::h(string) 当字符串已经像这样清理后,我的问题就出现了: string = "Watching baseball `&a
我有几个版本的项目结帐和编译。如果我发现错误,我会比较版本以缩小问题范围。有时我会启用像 AddressSanitizer 这样的 sanitizer 。如果我重新使用一个可执行文件,我不记得它是否是
过去有人担心在某些环境中的生产中使用 ASAN:https://seclists.org/oss-sec/2016/q1/363 .评论来自 2016 年 - 今天的情况如何? 是否推荐使用 sani
过去有人担心在某些环境中的生产中使用 ASAN:https://seclists.org/oss-sec/2016/q1/363 .评论来自 2016 年 - 今天的情况如何? 是否推荐使用 sani
我正在使用 Google Caja HTML Sanitizer ( https://code.google.com/p/google-caja/wiki/JsHtmlSanitizer ),但它正在
我正在使用 goog.dom.safeHtmlToNode 动态更新包含内容的选项卡 由于较新版本的 google 闭包库删除了 dom 片段方法:goog.dom.htmlToDocumentFra
我正在使用 DOMPurify.sanitize()里面 dangerouslySetInnerHTML={{}}显示 innerHtml从数据库返回。对于最初的目的,我使用 getServersid
我不知道我需要做什么才能使这些选项不再被禁用。任何帮助,将不胜感激: 最佳答案 Thread Sanitizer 可用于以下准备条件: 关闭其他选项,例如 'Malloc stack' 需要64位模拟
我想知道是否有人使用过这个类并发现它可靠? http://www.phpclasses.org/package/3746-PHP-Remove-unsafe-tags-and-attributes-f
假设我复制了一些“恶意”输入,例如带有事件处理程序或其他 javascript 的 DOM 节点 如果我将其复制到我的剪贴板并将其粘贴到 contenteditable div 中,事件处理程序将被
这是我的一个表单(PHP+MySQL,textarea被TinyMCE取代)。它记录了带有段落、项目符号、标题和文本对齐方式(右对齐、左对齐、居中对齐和对齐)的描述。 提交后,记录显示为 Introd
我有以下代码片段,我在其中检查 soap 结果并将数据插入我的数据库。 Connection dbconn = null; Statement stmt1 = null; Statem
在以下示例中,我如何删除所有保留 html 内容的未知现有自定义标签: my header my Title my SubTitle 我想回去
我正在 Ubuntu 14.04 上使用带有 Clang 3.7.0 的 Memory Sanitizer。以下代码可以完美运行: #include int main() { double an
有哪些好的 PHP html(输入) sanitizer ? 最好是,如果内置了某些东西 - 我希望我们能做到这一点。 更新: 根据请求,通过评论,输入应该不允许 HTML(并且显然防止 XSS 和
我有以下数组,想知道验证和清理该数组以确保只允许整数的最佳方法是什么? if(is_array($_POST['taxonomy'])) { $term_ids = array_map('es
$sanitize 服务 tells me that All safe tokens (from a whitelist) are then serialized back to properly e
很抱歉,如果这是一个 super 简单的概念,但我发现很难获得正确的心态才能正确使用 clang 提供的 sanitizer 。 float foo(float f) { return (f / 0)
Clang有各种 sanitizer ,可以打开以在运行时发现问题。 但是,有些 sanitizer 我不能一起使用。这是为什么? clang++-3.9 -std=c++1z -g -fsaniti
一直在用fsanitize=address在编译 C 程序时,为了跟踪段错误大约一年了。我时不时地遇到一个奇怪的行为,如果编译没有我的程序会出现段错误 fsanitize=address但是当我用 f
我是一名优秀的程序员,十分优秀!