File: link_open-do-not-crash-when-run-as-non-root.patch

package info (click to toggle)
arp-scan 1.9.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,624 kB
  • sloc: ansic: 5,289; sh: 959; perl: 856; makefile: 17
file content (28 lines) | stat: -rw-r--r-- 947 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From: rofl0r <retnyg@gmx.net>
Date: Wed, 2 Nov 2016 09:30:38 +0000
Subject: link_open: do not crash when run as non-root

if there's a permission error (or another error), the returned handle
will be null and the subsequent dereference will crash the program.

Bug-Debian: https://bugs.debian.org/881125
Origin: https://github.com/royhills/arp-scan/commit/bd028a84191e2cc3f21ccdb8a5ddbdab743b81e6
---
 link-packet-socket.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/link-packet-socket.c b/link-packet-socket.c
index dac1bbb..bc22fbe 100644
--- a/link-packet-socket.c
+++ b/link-packet-socket.c
@@ -118,6 +118,10 @@ get_hardware_address(const char *if_name, unsigned char hw_address[]) {
    link_t *handle;
 
    handle = link_open(if_name);
+   if(!handle) {
+       err_sys("link_open");
+       return;
+   }
 
 /* Obtain hardware address for specified interface */
    if ((ioctl(handle->fd, SIOCGIFHWADDR, &(handle->ifr))) != 0)