我有一个问题,修补开放源码软件脆弱的问题,这是一个CVE-2008-1687发现在m4开源资源。
问题的日志是
cd _DIR/M4/1.4.9-R2/M4-1.4.9/checks && AWK=gawk ./get./doc/m4.texinfo (....skip) 节点:注释gawk: cmd。行:70:(文件名=./doc/m4.texinfo FNR=919)致命:
Invalid content of \{\}: /@tabchar{}/
日志说gawk命令一直执行到m4.texinfo文件的第918行,并且Invalid content of \{\}: /@tabchar{}/错误发生在第919行。但是,在m4.texinfo的第919行中找不到\{\}内容和/@tabchar{}/字符。因此,我想知道为什么会发生错误,以及如何修复它。
把-他们
/^@example$/, /^@end example$/ {
if (seq < 0)
next;
if ($0 ~ /^@example$/) {
if (count > 0)
close (file);
seq++;
count++;
file = sprintf("%03d.%s", count, node);
printf("dnl @ %s:%d: Origin of test\n"\
"dnl @ expected status: %d\n"\
"dnl @ Copyright (C) 2006, 2007 Free Software Foundation\n"\
"dnl @ This file is free software; the Free Software Foundation\n"\
"dnl @ gives unlimited permission to copy and/or distribute it\n"\
"dnl @ with or without modifications, as long as this notice\n"\
"dnl @ is preserved.\n", FILENAME, NR, status) > file;
status = 0;
next;
}
if ($0 ~ /^@end example$/) {
next; // line 70
}
if ($0 ~ /^\^D$/)
next;
if ($0 ~ '/^@result\{\}/' || $0 ~ '/^@error\{\}/')
prefix = "dnl ";
else
prefix = "";
gsub("@@", "@", $0);
gsub("@{", "{", $0);
gsub("@}", "}", $0);
gsub("@w{ }", " ", $0);
gsub("@tabchar{}", "\t", $0);
printf("%s%s\n", prefix, $0) >> file;}
m4.texinfo @节点注释@节注释在@code{m4}输入中 @m4}中的@cindex注释通常由字符@samp{#}和换行符分隔。注释分隔符之间的所有字符都被忽略,但是整个注释(包括分隔符)被传递到输出--注释被@code{m4}丢弃。 注释不能嵌套,因此@samp{#}之后的第一行结束注释。开始注释字符串的注释效果可以通过引用它来抑制。 @示例
quoted text' #注释文本‘//第919行 @result{}引文#commented text'引用抑制‘#'注释’ @结果{}引用抑制#注释 @end示例
发布于 2019-05-08 14:44:49
您所指示的行是第70行:
next; // line 70显然不是awk脚本的第70行,因为它不包含错误消息告诉您的在第70行产生故障的文本:
Invalid content of \{\}: /@tabchar{}/在此代码中的regexp中:
gsub("@tabchar{}", "\t", $0);{}是一个RE间隔(在x{3}中是指3次x的重复)--它不能是空的,而且我怀疑您希望将{和}作为文本来处理。
看:
$ echo 'foo@tabchar{}bar' | awk 'gsub("@tabchar{}", "\t", $0);'
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: Invalid content of \{\}: /@tabchar{}/
$ echo 'foo@tabchar{}bar' | awk 'gsub("@tabchar\{\}", "\t", $0);'
awk: cmd. line:1: warning: escape sequence `\{' treated as plain `{'
awk: cmd. line:1: warning: escape sequence `\}' treated as plain `}'
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: Invalid content of \{\}: /@tabchar{}/
$ echo 'foo@tabchar{}bar' | awk 'gsub("@tabchar\\{\\}", "\t", $0);'
foo bar您需要2个转义符,因为您在regexp上下文中使用了一个字符串,所以awk必须首先将该字符串转换为regexp (使用完一组转义符),然后使用它作为regexp (使用其余的一组转义符)。在regexp周围使用regexp (/.../)而不是string ("...")分隔符,以避免这种情况和其他问题:
$ echo 'foo@tabchar{}bar' | awk 'gsub(/@tabchar\{\}/, "\t", $0);'
foo bar您还应该考虑一下脚本的其他部分中regexp周围的单引号是如何处理的,例如:
if ($0 ~ '/^@result\{\}/' || $0 ~ '/^@error\{\}/')我想你可能是想写:
if ($0 ~ /^@result\{\}/ || $0 ~ /^@error\{\}/)这相当于:
if (/^@result\{\}/ || /^@error\{\}/)甚至只是:
if (/^@(result|error)\{\}/)https://stackoverflow.com/questions/56034233
复制相似问题