mirror of
https://github.com/nmap/nmap.git
synced 2025-12-25 17:09:02 +00:00
Update libpcap to 1.9.0 (no patches applied yet)
This commit is contained in:
@@ -20,22 +20,10 @@
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* _WIN32 */
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#endif /* _WIN32 */
|
||||
#include <pcap-types.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <memory.h>
|
||||
@@ -50,26 +38,23 @@
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
static inline int xdtoi(int);
|
||||
static inline int skip_space(FILE *);
|
||||
static inline int skip_line(FILE *);
|
||||
|
||||
/* Hex digit to integer. */
|
||||
static inline int
|
||||
xdtoi(c)
|
||||
register int c;
|
||||
static inline u_char
|
||||
xdtoi(u_char c)
|
||||
{
|
||||
if (isdigit(c))
|
||||
return c - '0';
|
||||
return (u_char)(c - '0');
|
||||
else if (islower(c))
|
||||
return c - 'a' + 10;
|
||||
return (u_char)(c - 'a' + 10);
|
||||
else
|
||||
return c - 'A' + 10;
|
||||
return (u_char)(c - 'A' + 10);
|
||||
}
|
||||
|
||||
static inline int
|
||||
skip_space(f)
|
||||
FILE *f;
|
||||
skip_space(FILE *f)
|
||||
{
|
||||
int c;
|
||||
|
||||
@@ -81,8 +66,7 @@ skip_space(f)
|
||||
}
|
||||
|
||||
static inline int
|
||||
skip_line(f)
|
||||
FILE *f;
|
||||
skip_line(FILE *f)
|
||||
{
|
||||
int c;
|
||||
|
||||
@@ -96,47 +80,61 @@ skip_line(f)
|
||||
struct pcap_etherent *
|
||||
pcap_next_etherent(FILE *fp)
|
||||
{
|
||||
register int c, d, i;
|
||||
register int c, i;
|
||||
u_char d;
|
||||
char *bp;
|
||||
size_t namesize;
|
||||
static struct pcap_etherent e;
|
||||
|
||||
memset((char *)&e, 0, sizeof(e));
|
||||
do {
|
||||
for (;;) {
|
||||
/* Find addr */
|
||||
c = skip_space(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
if (c == '\n')
|
||||
continue;
|
||||
|
||||
/* If this is a comment, or first thing on line
|
||||
cannot be etehrnet address, skip the line. */
|
||||
cannot be Ethernet address, skip the line. */
|
||||
if (!isxdigit(c)) {
|
||||
c = skip_line(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* must be the start of an address */
|
||||
for (i = 0; i < 6; i += 1) {
|
||||
d = xdtoi(c);
|
||||
d = xdtoi((u_char)c);
|
||||
c = getc(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
if (isxdigit(c)) {
|
||||
d <<= 4;
|
||||
d |= xdtoi(c);
|
||||
d |= xdtoi((u_char)c);
|
||||
c = getc(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
}
|
||||
e.addr[i] = d;
|
||||
if (c != ':')
|
||||
break;
|
||||
c = getc(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
}
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
/* Must be whitespace */
|
||||
if (!isspace(c)) {
|
||||
c = skip_line(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
continue;
|
||||
}
|
||||
c = skip_space(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
|
||||
/* hit end of line... */
|
||||
if (c == '\n')
|
||||
@@ -144,17 +142,21 @@ pcap_next_etherent(FILE *fp)
|
||||
|
||||
if (c == '#') {
|
||||
c = skip_line(fp);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* pick up name */
|
||||
bp = e.name;
|
||||
/* Use 'd' to prevent buffer overflow. */
|
||||
d = sizeof(e.name) - 1;
|
||||
/* Use 'namesize' to prevent buffer overflow. */
|
||||
namesize = sizeof(e.name) - 1;
|
||||
do {
|
||||
*bp++ = c;
|
||||
*bp++ = (u_char)c;
|
||||
c = getc(fp);
|
||||
} while (!isspace(c) && c != EOF && --d > 0);
|
||||
if (c == EOF)
|
||||
return (NULL);
|
||||
} while (!isspace(c) && --namesize != 0);
|
||||
*bp = '\0';
|
||||
|
||||
/* Eat trailing junk */
|
||||
@@ -162,8 +164,5 @@ pcap_next_etherent(FILE *fp)
|
||||
(void)skip_line(fp);
|
||||
|
||||
return &e;
|
||||
|
||||
} while (c != EOF);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user