【发布时间】:2011-07-03 02:38:29
【问题描述】:
int main(int argc,char* argv[]);
如果A 中有'\0' 字符,它会被拆分成2 个参数吗?
./programe "A"
我无法轻松复制它,因为我无法将 '\0' 放入 A,但可能有人可以。
【问题讨论】:
-
你不能?
./programe $'A\0B' -
这是出于安全考虑吗?
-
@Ignacio Vazquez-Abrams,
$'A\0B'在这里如何工作? -
bash 解释
$'...'中的转义序列。 -
它没有 - 或者它有但它没有。我有一个程序
al,它每行打印一个参数(而不是像echo这样在一行上用空格分隔)。在 Bash 中,al $'a\0b'仅生成a作为输出。您必须在 Bash 手册中查看$'...'的确切含义,就像我一样。我发现al "a\0b"产生了a\0b作为输出,这并不令我大吃一惊。因此,即使$'a\0b' notation includes a null in the string, theexecve()` 系统调用在第一个 null 处停止复制参数,努力工作也没有任何用处。