adjust Makefile.in (add docs, man), fix build

未关闭
#10 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
c
领域
cli, networking

调研方向

先从 Makefile.in 和构建输出开始,然后检查 scan.c、ars.c、getifname.c、waitpacket.c、listen.c、libpcap_stuff.c、ip_opt_build.c、random.c、adbuf.c、apd.c 以及主机名查找代码中报告的位置。重新构建 hping3,并验证所请求的 DESTDIR、文档和 man 页面安装能够正常工作,同时确认列出的构建警告和 gethostbyname 诊断已得到处理。

由索引模型根据 Issue 内容生成。

描述

I have added support for $(DESTDIR), docs, man pages too for French in Makefile.in

cat hping-3.0.0_alpha_1-Makefile.in.patch 
--- Makefile.in.orig    2014-12-25 15:01:43.000000000 +0100
+++ Makefile.in 2014-12-26 08:06:25.681410513 +0100
@@ -9,14 +9,19 @@
 CC= gcc
 AR=/usr/bin/ar
 RANLIB=/usr/bin/ranlib
-CCOPT= -O2 -Wall @PCAP_INCLUDE@ @TCL_INC@ @USE_TCL@
+CCOPT= $(CFLAGS) -O2 -Wall @PCAP_INCLUDE@ @TCL_INC@ @USE_TCL@
 DEBUG= -g
 #uncomment the following if you need libpcap based build under linux
 #(not raccomanded)
 COMPILE_TIME=
-INSTALL_MANPATH=@MANPATH@
 @PCAP@

+DOCS = AUTHORS *BUGS CHANGES COPYING NEWS README TODO
+DOCS_EN = docs/*.txt docs/AS-BACKDOOR docs/HPING2-IS-OPEN docs/MORE-FUN-WITH-IPID
+DOCS_FR = docs/french/*.txt docs/french/AS-BACKDOOR docs/french/HPING2-IS-OPEN docs/french/MORE-FUN-WITH-IPID
+MANS = docs/hping2.8 docs/hping3.8
+MANS_FR = docs/french/hping2-fr.8
+
 ARSOBJ = ars.o apd.o split.o rapd.o

 OBJ=   main.o getifname.o getlhs.o \
@@ -72,17 +77,18 @@
        rm -rf hping3 *.o byteorder byteorder.h systype.h Makefile libars.a .depend
        rm -rf hping3 *.o byteorder byteorder.h systype.h Makefile libars.a .depend

 install: hping3
-       cp -f hping3 /usr/sbin/
-       chmod 755 /usr/sbin/hping3
-       ln -s /usr/sbin/hping3 /usr/sbin/hping
-       ln -s /usr/sbin/hping3 /usr/sbin/hping2
-       @if [ -d ${INSTALL_MANPATH}/man8 ]; then \
-               cp ./docs/hping3.8 ${INSTALL_MANPATH}/man8; \
-               chmod 644 ${INSTALL_MANPATH}/man8/hping3.8; \
-       else \
-               echo "@@@@@@ WARNING @@@@@@"; \
-               echo "Can't install the man page: ${INSTALL_MANPATH}/man8 does not exist"; \
-       fi
+       install -m 0755 -d $(DESTDIR)/usr/sbin
+       install -m 0755 -d $(DESTDIR)/usr/share/man/man8
+       install -m 0755 -d $(DESTDIR)/usr/share/man/fr/man8
+       install -m 0755 -d $(DESTDIR)/usr/share/doc/packages/hping/docs/french
+       install -m 0755 hping3 $(DESTDIR)/usr/sbin/
+       ln -s /usr/sbin/hping3 hping
+       ln -s /usr/sbin/hping3 hping2
+       install -m 0644 $(MANS) $(DESTDIR)/usr/share/man/man8/
+       install -m 0644 $(MANS_FR) $(DESTDIR)/usr/share/man/fr/man8/
+       install -m 0644 $(DOCS) $(DESTDIR)/usr/share/doc/packages/hping/
+       install -m 0644 $(DOCS_EN) $(DESTDIR)/usr/share/doc/packages/hping/docs/
+       install -m 0644 $(DOCS_FR) $(DESTDIR)/usr/share/doc/packages/hping/docs/french/

 strip: hping3
        @ls -l ./hping3

This changes fix build

I use this sed to fix build with scan.c

sed -i 's|icmp, p, sizeof(subtcp|icmp, p, sizeof(icmp|' scan.c

Without this sed get

[   19s] I: Statement is overflowing a buffer
[   19s] E: hping bufferoverflow /usr/include/bits/string3.h:51

I use this patch to fix build with ars.c

cat hping-3.0.0_alpha_1-ars.c.patch 
--- ars.c.orig  2014-12-25 15:01:43.000000000 +0100
+++ ars.c       2014-12-26 07:50:20.883410513 +0100
@@ -481,8 +481,8 @@
                sum = (sum >> 16) + (sum & 0xffff);
                sum += (sum >> 16);
                return (u_int16_t) ~sum;
-       } else {
-               assert("else reached in ars_multi_cksum()" == "");
+//     } else {
+//             assert("else reached in ars_multi_cksum()" == "");
        }
        return 0; /* unreached, here to prevent warnings */
 }

