Chinaunix

标题: iptables Segmentation fault,呵呵 [打印本页]

作者: liuzhuan23    时间: 2006-10-23 01:37
标题: iptables Segmentation fault,呵呵
1)随意看了看iptables的extensions的代码,看到 libipt_ttl.c 的时候,发现这份代码的一个问题

     我的配置: iptables-1.3.4,已经pom和patch了

2)在 1.3.4 版本的 parse 函数中,竟然把下述代码放到了 option 解析之后:

      if( * flags )
      {
           exit_error(PARAMETER_PROBLEM, "Can't specify TTL option twice");
      }

       即原来的代码是这样的:

       switch( c )
       {
           ....................
       }

        if( * flags )
        {
           exit_error(PARAMETER_PROBLEM, "Can't specify TTL option twice");
        }

       看到之后,感觉这段代码一定会导致 Segmentation fault,于是试了一试:

       iptables -A INPUT -m ttl --ttl-eq 123 -J DROP

       果然,Segmentation fault,注意,这里我使用的是 -J 而不是 -j

3)如何解决:
     
     if( * flags )
     {
           exit_error(PARAMETER_PROBLEM, "Can't specify TTL option twice");
     }

      代码放到 check_inverse(optarg, &invert, &optind, 0); 之前即可,把该检查的逻辑放到头里去做

4)也许有别人也遇到这个问题,希望对你们有帮助




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2