Fix filter allocation failure on the UDS port.

Although it does not need to, the UDS port tries to allocate a filter,
just as any normal port would. Since the given length is zero, the
filter tries to allocate storage of size zero. When running with
uClibc, calloc(1, 0) returns NULL, but glibc is apparently returning
"a unique pointer value that can later be successfully passed to
free()." Both behaviors are allowed (see MALLOC(3)).

This patch works around the issue by letting the UDS port have a
filter of length one.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2013-12-26 19:09:26 +01:00
parent 3aedebe74b
commit c00889f9eb
1 changed files with 1 additions and 0 deletions

View File

@ -583,6 +583,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count,
memset(&udsif, 0, sizeof(udsif)); memset(&udsif, 0, sizeof(udsif));
snprintf(udsif.name, sizeof(udsif.name), "%s", uds_path); snprintf(udsif.name, sizeof(udsif.name), "%s", uds_path);
udsif.transport = TRANS_UDS; udsif.transport = TRANS_UDS;
udsif.delay_filter_length = 1;
clock_gettime(CLOCK_REALTIME, &ts); clock_gettime(CLOCK_REALTIME, &ts);
srandom(ts.tv_sec ^ ts.tv_nsec); srandom(ts.tv_sec ^ ts.tv_nsec);