Commit Graph

125 Commits

Author SHA1 Message Date
Xiang Xiao
1ee948e0c8 Include assert.h for DEBUGASSERT caller
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-05-24 12:34:37 +09:00
YAMAMOTO Takashi
998abe1deb netlib_parseurl.c: Fix string overruns
For EINVAL, it doesn't make sense to keep parsing.
(For E2BIG, it might make some sense.)

Found by LLVM ASan.

```
=================================================================
==81622==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000000f2 at pc 0x00010d2746ca bp 0x7ffee29a9980 sp 0x7ffee29a9978
READ of size 1 at 0x6020000000f2 thread T0
    #0 0x10d2746c9 in netlib_parseurl netlib_parseurl.c:121
    #1 0x10d26b293 in parseurl webclient.c:479
    #2 0x10d265e48 in webclient_perform webclient.c:690
    #3 0x10d277c5b in main main.c:210
    #4 0x7fff7a06f3d4 in start+0x0 (libdyld.dylib:x86_64+0x163d4)

0x6020000000f2 is located 0 bytes to the right of 2-byte region [0x6020000000f0,0x6020000000f2)
allocated by thread T0 here:
    #0 0x10d3996d3 in wrap_strdup+0x203 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x3e6d3)
    #1 0x10d276abe in main main.c:147
    #2 0x7fff7a06f3d4 in start+0x0 (libdyld.dylib:x86_64+0x163d4)

SUMMARY: AddressSanitizer: heap-buffer-overflow netlib_parseurl.c:121 in netlib_parseurl
Shadow bytes around the buggy address:
  0x1c03ffffffc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c03ffffffd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c03ffffffe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c03fffffff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c0400000000: fa fa fd fd fa fa fd fd fa fa 00 00 fa fa 00 00
=>0x1c0400000010: fa fa 00 fa fa fa 00 00 fa fa 00 06 fa fa[02]fa
  0x1c0400000020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0400000030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0400000040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0400000050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0400000060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 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
  Shadow gap:              cc
==81622==ABORTING
```
2021-05-07 20:23:01 -07:00
YAMAMOTO Takashi
73a93e2370 netlib_parseurl.c: Appease nxstyle
The following errors are false positives.
https://github.com/apache/incubator-nuttx/issues/387

```
/Users/yamamoto/git/nuttx/apps/netutils/netlib/netlib_parseurl.c:57:13: error: C++ style comment
/Users/yamamoto/git/nuttx/apps/netutils/netlib/netlib_parseurl.c:59:35: error: C++ style comment
```
2021-05-07 20:23:01 -07:00
YAMAMOTO Takashi
5065d470ce netutils/netlib/netlib_ipmsfilter.c: Fix a syslog format 2020-11-23 04:59:11 -08:00
YAMAMOTO Takashi
cbaf05bfd0 netutils/netlib/netlib_ipmsfilter.c: Appease nxstyle 2020-11-23 04:59:11 -08:00
Xiang Xiao
8375a2177e Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-10-18 22:27:57 -07:00
Xiang Xiao
8a63e58936 Change all 'Nuttx' to 'NuttX'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-10-18 22:27:57 -07:00
Xiang Xiao
deaa6c5b7b build: Replace $(TOPDIR)/Make.defs with $(APPDIR)/Make.defs
and move NUTTXLIB defintion to the common place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-07-09 15:17:37 -03:00
YAMAMOTO Takashi
a49f951c86 netlib_parsehttpurl: Fix pathlen check 2020-05-28 19:59:03 +08:00
YAMAMOTO Takashi
585d63b30d netlib_parseurl: Fix pathlen check 2020-05-28 19:59:03 +08:00
Xiang Xiao
69f013e74e build: Remve the unnecessary .gitignore
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-23 15:56:35 +01:00
Xiang Xiao
ead498a788 build: Remove the workaround for the inexistence of .config/Make.defs
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-21 17:43:42 +01:00
Gregory Nutt
b2d8c501f6 Remove use of set_errno() from application code.
The normal assignment errno = errcode should work fine now.
2020-05-07 22:23:19 +01:00
Xiang Xiao
95efbf7e62 netlib: fix nxstyle issue for netlink related code
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-10 09:22:08 -06:00
Xiang Xiao
63157f3a4d nshlib: use rtgenmsg for netlib_get_arptable/netlib_get_nbtable lik Linux
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I0b28eea6a70d0b5f6c5beef26f6624edfb3d6c86
2020-04-10 09:22:08 -06:00
Xiang Xiao
300bc2729a netlib: correct netlink usage to follow Linux convention
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Iae98b0a008dc42dddb77f47d79511ae4fb4bbfca
2020-04-10 09:22:08 -06:00
Xiang Xiao
f5ea28e9ad netlib: Remove AF_FAMILY and PF_FAMILY definition
use the common one(NETLIB_SOCK_FAMILY)