Without this patch get

[   16s] I: Expression compares a char* pointer with a string literal.
[   16s]    Usually a strcmp() was intended by the programmer
[   16s] E: hping stringcompare ars.c:485

Please correct these build warnings and release new commit when is all fixed, too Issue #9

[    9s] getifname.c:343:35: warning: pointer targets in passing argument 3 of 'getsockname' differ in signedness [-Wpointer-sign]
[    9s]   if (getsockname(sock_rt, (struct sockaddr *)&iface_out, &len) == -1 ) {
[    9s]                                    ^
[    9s] In file included from getifname.c:14:0:
[    9s] /usr/include/sys/socket.h:127:12: note: expected 'socklen_t * __restrict__' but argument is of type 'int *'
[    9s]  extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
[    9s]             ^
[    9s] getifname.c: In function 'get_if_name':
[    9s] getifname.c:61:11: warning: 'sa.sin_addr.s_addr' may be used uninitialized in this function [-Wmaybe-uninitialized]
[    9s]      printf("DEBUG: Output interface address: %s\n",
[    9s]            ^
...
[   11s] waitpacket.c: In function 'wait_packet':
[   11s] waitpacket.c:691:57: warning: 'tstamp' may be used uninitialized in this function [-Wmaybe-uninitialized]
[   11s]                  if (hz > 0 && opt_clock_skew) clock_skew(hz,tstamp,rttms);
[   11s]                                                          ^
[   11s] waitpacket.c:611:8: note: 'tstamp' was declared here
[   11s]   __u32 tstamp, echo;
[   11s]         ^
...
[   11s] listen.c: In function 'listenmain':
[   11s] listen.c:77:9: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
[   11s]     write(stdoutFD, p, size-(p-ip_packet));
[   11s]          ^
...
[   11s] libpcap_stuff.c:26:6: warning: variable 'on' set but not used [-Wunused-but-set-variable]
[   11s]   int on;
[   11s]       ^
[   11s] libpcap_stuff.c: In function 'pcap_recv':
[   11s] libpcap_stuff.c:61:19: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
[   11s]                  p = (unsigned char*) pcap_next(pcapfp, &hdr);
[   11s]                    ^
...
[   12s] ip_opt_build.c: In function 'ip_opt_build':
[   12s] ip_opt_build.c:28:29: warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsize
of-pointer-memaccess]
[   12s]      memset(ip_opt, 1, sizeof(ip_opt));
[   12s]                              ^
...
[   12s] random.c:32:7: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
[   12s]    read(fd, rc4_sbox, 256);
[   12s]        ^
...
[   12s] scan.c:458:6: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
[   12s]     p = packet+linkhdr_size+iphdrlen;
[   12s]       ^
...
[   12s] adbuf.c: In function 'adbuf_addchar':
[   12s] adbuf.c:130:22: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
[   12s]    unsigned char *p = b->buf + adbuf_used(b);
[   12s]                       ^
...
[   13s] ars.c:909:20: warning: variable 'ip' set but not used [-Wunused-but-set-variable]
[   13s]   struct ars_iphdr *ip;
[   13s]                     ^
[   13s] apd.c: In function 'ars_decode_hex':
[   13s] apd.c:823:2: warning: pointer targets in return differ in signedness [-Wpointer-sign]
[   13s]   return saved;
[   13s]   ^
[   13s] apd.c: In function 'ars_decode_string':
[   13s] apd.c:852:2: warning: pointer targets in return differ in signedness [-Wpointer-sign]
[   13s]   return saved;
[   13s]   ^
[   13s] apd.c: In function 'ars_d_set_data':
[   13s] apd.c:889:7: warning: variable 'err' set but not used [-Wunused-but-set-variable]
[   13s]    int err, blen;
[   13s]        ^

Tip add in sources where you get

p = 
   ^
#include <unistd.h>

Please fix too gethostbyname

[   23s] hping.x86_64: I: binary-or-shlib-calls-gethostbyname /usr/sbin/hping3
[   23s] The binary calls gethostbyname(). Please port the code to use getaddrinfo().
主要语言
C
星标
1.7k
派生
367
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

antirez/hping 的其他 Issue

查看 antirez/hping 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。