| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
netdissect.h since commit 7578e1c requires <time.h> for struct tm. The
dependency is difficult to notice because the warning pops up when
compiling strdup.c only and only on Linux, and Linux most certainly has
strdup(), so normally strdup.c is never compiled on Linux. Make it
correct anyway to eliminate a space for future surprises in other files.
$ make strdup.o
In file included from ./missing/strdup.c:38:
./netdissect.h:441:38: warning: 'struct tm' declared inside parameter
list will not be visible outside of this definition or declaration
gcc (Debian 10.2.1-6) 10.2.1 20210110
|
|
|
|
|
|
|
|
| |
It's specified by the C90 standard (and, as I remember, by the C89
standard, although I no longer have my paper copy); no need to worry
about ancient environments that lack it, and we have some cases where we
call it in code not protected by #ifdef HAVE_STRFTIME/#endif and haven't
seen any reports of problems.
|
|
|
|
|
|
| |
Enable ND_LONGJMP_FROM_TCHECK. Remove a few redundant ND_TCHECK()
instances. Move one ND_TCHECK_4() to where it belongs. Have nd_printjn()
guard the snapshot end.
|
|
|
|
|
|
|
|
|
|
|
| |
ND_TCHECK_n(e), n in { 1, 2, 3, 4, 8 }.
They are redundant because they are followed by a GET_.*_n(e) call,
same n, same e, which do the bounds check.
Remove unused 'trunc' labels and most associated codes.
Update the outputs of some tests accordingly.
|
|
|
|
| |
This method is required to dissect some RADIUS attributes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Replace more calls to ipaddr_string()/ip6addr_string() with calls to
GET_IPADDR_STRING()/GET_IP6ADDR_STRING() macros performing bounds
checking.
Add similar bounds-checking inline functions and macros to wrap
linkaddr_string(), etheraddr_string(), and isonsap_string() and convert
calls to them to use the macros as well.
Shuffle the inline functions in addrtoname.h around a bit, so that the
inline functions, external declarations, and macros are all in the same
order.
|
|
|
|
|
|
|
| |
The exceptions are currently:
Some EXTRACT_ in print-juniper.c, not used on packet buffer pointer.
An EXTRACT_BE_U_3 in addrtoname.c, not always used on packet buffer
pointer.
|
|
|
|
|
|
|
| |
It prints " (invalid)", used for malformed or corrupted packets.
Moreover:
Update CONTRIBUTING.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Add the "Z" suffix for UTC.
According to the RFC3339:
Z A suffix which, when applied to a time, denotes a UTC
offset of 00:00; often spoken "Zulu" from the ICAO
phonetic alphabet representation of the letter "Z".
Update the output of some tests accordingly.
|
|
|
|
| |
Use EXTRACT_S_1 for ppoll (signed).
|
|
|
|
|
|
|
| |
Because istr[] is assign to " (invalid)", avoid adding a space before it.
Moreover:
Avoid also useless '\n'
|
|
|
|
|
|
|
|
| |
Remove the tstr[] strings.
Update the output of some tests accordingly.
Moreover:
Add or update some ndo_protocol fields.
|
|
|
|
|
|
|
| |
The functions are: nd_print, nd_printztn, nd_printn and nd_printzp.
Trying to make it clearer that they currently have to be used only on part
of the packet buffer.
Update some comments.
|
|
|
|
|
| |
Update this field in printer entry functions.
It will be used for some printings.
|
|
|
|
|
|
|
|
|
| |
First, check whether the originate timestamp is greater than the other
timestamp and, if so, calculate (originate - other) and print a -
instead of a + before it. This means we're not trying to stuff the
difference between two unsigned values into a signed value of the same
width (the result of which is undefined if the difference doesn't fit in
the signed variable).
|
|
|
|
| |
Fix warnings that introduces.
|
| |
|
|
|
|
|
|
|
|
| |
This can prevent bizarre failures if, for example, you've done a
configuration in the top-level source directory, leaving behind one
config.h file, and then do an out-of-tree build in another directory,
with different configuration options. This way, we always pick up the
same config.h, in the build directory.
|
| |
|
|
|
|
|
| |
This avoids a "comparison is always true" warning when checking whether
mode is >= MODE_UNSPEC.
|
| |
|
|
|
|
| |
They are arrays.
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Let the compiler do the optimizations (or not) based on build options.
Avoid 'value has been optimized out' messages in gdb using '-O0'.
|
| |
|
|
|
|
|
| |
ND_TTEST2(var, l) -> ND_TTEST_LEN(p, l)
ND_TCHECK2(var, l) -> ND_TCHECK_LEN(p, l)
|
|
|
|
|
|
|
|
|
|
| |
This catches direct references, so we can change them to use EXTRACT_U_1
or EXTRACT_S_1.
Also, change some structures to use the nd_ types that weren't already
using them.
Then make the appropriate EXTRACT_{U,S}_1() changes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now all the macros have a name meaning a count in bytes.
With _S_: signed, _U_: unsigned
e.g.:
EXTRACT_BE_32BITS -> EXTRACT_BE_U_4
EXTRACT_LE_32BITS -> EXTRACT_LE_U_4
...
EXTRACT_BE_INT32 -> EXTRACT_BE_S_4
and have:
EXTRACT_8BITS -> EXTRACT_U_1
EXTRACT_INT8 -> EXTRACT_S_1
|
|
|
|
|
| |
It indicates clearly that these macros are used to extract big-endian
integral values.
|
|
|
|
|
|
| |
It doesn't fit in a 32-bit signed integral constant, so make sure it's
64-bit; the only use is to subtract it from a 64-bit signed integral
value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The seconds value in a 64-bit NTP timestamp is unsigned. Treat it as
such.
When converting it to a UN*X seconds-since-the-Epoch, cast the 32-bit
seconds value from an NTP timestap to a 64-bit signed value (which is
always possible), and then subtract the signed delta between 1900 and
1970, giving a signed seconds-since-the-Epoch value.
Then assign that to a time_t; if that variable doesn't have the same
value as the calculated 64-bit value, we can't represent it in a time_t,
so just report it as unrepresentable.
Otherwise, use that resulting value in a gmtime() call - and make sure
gmtime() doesn't return NULL, which it can do with some versions of the
Microsoft C runtime. If it does, report the time as unrepresentable,
otherwise report it as YYYY-MM-DDTHH:MM:SS.
This fixes the 32-bit vs. 64-bit issue for tests.
It also changes the test output, so update that.
|
| |
|
|
|
|
|
|
| |
In ntp_time_print() do not print the information already printed in
ntp_print(): mode, leap indicator, version (all part of the Status
header field) and length. Update the test case.
|
|
|
|
|
|
|
|
|
| |
See if this fixes the crashes on the OpenCSW SPARC buildbots. If so, it
means that the compiler may think that even structures made up of
nothing but bytes (char/unsigned char) and arrays of bytes are aligned,
even if there's no guarantee of that.
(Bad compiler! No biscuit!)
|
|
|
|
|
|
| |
This change adds checks that were missing from the recent NTP code and
could cause a buffer over-read vulnerability (see earlier commits for
rationale).
|
|
|
|
|
|
| |
Rename NTP_MSG_MINLEN to NTP_TIMEMSG_MINLEN for clarity and introduce and
use NTP_CTRLMSG_MINLEN. With this change ntp_control_print() can detect
invalid packets better.
|
|
|
|
|
| |
This prevents alignment issues when the structures are used to access
the input buffer (see earlier commits for more detailed rationale).
|
|
|
|
| |
This implements the same convention as in all other decoders.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In print-ntp.c:
Rename struct ntpdata into struct ntp_time_data and add new
struct ntp_control_data to map NTP Control messages.
Add figure of NTP Control Message Header as comment.
Add union ntpdata to provide a common view on NTP messages.
Rename ntp_print() to ntp_time_print(), using new structures.
Improve comment and re-arrange fields in ntp_print().
Add ntp_control_print() to handle NTP Control Messages.
Output R, E, M, OpCode, Sequence, Status, Assoc, Offset, and Count in
ntp_control_print().
A new ntp_print() will decode only the very basics (VN, LI and Mode)
to call ntp_time_print() or ntp_control_print(), depending on Mode.
|
|
|
|
|
|
| |
poll() is a system API on UN*Xes, so calling a variable "poll" causes
"declaration of 'poll' shadows a global declaration" warnings in some
compilers. Call the argument "poll_interval" instead.
|
|
|
|
|
|
|
|
|
|
| |
In ntp_print() add a missing length check to reject packets that are
declared too short, make the existing length checks easier to follow and
add a catch-all block after the known message layouts.
This fixes a bug where an invalid packet could be erroneously printed
like it is valid so long as the provided buffer was large enough. That
said, the bounds checks were done correctly so there was no over-read.
|
|
|
|
|
| |
An NTP packet authenticated with a key using stronger hash function than
MD5 may have a 160-bit digest.
|
|
|
|
|
|
|
| |
print-ntp.c: Change p_ntp_time() to print NTP timestamps in UTC instead
of local time. This allows for consistent output for automatic testing
different time zones. Also use an ISO 8601 (RFC3339) format for the
time stamps.
|
|
|
|
|
| |
Add shift constants LEAPSHIFT(6) and MODESHIFT(0).
Rename MODE_RES1 to MODE_CONTROL, adjusting ntp_mode_values[].
|
|
|
|
| |
Add shift constant VERSIONSHIFT(3), and use it in ntp_print().
|
| |
|