Change-Id: Ifc255f82f169d3bb37604c49006361a40c9933d1
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-09 07:36:19 -06:00
Xiang Xiao
1511403fdf Revert "Don't generate .depend anymore"
This reverts commit cc5ad09caa.
2020-03-22 23:09:40 -05:00
Xiang Xiao
cc5ad09caa
Don't generate .depend anymore 2020-03-22 18:15:21 +00:00
Xiang Xiao
41d88f06e7 Run codespell -w with the latest dictonary again 2020-02-23 07:10:14 -06:00
Miguel Herranz
960a92c652 Make SO_REUSEADDR not mandatory in netlib
This functionality is not available in NuttX so far.
2020-02-06 23:43:37 +01:00
Xiang Xiao
e0adf5ee0b Remove all CONFIG_NET_HAVE_REUSEADDR guard 2020-02-03 15:13:19 -06:00
Xiang Xiao
e0dcfa0c55 Remove extra whitespace from files (#43)
* Remove multiple newlines at the end of file
* Remove the white space from the end of line
2020-01-31 08:29:24 -06:00
Alin Jerpelea
59b763add4 netutils/netlib: Fix buffer overflow 2020-01-29 00:29:30 -08:00
Xiang Xiao
857158451b Unify the void cast usage
1.Remove void cast for function because many place ignore the returned value witout cast
2.Replace void cast for variable with UNUSED macro

Change-Id: Ie644129a563244a6397036789c4c3ea83c4e9b09
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-01-02 23:21:01 +08:00
Gregory Nutt
1859f56380 apps/netutils/netinit, apps/netutils/netlib/, and apps/include/netutils/netlib.h: Extend a few definitions to permit building netutils and netinit with only Netlink sockets enabled. 2019-11-19 09:49:36 -06:00
Gregory Nutt
370bd94a6b netutils/netlib/netlib_getdevs.c: Add comments and a placeholder for the RTM_NEWROUTE response. 2019-11-12 10:37:40 -06:00
Gregory Nutt
449290c8da apps/examples/netlink_route: Add test/example of NETLINK_ROUTE 'get' opeations. apps/netutils/netlib: Fixes to NETLINK_ROUTE helpers found by testing with apps/examples/netlink_route. 2019-11-11 13:40:57 -06:00
Gregory Nutt
438777cd38 netutils/netlib/netlib_getroute.c: Add function to retrieve routing tables using netlink. 2019-11-10 12:36:34 -06:00
Gregory Nutt
e260ea779c apps/netutils/netlib/netlib_getnbtab.c: Add a utility function that will return a list of all network devices in the UP state. 2019-11-09 17:38:02 -06:00
Gregory Nutt
2507cc15e8 netutils/netlib/netlib_getnbtab.c: Add support for retrieving a snapshot of the IPv6 neighbor table using Netlink sockets. 2019-11-08 11:30:32 -06:00
Gregory Nutt
f4f1ddccd7 netutils/netlib/netlib_getarptab.c: Per an old Linux Journal article, the nl_pid fild of struct sockaddr_nl should be set to the PID of the task that created the Netlink socket. Also fixes a warning. 2019-11-07 14:08:03 -06:00
Gregory Nutt
de9101a1d9 apps/netutils/netlib/netlib_getarptab.c: Fix typos in comments. 2019-11-04 12:31:13 -06:00
Gregory Nutt
af6719d78d netutils/netlib/netlib_getarptab.c: Do not initialize response buffer, it is write-only. Also add a check to assue that the sequence number in the response is the same as the sequence number in the request. 2019-11-04 09:04:17 -06:00
Gregory Nutt
b65c3dac0e netutils/netlib/netlib_getarptab.c: Misc fixes from initial testing with the 'arp -t' commeand. 2019-11-03 19:29:20 -06:00
Gregory Nutt
400995dec6 nshlib/nsh_netcmds.c: Add a -t option to the arp command which will enable printing the entire ARP table. 2019-11-03 16:19:14 -06:00
Gregory Nutt
768218ee81 netutils/netlib/netlib_getarptab.c: Add a function to read the entire ARP tableusing NETLINK_ROUTE protocol. 2019-11-03 15:13:47 -06:00
Xiang Xiao
7808eb62d2 apps/: In all Make.def files, append to CONFIGURED_APPS patch with the absolute path. 2019-10-17 11:33:59 -06:00
Gregory Nutt
3a23523147 Makefiles: This reverts part of commit cf0365ea9. It restores 'conditional' inclusion of TOPDIR/Make.defs. Otherwise all make targets fail if the board has not been configured. That is okay most of the time, but not for things like clean and distclean which should not depend on being configured. 2019-10-15 09:25:48 +08:00
Xiang Xiao
cf0365ea92 Clean up Makefile under apps folder no functional changes. 2019-10-04 08:35:46 -06:00
Xiang Xiao
70e7fafaed Revert netutils/netlib: correct ICMPv6 socket create error. This reverts commit 0bcd3b76280ad100b2d0f7d813fa6d970f54b4f4. 2019-09-20 12:47:04 -06:00
ligd
2c34489e81 netutils/netlib/netlib_autoconfig.c: Correct ICMPv6 socket create error. 2019-09-15 08:40:05 -06:00
Sebastien Lorquet
fe0954cd62 netutils/netlib/netlib_parseurl.c: Add a more flexible version of netlib_parsehttpurl. This one can parse any URL, and is extensible so future improvements keep the same API. 2019-04-26 13:08:38 -06:00
Gregory Nutt
b2f46360de apps/: Remove/replace all conditional logic based on CONFIG_NSOCKET_DESCRIPTORS == 0. That value is always greater than zero now. In places just replace with #ifdef CONFIG_NET. 2019-02-11 16:23:55 -06:00
Gregory Nutt
a26a7f9767 apps/netutils/netlib and apps/examples/igmp: Adapt to use the corrected, semi-standard version of struct ip_msfilter. 2018-10-29 06:51:56 -06:00
Gregory Nutt
386c29bbaf netutils/netlib/netlib_parsehttpurl.c: Rethink last commit. I think it still needs to continue parsing to the end of the hostname string after the E2BIG error has occurred. 2018-09-30 08:46:52 -06:00
Gregory Nutt
2d9a916be1 apps/netutils/netlib/netlib_parsehttpurl.c: Correct handling of long URLs as noted in Bitbucket issue #119 (in the nuttx/ repository, not the apps/ repository). 2018-09-30 08:33:10 -06:00
anchao
b5cfd93444 apps/: Modification to build system: Unified application compilation rules 2018-09-03 09:29:56 -06:00
Gregory Nutt
a57610c2c4 Remove trailing spaces at the end of lines. 2018-08-13 07:47:26 -06:00
Gregory Nutt
0094b411da apps/netutils/netlib: Various fixes needed to get a clean netlib build with Bluetooth only. 2018-04-03 10:01:55 -06:00