diff options
author | Ryan Zezeski <rpz@joyent.com> | 2016-08-17 14:28:15 -0700 |
---|---|---|
committer | Ryan Zezeski <rpz@joyent.com> | 2016-08-19 12:25:59 -0400 |
commit | 926f7c1c9f70982389660a5240eabff26fec931b (patch) | |
tree | 1fd05b1747a36da27664fde5f25d0e19fef31fb0 | |
parent | 33736cadb4f8ed87b0c2c0a7be9a00c649f87673 (diff) | |
download | illumos-joyent-926f7c1c9f70982389660a5240eabff26fec931b.tar.gz |
OS-4601 lxbrand clock_getres() returns success for invalid clocks
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approved by: Jerry Jelinek <jerry.jelinek@joyent.com>
-rw-r--r-- | usr/src/uts/common/brand/lx/syscall/lx_timer.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/usr/src/uts/common/brand/lx/syscall/lx_timer.c b/usr/src/uts/common/brand/lx/syscall/lx_timer.c index c102334156..17ca59b534 100644 --- a/usr/src/uts/common/brand/lx/syscall/lx_timer.c +++ b/usr/src/uts/common/brand/lx/syscall/lx_timer.c @@ -257,15 +257,22 @@ lx_clock_getres(int clock, timespec_t *tp) { lx_clock_backend_t *backend; - if (tp == NULL) { - return (0); - } - if ((backend = LX_CLOCK_BACKEND(clock)) == NULL) { lx_clock_unsupported(clock); return (set_errno(EINVAL)); } + /* + * It is important this check is performed after the clock + * check. Both glibc and musl, in their clock_getcpuclockid(), + * use clock_getres() with a NULL tp to validate a clock + * value. Performing the tp check before the clock check could + * indicate a valid clock to libc when it shouldn't. + */ + if (tp == NULL) { + return (0); + } + return (backend->lclk_clock_getres(backend->lclk_ntv_id, tp)); } |