diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-07-31 13:00:21 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-07-31 13:00:21 +0000 |
| commit | a43f1df58a9e20639c60ab24da9193c2ff8e074e (patch) | |
| tree | 2c782258c5ed0ceff90367f775728dc5cb1e9a12 /usr/src/lib | |
| parent | 2b6211c70cd9e899b15e259d53790f01e46bb88a (diff) | |
| parent | d65dfb0a6855414a1ff916b896e8be0fbe0d212a (diff) | |
| download | illumos-joyent-a43f1df58a9e20639c60ab24da9193c2ff8e074e.tar.gz | |
[illumos-gate merge]
commit d65dfb0a6855414a1ff916b896e8be0fbe0d212a
8499 ficl: this statement may fall through
commit e07d85f87c3920e032adb855fdc500e4616c7718
7875 libcurses: multiple misleading-indentation errors
commit f1cdbd3731f01314c1d46f05280ad63f1770fdc6
8546 want recallocarray(3C) and freezero(3C)
commit 0b905b49d460a57773d88d714cd880ffe0182b7c
5980 in-kernel inet_ntop should format IPv4 addresses like userland one
commit 3facafd61791b16f112797f1b07dde00ab6b9a59
8487 cfgadm_plugins/shp: memory leak in cfga_get_condition()
commit a3bcc60de108dc761615b2b9561d6dc76971f471
8543 nss_ldap crashes handling a group with no gidnumber attribute
commit b2ce6e4ebc262a57e5c5d0224b2577526261a0e4
8463 common/acl: 'resultcount' may be used uninitialized in this function
commit 83e86541459022f059e0bf50ebbc33fc8ec2d62e
8486 libdiskmgt: memory leak in slice_get_stats()
commit 7f6d142fc0001e76967b1f047b6df5bc4c5d9082
8399 sun_fc: in C++11 destructors default to noexcept
commit 3dde7c95de085cfe31f989eff6cefb775563eeb8
8528 Want Chelsio T6 support
Diffstat (limited to 'usr/src/lib')
| -rw-r--r-- | usr/src/lib/cfgadm_plugins/shp/common/shp.c | 11 | ||||
| -rw-r--r-- | usr/src/lib/libc/amd64/Makefile | 2 | ||||
| -rw-r--r-- | usr/src/lib/libc/i386/Makefile.com | 2 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/gen/freezero.c | 27 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/gen/reallocarray.c | 8 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/gen/recallocarray.c | 80 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/llib-lc | 6 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/mapfile-vers | 13 | ||||
| -rw-r--r-- | usr/src/lib/libc/sparc/Makefile.com | 2 | ||||
| -rw-r--r-- | usr/src/lib/libc/sparcv9/Makefile.com | 2 | ||||
| -rw-r--r-- | usr/src/lib/libcurses/screen/termcap.ed | 25 | ||||
| -rw-r--r-- | usr/src/lib/libcurses/screen/tparm.c | 84 | ||||
| -rw-r--r-- | usr/src/lib/libcurses/screen/waddch.c | 27 | ||||
| -rw-r--r-- | usr/src/lib/libcurses/screen/wnoutref.c | 22 | ||||
| -rw-r--r-- | usr/src/lib/libcurses/screen/wrefresh.c | 83 | ||||
| -rw-r--r-- | usr/src/lib/libdiskmgt/common/slice.c | 4 | ||||
| -rw-r--r-- | usr/src/lib/nsswitch/ldap/common/getgrent.c | 70 | ||||
| -rw-r--r-- | usr/src/lib/sun_fc/Makefile.com | 4 |
18 files changed, 309 insertions, 163 deletions
diff --git a/usr/src/lib/cfgadm_plugins/shp/common/shp.c b/usr/src/lib/cfgadm_plugins/shp/common/shp.c index f8bbda4f7f..39647d9ad5 100644 --- a/usr/src/lib/cfgadm_plugins/shp/common/shp.c +++ b/usr/src/lib/cfgadm_plugins/shp/common/shp.c @@ -1344,15 +1344,17 @@ static cfga_err_t cfga_get_condition(hp_node_t node, ap_condition_t *cond) { char *condition; + char *tmpc; + cfga_err_t ret = CFGA_OK; /* "condition" bus specific commands */ if (hp_get_private(node, PCIEHPC_PROP_SLOT_CONDITION, - &condition) != 0) { + &tmpc) != 0) { *cond = AP_COND_UNKNOWN; return (CFGA_ERROR); } - condition = get_val_from_result(condition); + condition = get_val_from_result(tmpc); if (strcmp(condition, PCIEHPC_PROP_COND_OK) == 0) *cond = AP_COND_OK; @@ -1365,9 +1367,10 @@ cfga_get_condition(hp_node_t node, ap_condition_t *cond) else if (strcmp(condition, PCIEHPC_PROP_COND_UNKNOWN) == 0) *cond = AP_COND_UNKNOWN; else - return (CFGA_ERROR); + ret = CFGA_ERROR; - return (CFGA_OK); + free(tmpc); + return (ret); } /*ARGSUSED*/ diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile index a93a2c54a4..e5449fbbfc 100644 --- a/usr/src/lib/libc/amd64/Makefile +++ b/usr/src/lib/libc/amd64/Makefile @@ -395,6 +395,7 @@ PORTGEN= \ flock.o \ fls.o \ fmtmsg.o \ + freezero.o \ ftime.o \ ftok.o \ fts.o \ @@ -513,6 +514,7 @@ PORTGEN= \ readdir.o \ readdir_r.o \ reallocarray.o \ + recallocarray.o \ realpath.o \ reboot.o \ regexpr.o \ diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com index d4999bdfb1..c81a7c62a1 100644 --- a/usr/src/lib/libc/i386/Makefile.com +++ b/usr/src/lib/libc/i386/Makefile.com @@ -431,6 +431,7 @@ PORTGEN= \ flock.o \ fls.o \ fmtmsg.o \ + freezero.o \ ftime.o \ ftok.o \ fts.o \ @@ -549,6 +550,7 @@ PORTGEN= \ readdir.o \ readdir_r.o \ reallocarray.o \ + recallocarray.o \ realpath.o \ reboot.o \ regexpr.o \ diff --git a/usr/src/lib/libc/port/gen/freezero.c b/usr/src/lib/libc/port/gen/freezero.c new file mode 100644 index 0000000000..9280590aa6 --- /dev/null +++ b/usr/src/lib/libc/port/gen/freezero.c @@ -0,0 +1,27 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 Nexenta Systems, Inc. + */ + +#include <stdlib.h> +#include <strings.h> + +void +freezero(void *ptr, size_t size) +{ + if (ptr == NULL) + return; + + explicit_bzero(ptr, size); + free(ptr); +} diff --git a/usr/src/lib/libc/port/gen/reallocarray.c b/usr/src/lib/libc/port/gen/reallocarray.c index ecc4d25fa9..ba1f028c42 100644 --- a/usr/src/lib/libc/port/gen/reallocarray.c +++ b/usr/src/lib/libc/port/gen/reallocarray.c @@ -26,12 +26,12 @@ #define MUL_NO_OVERFLOW ((size_t)1 << (sizeof (size_t) * 4)) void * -reallocarray(void *optr, size_t nmemb, size_t size) +reallocarray(void *ptr, size_t nelem, size_t elsize) { - if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && - nmemb > 0 && SIZE_MAX / nmemb < size) { + if ((nelem >= MUL_NO_OVERFLOW || elsize >= MUL_NO_OVERFLOW) && + nelem > 0 && SIZE_MAX / nelem < elsize) { errno = ENOMEM; return (NULL); } - return (realloc(optr, size * nmemb)); + return (realloc(ptr, elsize * nelem)); } diff --git a/usr/src/lib/libc/port/gen/recallocarray.c b/usr/src/lib/libc/port/gen/recallocarray.c new file mode 100644 index 0000000000..1edcbef960 --- /dev/null +++ b/usr/src/lib/libc/port/gen/recallocarray.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2008, 2017 Otto Moerbeek <otto@drijf.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <errno.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <unistd.h> + +/* + * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX + * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW + */ +#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof (size_t) * 4)) + +void * +recallocarray(void *ptr, size_t oldnelem, size_t newnelem, size_t elsize) +{ + size_t oldsize, newsize; + void *newptr; + + if (ptr == NULL) + return (calloc(newnelem, elsize)); + + if ((newnelem >= MUL_NO_OVERFLOW || elsize >= MUL_NO_OVERFLOW) && + newnelem > 0 && SIZE_MAX / newnelem < elsize) { + errno = ENOMEM; + return (NULL); + } + newsize = newnelem * elsize; + + if ((oldnelem >= MUL_NO_OVERFLOW || elsize >= MUL_NO_OVERFLOW) && + oldnelem > 0 && SIZE_MAX / oldnelem < elsize) { + errno = EINVAL; + return (NULL); + } + oldsize = oldnelem * elsize; + + /* + * Don't bother too much if we're shrinking just a bit, + * we do not shrink for series of small steps, oh well. + */ + if (newsize <= oldsize) { + size_t d = oldsize - newsize; + + if (d < oldsize / 2 && d < getpagesize()) { + (void) memset((char *)ptr + newsize, 0, d); + return (ptr); + } + } + + newptr = malloc(newsize); + if (newptr == NULL) + return (NULL); + + if (newsize > oldsize) { + (void) memcpy(newptr, ptr, oldsize); + (void) memset((char *)newptr + oldsize, 0, newsize - oldsize); + } else { + (void) memcpy(newptr, ptr, newsize); + } + + explicit_bzero(ptr, oldsize); + free(ptr); + + return (newptr); +} diff --git a/usr/src/lib/libc/port/llib-lc b/usr/src/lib/libc/port/llib-lc index 4ae1c835c9..350dfc71dd 100644 --- a/usr/src/lib/libc/port/llib-lc +++ b/usr/src/lib/libc/port/llib-lc @@ -439,6 +439,9 @@ int addseverity(int value, const char *string); int fmtmsg(long class, const char *label, int severity, const char *text, const char *action, const char *tag); +/* freezero.c */ +void freezero(void *, size_t); + /* ftime.c */ int ftime(struct timeb *tp); @@ -832,6 +835,9 @@ struct dirent *readdir(DIR *dirp); /* reallocarray.c */ void *reallocarray(void *, size_t, size_t); +/* recallocarray.c */ +void *recallocarray(void *, size_t, size_t, size_t); + /* realpath.c */ char *realpath(const char *_RESTRICT_KYWD raw, char *_RESTRICT_KYWD canon); diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers index e6acdc87bd..d70de892a1 100644 --- a/usr/src/lib/libc/port/mapfile-vers +++ b/usr/src/lib/libc/port/mapfile-vers @@ -18,17 +18,16 @@ # # CDDL HEADER END # + # # Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. -# -# Copyright 2010 Nexenta Systems, Inc. All rights reserved. -# Use is subject to license terms. -# +# Copyright 2017 Nexenta Systems, Inc. # Copyright (c) 2012 by Delphix. All rights reserved. # Copyright 2016 Joyent, Inc. # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. # Copyright (c) 2013 Gary Mills # Copyright 2014 Garrett D'Amore <garrett@damore.org> +# # # MAPFILE HEADER START @@ -93,6 +92,12 @@ $if _x86 && _ELF64 $add amd64 $endif +SYMBOL_VERSION ILLUMOS_0.24 { # openbsd compat + protected: + freezero; + recallocarray; +} ILLUMOS_0.23; + SYMBOL_VERSION ILLUMOS_0.23 { # openbsd compat protected: fts_children; diff --git a/usr/src/lib/libc/sparc/Makefile.com b/usr/src/lib/libc/sparc/Makefile.com index baaeba0ac5..e870b9fc87 100644 --- a/usr/src/lib/libc/sparc/Makefile.com +++ b/usr/src/lib/libc/sparc/Makefile.com @@ -456,6 +456,7 @@ PORTGEN= \ flock.o \ fls.o \ fmtmsg.o \ + freezero.o \ ftime.o \ ftok.o \ fts.o \ @@ -575,6 +576,7 @@ PORTGEN= \ readdir.o \ readdir_r.o \ reallocarray.o \ + recallocarray.o \ realpath.o \ reboot.o \ regexpr.o \ diff --git a/usr/src/lib/libc/sparcv9/Makefile.com b/usr/src/lib/libc/sparcv9/Makefile.com index b465048987..9d46f88b86 100644 --- a/usr/src/lib/libc/sparcv9/Makefile.com +++ b/usr/src/lib/libc/sparcv9/Makefile.com @@ -414,6 +414,7 @@ PORTGEN= \ flock.o \ fls.o \ fmtmsg.o \ + freezero.o \ ftime.o \ ftok.o \ fts.o \ @@ -533,6 +534,7 @@ PORTGEN= \ readdir.o \ readdir_r.o \ reallocarray.o \ + recallocarray.o \ realpath.o \ reboot.o \ regexpr.o \ diff --git a/usr/src/lib/libcurses/screen/termcap.ed b/usr/src/lib/libcurses/screen/termcap.ed index da57358091..6375be8dfb 100644 --- a/usr/src/lib/libcurses/screen/termcap.ed +++ b/usr/src/lib/libcurses/screen/termcap.ed @@ -16,8 +16,6 @@ H * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Simulation of termcap using terminfo. * This file is created from termcap.ed. DO NOT EDIT ME! @@ -60,17 +58,18 @@ _stripdelays(char *inbuf, char *outbuf, int size) if (inbuf == NULL) return (0); - else - while (size && *inbuf) - if (*inbuf == '$' && *(inbuf+1) == '<') - /* LINTED */ - while (*inbuf && *inbuf++ != '>'); - else { - size--; - *outbuf++ = *inbuf++; - *outbuf = 0; - } - return (saveoutbuf); + + while (size && *inbuf) { + if (*inbuf == '$' && *(inbuf+1) == '<') { + /* LINTED */ + while (*inbuf && *inbuf++ != '>'); + } else { + size--; + *outbuf++ = *inbuf++; + *outbuf = 0; + } + } + return (saveoutbuf); } /* generated by sort on caps */ diff --git a/usr/src/lib/libcurses/screen/tparm.c b/usr/src/lib/libcurses/screen/tparm.c index 99d03d5326..49f2d3852d 100644 --- a/usr/src/lib/libcurses/screen/tparm.c +++ b/usr/src/lib/libcurses/screen/tparm.c @@ -135,7 +135,8 @@ pop(STACK *st) return (st->stack[st->top--]); } -/* The following routine was added to make lint shut up about converting from +/* + * The following routine was added to make lint shut up about converting from * a long to a char *. It is identical to the pop routine, except for the * cast on the return statement. */ @@ -165,16 +166,16 @@ free_stack(STACK *st) } -char * +char * tparm_p0(char *instring) { long p[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; return (tparm(instring, p[0], p[1], p[2], p[3], p[4], p[5], p[6], - p[7], p[8])); + p[7], p[8])); } -char * +char * tparm_p1(char *instring, long l1) { long p[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -182,10 +183,10 @@ tparm_p1(char *instring, long l1) p[0] = l1; return (tparm(instring, p[0], p[1], p[2], p[3], p[4], p[5], p[6], - p[7], p[8])); + p[7], p[8])); } -char * +char * tparm_p2(char *instring, long l1, long l2) { long p[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -194,10 +195,10 @@ tparm_p2(char *instring, long l1, long l2) p[1] = l2; return (tparm(instring, p[0], p[1], p[2], p[3], p[4], p[5], p[6], - p[7], p[8])); + p[7], p[8])); } -char * +char * tparm_p3(char *instring, long l1, long l2, long l3) { long p[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -207,10 +208,10 @@ tparm_p3(char *instring, long l1, long l2, long l3) p[2] = l3; return (tparm(instring, p[0], p[1], p[2], p[3], p[4], p[5], p[6], - p[7], p[8])); + p[7], p[8])); } -char * +char * tparm_p4(char *instring, long l1, long l2, long l3, long l4) { long p[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -221,12 +222,12 @@ tparm_p4(char *instring, long l1, long l2, long l3, long l4) p[3] = l4; return (tparm(instring, p[0], p[1], p[2], p[3], p[4], p[5], p[6], - p[7], p[8])); + p[7], p[8])); } -char * +char * tparm_p7(char *instring, long l1, long l2, long l3, long l4, long l5, long l6, - long l7) + long l7) { long p[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -239,13 +240,13 @@ tparm_p7(char *instring, long l1, long l2, long l3, long l4, long l5, long l6, p[6] = l7; return (tparm(instring, p[0], p[1], p[2], p[3], p[4], p[5], p[6], - p[7], p[8])); + p[7], p[8])); } /* VARARGS */ -char * +char * tparm(char *instring, long fp1, long fp2, long p3, long p4, - long p5, long p6, long p7, long p8, long p9) + long p5, long p6, long p7, long p8, long p9) { static char result[512]; static char added[100]; @@ -257,7 +258,7 @@ tparm(char *instring, long fp1, long fp2, long p3, long p4, long op; long op2; int sign; - int onrow = 0; + volatile int onrow = 0; volatile long p1 = fp1, p2 = fp2; /* copy in case < 2 actual parms */ char *xp; char formatbuffer[100]; @@ -386,8 +387,7 @@ tparm(char *instring, long fp1, long fp2, long p3, long p4, * now. */ if (c == 's') - (void) sprintf(outp, formatbuffer, - (char *) op); + (void) sprintf(outp, formatbuffer, (char *)op); else (void) sprintf(outp, formatbuffer, op); /* @@ -398,7 +398,7 @@ tparm(char *instring, long fp1, long fp2, long p3, long p4, * BSD emulations are particularly confusing. */ while (*outp) - outp++; + outp++; (void) pop(&stk); continue; @@ -425,24 +425,24 @@ tparm(char *instring, long fp1, long fp2, long p3, long p4, */ switch (op) { /* - * Null. Problem is that our - * output is, by convention, null terminated. - */ + * Null. Problem is that our + * output is, by convention, null terminated. + */ case 0: op = 0200; /* Parity should */ /* be ignored. */ break; /* - * Control D. Problem is that certain very - * ancient hardware hangs up on this, so the - * current(!) UNIX tty driver doesn't xmit - * control D's. - */ + * Control D. Problem is that certain very + * ancient hardware hangs up on this, so the + * current(!) UNIX tty driver doesn't xmit + * control D's. + */ case _CHCTRL('d'): /* - * Newline. Problem is that UNIX will expand - * this to CRLF. - */ + * Newline. Problem is that UNIX will expand + * this to CRLF. + */ case '\n': xp = (onrow ? cursor_down : cursor_right); @@ -486,10 +486,10 @@ tparm(char *instring, long fp1, long fp2, long p3, long p4, break; /* - * %i: shorthand for increment first two parms. - * Useful for terminals that start numbering from - * one instead of zero(like ANSI terminals). - */ + * %i: shorthand for increment first two parms. + * Useful for terminals that start numbering from + * one instead of zero(like ANSI terminals). + */ case 'i': p1++; p2++; @@ -545,8 +545,8 @@ tparm(char *instring, long fp1, long fp2, long p3, long p4, } else { if (*cp >= 'A' && *cp <= 'Z') { regs[*cp++ - 'A'] = - /* LINTED */ - (short) pop(&stk); + /* LINTED */ + (short)pop(&stk); } #ifdef DEBUG else if (outf) { @@ -692,17 +692,17 @@ tparm(char *instring, long fp1, long fp2, long p3, long p4, /* Sorry, no unary minus, because minus is binary. */ /* - * If-then-else. Implemented by a low level hack of - * skipping forward until the match is found, counting - * nested if-then-elses. - */ + * If-then-else. Implemented by a low level hack of + * skipping forward until the match is found, counting + * nested if-then-elses. + */ case '?': /* IF - just a marker */ break; case 't': /* THEN - branch if false */ if (!pop(&stk)) cp = _branchto(cp, 'e'); - break; + break; case 'e': /* ELSE - branch to ENDIF */ cp = _branchto(cp, ';'); diff --git a/usr/src/lib/libcurses/screen/waddch.c b/usr/src/lib/libcurses/screen/waddch.c index 31c7627981..91cfa65c42 100644 --- a/usr/src/lib/libcurses/screen/waddch.c +++ b/usr/src/lib/libcurses/screen/waddch.c @@ -37,8 +37,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /*LINTLIBRARY*/ #include <sys/types.h> @@ -100,12 +98,13 @@ move_to_begin_line: chtype space = ' ' | rawattrs; if ((newx = x + (TABSIZE - - (x % TABSIZE))) > win->_maxx) + (x % TABSIZE))) > win->_maxx) { newx = win->_maxx; - for (; x < newx; x++) - if (waddch(win, - space) == ERR) - goto next; + } + for (; x < newx; x++) { + if (waddch(win, space) == ERR) + goto next; + } } else { if ((waddch(win, (chtype) '^'|rawattrs) == ERR) || @@ -173,18 +172,22 @@ new_line: } #endif /* DEBUG */ break; - } else + } else { savimmed = 1; - } else + } + } else { y++; - x = 0; - } else + } + x = 0; + } else { savimmed += 2; + } #ifdef FULLDEBUG - if (outf) + if (outf) { fprintf(outf, "ADDCH: 2: y = %d, x = %d, " "firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); + } #endif /* FULLDEBUG */ break; } diff --git a/usr/src/lib/libcurses/screen/wnoutref.c b/usr/src/lib/libcurses/screen/wnoutref.c index 3f9dd35054..8f1e7050c8 100644 --- a/usr/src/lib/libcurses/screen/wnoutref.c +++ b/usr/src/lib/libcurses/screen/wnoutref.c @@ -37,8 +37,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /*LINTLIBRARY*/ #include <string.h> @@ -53,8 +51,8 @@ wnoutrefresh(WINDOW *win) short *bch, *ech, *sbch, *sech; chtype **wcp, **scp, *wc, *sc; int *hash; - short y, x, xorg, yorg, scrli, scrco, - boty, sminy, smaxy, minx, maxx, lo, hi; + short y, x, xorg, yorg, scrli, scrco, boty, sminy, smaxy, minx, + maxx, lo, hi; bool doall; if (win->_parent) @@ -138,13 +136,13 @@ wnoutrefresh(WINDOW *win) for (x = lo - 1; x >= minx; --x) if (!ISCBIT(wc[x])) break; - if (x < minx) { - for (x = lo+1; x <= maxx; ++x) - if (!ISCBIT(wc[x])) - break; - if (x > maxx) - goto nextline; - } + if (x < minx) { + for (x = lo + 1; x <= maxx; ++x) + if (!ISCBIT(wc[x])) + break; + if (x > maxx) + goto nextline; + } lo = x; } if (ISMBIT(wc[hi])) { @@ -188,7 +186,7 @@ wnoutrefresh(WINDOW *win) /* update the image */ wc = *wcp + lo; sc = *scp + lo + xorg; - (void) memcpy((char *) sc, (char *) wc, (size_t) + (void) memcpy((char *)sc, (char *)wc, (size_t) (((hi - lo) + 1) * sizeof (chtype))); /* the hash value of the line */ diff --git a/usr/src/lib/libcurses/screen/wrefresh.c b/usr/src/lib/libcurses/screen/wrefresh.c index 41a589fbe8..7b704c6d29 100644 --- a/usr/src/lib/libcurses/screen/wrefresh.c +++ b/usr/src/lib/libcurses/screen/wrefresh.c @@ -37,8 +37,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /*LINTLIBRARY*/ #include <sys/types.h> @@ -146,14 +144,14 @@ wrefresh(WINDOW *win) * If there is no exit_attribute mode, then vidupdate * could only possibly turn off one of the below three * so that's all we ask it turn off. - */ + */ vidupdate(A_NORMAL, (A_ALTCHARSET | A_STANDOUT | A_UNDERLINE), _outch); SP->fl_endwin = FALSE; #ifdef _VR2_COMPAT_CODE - _endwin = (char) FALSE; + _endwin = (char)FALSE; #endif /* _VR2_COMPAT_CODE */ } @@ -218,7 +216,7 @@ wrefresh(WINDOW *win) /* there is type-ahead */ if (!curwin && (_INPUTPENDING = _chkinput()) == TRUE) { /* LINTED */ - _VIRTTOP = (short) wy; + _VIRTTOP = (short)wy; goto done; } @@ -263,9 +261,9 @@ next: if (wy != cy || wx != cx) { (void) mvcur(cy, cx, wy, wx); /* LINTED */ - cy = (short) wy; + cy = (short)wy; /* LINTED */ - cx = (short) wx; + cx = (short)wx; } /* reset the flags */ @@ -298,8 +296,7 @@ _shove(int wy) /* allocate space for shifted line */ if (length < scrco) { - if (line) - free((char *) line); + free(line); line = (chtype *) malloc(scrco * sizeof (chtype)); length = line ? scrco : 0; } @@ -371,7 +368,7 @@ _updateln(int wy) { chtype *wcp, *scp, *wp, *sp, wc, sc; int wx, lastx, x, mtch, idch, blnkx, idcx, video_attrx, - color_attrx, maxi, endns, begns, wx_sav, multi_col; + color_attrx, maxi, endns, begns, wx_sav, multi_col; bool redraw, changed, didcolor, didvideo; redraw = (_virtscr->_firstch[wy] == _REDRAW); @@ -565,12 +562,12 @@ _updateln(int wy) _PUTS(clr_bol, 1); /* LINTED */ - cy = (short) wy; + cy = (short)wy; /* LINTED */ - cx = (short) x; + cx = (short)x; mtch = x - wx; - (void) memcpy((char *) scp, (char *) wcp, + (void) memcpy(scp, wcp, (mtch * sizeof (chtype))); wcp += mtch; scp += mtch; @@ -585,9 +582,9 @@ _updateln(int wy) if (cy != wy || cx != wx) (void) mvcur(cy, cx, wy, wx); /* LINTED */ - cy = (short) wy; + cy = (short)wy; /* LINTED */ - cx = (short) wx; + cx = (short)wx; /* update screen image */ while (wx < lastx) { @@ -609,9 +606,9 @@ _updateln(int wy) _PUTS(clr_eol, 1); /* LINTED */ - curscr->_curx = (short) wx; - /* LINTED */ - curscr->_cury = (short) wy; + curscr->_curx = (short)wx; + /* LINTED */ + curscr->_cury = (short)wy; (void) wclrtoeol(curscr); if (marks && wx > 0 && _ATTR(*(scp - 1)) != @@ -643,15 +640,21 @@ _updateln(int wy) /* color and video attributes */ if (_ATTR(wc) != curscr->_attrs) { - bool color_change = FALSE; - bool video_change = FALSE; - - if (marks) - if (_VIDEO(wc) != _VIDEO(curscr->_attrs)) - video_change = TRUE; - if (color_marks) - if (_COLOR(wc) != _COLOR(curscr->_attrs)) - color_change = TRUE; + bool color_change = FALSE; + bool video_change = FALSE; + + if (marks) { + if (_VIDEO(wc) != + _VIDEO(curscr->_attrs)) { + video_change = TRUE; + } + } + if (color_marks) { + if (_COLOR(wc) != + _COLOR(curscr->_attrs)) { + color_change = TRUE; + } + } /* the following may occurs when, for */ /* example the application */ @@ -694,8 +697,8 @@ _updateln(int wy) color_attrx); /* * sc = _COLOR(curscr->_y[wy][color_attrx]); - *_VIDS(sc, (~sc & A_COLOR)); - */ + * _VIDS(sc, (~sc & A_COLOR)); + */ _VIDS(_COLOR(_virtscr->_y[wy] [color_attrx]), _COLOR(_virtscr->_y[wy] @@ -762,7 +765,7 @@ done: if (_DARKCHAR(*scp)) break; /* LINTED */ - _BEGNS[wy] = (short) wx; + _BEGNS[wy] = (short)wx; if (wx == scrco) _ENDNS[wy] = -1; else { @@ -772,7 +775,7 @@ done: if (_DARKCHAR(*scp)) break; /* LINTED */ - _ENDNS[wy] = (short) wx; + _ENDNS[wy] = (short)wx; } /* update the hash structure */ @@ -925,7 +928,7 @@ do_insert_char: /* update the screen image */ for (x1 = length - 1, x2 = length - idch - 1; x2 >= 0; --x1, --x2) scp[x1] = scp[x2]; - (void) memcpy((char *) scp, (char *) wcp, idch * sizeof (chtype)); + (void) memcpy(scp, wcp, idch * sizeof (chtype)); *id = idch; return (match + idch); @@ -1096,7 +1099,7 @@ _rmargin(int wx) /* update screen image */ /* LINTED */ - cx = (short) wx; + cx = (short)wx; curscr->_y[cy][wx] = wcp[wx]; for (x = wx + 1; x < scrco; ++x) { (void) _outwch(wcp[x]); @@ -1205,13 +1208,13 @@ _useceod(int topy, int boty) _PUTS(clear_screen, scrli); cy = 0; cx = 0; (void) werase(curscr); - } else + } else { /* use clear-to-end-of-display or delete lines */ if (clr_eos || (parm_delete_line && !memory_below)) { (void) mvcur(cy, cx, topy, 0); /* LINTED */ - cy = (short) topy; + cy = (short)topy; cx = 0; /* SS: colors */ if (back_color_erase) @@ -1221,15 +1224,17 @@ _useceod(int topy, int boty) /* update curscr */ /* LINTED */ - curscr->_cury = (short) topy; + curscr->_cury = (short)topy; curscr->_curx = 0; (void) wclrtobot(curscr); - } else + } else { /* no hardware support */ return; + } + } - /* correct the update structure */ - (void) wtouchln(_virtscr, topy, scrli, FALSE); + /* correct the update structure */ + (void) wtouchln(_virtscr, topy, scrli, FALSE); } diff --git a/usr/src/lib/libdiskmgt/common/slice.c b/usr/src/lib/libdiskmgt/common/slice.c index 5a37d6f4e6..11b7a86ff7 100644 --- a/usr/src/lib/libdiskmgt/common/slice.c +++ b/usr/src/lib/libdiskmgt/common/slice.c @@ -208,7 +208,8 @@ slice_get_stats(descriptor_t *dp, int stat_type, int *errp) } if ((*errp = add_inuse(dp->name, stats)) != 0) { - return (NULL); + nvlist_free(stats); + return (NULL); } /* if no cluster use, check for a use of the local name */ @@ -248,6 +249,7 @@ slice_get_stats(descriptor_t *dp, int stat_type, int *errp) sizeof (localpath)); if ((*errp = add_inuse(localpath, stats)) != 0) { + nvlist_free(stats); return (NULL); } diff --git a/usr/src/lib/nsswitch/ldap/common/getgrent.c b/usr/src/lib/nsswitch/ldap/common/getgrent.c index 2682e6e2f8..291d16dbc6 100644 --- a/usr/src/lib/nsswitch/ldap/common/getgrent.c +++ b/usr/src/lib/nsswitch/ldap/common/getgrent.c @@ -21,6 +21,8 @@ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2017 Nexenta Systems, Inc. All rights reserved. */ #include <grp.h> @@ -353,42 +355,50 @@ getbymember(ldap_backend_ptr be, void *a) username = (char *)argp->username; result = (ns_ldap_result_t *)be->result; curEntry = (ns_ldap_entry_t *)result->entry; - for (i = 0; i < result->entries_count; i++) { + for (i = 0; i < result->entries_count && curEntry != NULL; i++) { membervalue = __ns_ldap_getAttr(curEntry, "memberUid"); - if (membervalue) { - for (j = 0; membervalue[j]; j++) { - /* - * If we find an '=' in the member attribute - * value, treat it as a DN, otherwise as a - * username. - */ - if (member_str = strchr(membervalue[j], '=')) { - member_str++; /* skip over the '=' */ - member_str = strtok_r(member_str, ",", - &strtok_state); - } else { - member_str = membervalue[j]; + if (membervalue == NULL) { + curEntry = curEntry->next; + continue; + } + for (j = 0; membervalue[j]; j++) { + /* + * If we find an '=' in the member attribute + * value, treat it as a DN, otherwise as a + * username. + */ + if (member_str = strchr(membervalue[j], '=')) { + member_str++; /* skip over the '=' */ + member_str = strtok_r(member_str, ",", + &strtok_state); + } else { + member_str = membervalue[j]; + } + if (member_str != NULL && + strcmp(member_str, username) == 0) { + groupvalue = __ns_ldap_getAttr(curEntry, + "gidnumber"); + if (groupvalue == NULL || + groupvalue[0] == NULL) { + /* Drop this group from the list */ + break; } - if (member_str && - strcmp(member_str, username) == NULL) { - groupvalue = __ns_ldap_getAttr(curEntry, - "gidnumber"); - gid = (gid_t)strtol(groupvalue[0], - (char **)NULL, 10); - if (argp->numgids < argp->maxgids) { - for (k = 0; k < argp->numgids; - k++) { - if (argp->gid_array[k] - == gid) - /* already exists */ - break; + errno = 0; + gid = (gid_t)strtol(groupvalue[0], + (char **)NULL, 10); + + if (errno == 0 && + argp->numgids < argp->maxgids) { + for (k = 0; k < argp->numgids; k++) { + if (argp->gid_array[k] == gid) + /* already exists */ + break; } if (k == argp->numgids) argp->gid_array[argp->numgids++] = gid; - } - break; } + break; } } curEntry = curEntry->next; @@ -421,7 +431,7 @@ static ldap_backend_op_t gr_ops[] = { /*ARGSUSED0*/ nss_backend_t * _nss_ldap_group_constr(const char *dummy1, const char *dummy2, - const char *dummy3) + const char *dummy3) { return ((nss_backend_t *)_nss_ldap_constr(gr_ops, diff --git a/usr/src/lib/sun_fc/Makefile.com b/usr/src/lib/sun_fc/Makefile.com index 906c82a1ba..7eb64ad1b5 100644 --- a/usr/src/lib/sun_fc/Makefile.com +++ b/usr/src/lib/sun_fc/Makefile.com @@ -132,9 +132,9 @@ INCS += -I$(SRCDIR) INCS += -I$(SRC)/lib/hbaapi/common CCFLAGS += -D_POSIX_PTHREAD_SEMANTICS -CCFLAGS += -compat=5 +CCFLAGS += -compat=5 -_g++=-std=c++98 CCFLAGS64 += -D_POSIX_PTHREAD_SEMANTICS -CCFLAGS64 += -compat=5 +CCFLAGS64 += -compat=5 -_g++=-std=c++98 CPPFLAGS += $(INCS) -DBUILD_TIME='"Wed Sep 24 12:00:00 2008"' LDLIBS += -ldevinfo |
