Print this page
3946 ::gcore
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

*** 18,28 **** * * CDDL HEADER END */ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. ! * * Program to examine or set process privileges. */ #include <stdio.h> #include <stdio_ext.h> --- 18,32 ---- * * CDDL HEADER END */ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. ! */ ! /* ! * Copyright (c) 2013 by Delphix. All rights reserved. ! */ ! /* * Program to examine or set process privileges. */ #include <stdio.h> #include <stdio_ext.h>
*** 156,175 **** } static int look(char *arg) { - static size_t pprivsz = sizeof (prpriv_t); - static prpriv_t *ppriv; - struct ps_prochandle *Pr; int gcode; size_t sz; void *pdata; char *x; int i; boolean_t nodata; procname = arg; /* for perr() */ if ((Pr = proc_arg_grab(arg, set ? PR_ARG_PIDS : PR_ARG_ANY, PGRAB_RETAIN | PGRAB_FORCE | (set ? 0 : PGRAB_RDONLY) | --- 160,177 ---- } static int look(char *arg) { struct ps_prochandle *Pr; int gcode; size_t sz; void *pdata; char *x; int i; boolean_t nodata; + prpriv_t *ppriv; procname = arg; /* for perr() */ if ((Pr = proc_arg_grab(arg, set ? PR_ARG_PIDS : PR_ARG_ANY, PGRAB_RETAIN | PGRAB_FORCE | (set ? 0 : PGRAB_RDONLY) |
*** 177,195 **** (void) fprintf(stderr, "%s: cannot examine %s: %s\n", command, arg, Pgrab_error(gcode)); return (1); } ! if (ppriv == NULL) ! ppriv = malloc(pprivsz); ! ! if (Ppriv(Pr, ppriv, pprivsz) == -1) { perr(command); Prelease(Pr, 0); return (1); } - sz = PRIV_PRPRIV_SIZE(ppriv); /* * The ppriv fields are unsigned and may overflow, so check them * separately. Size must be word aligned, so check that too. --- 179,193 ---- (void) fprintf(stderr, "%s: cannot examine %s: %s\n", command, arg, Pgrab_error(gcode)); return (1); } ! if (Ppriv(Pr, &ppriv) == -1) { perr(command); Prelease(Pr, 0); return (1); } sz = PRIV_PRPRIV_SIZE(ppriv); /* * The ppriv fields are unsigned and may overflow, so check them * separately. Size must be word aligned, so check that too.
*** 200,231 **** ppriv->pr_infosize > sz || sz > 1024 * 1024) { (void) fprintf(stderr, "%s: %s: bad PRNOTES section, size = %lx\n", command, arg, (long)sz); Prelease(Pr, 0); return (1); } - if (sz > pprivsz) { - ppriv = realloc(ppriv, sz); - - if (ppriv == NULL || Ppriv(Pr, ppriv, sz) != sz) { - perr(command); - Prelease(Pr, 0); - return (1); - } - pprivsz = sz; - } - if (set) { privupdate(ppriv, arg); if (Psetpriv(Pr, ppriv) != 0) { perr(command); Prelease(Pr, 0); return (1); } Prelease(Pr, 0); return (0); } if (Pstate(Pr) == PS_DEAD) { (void) printf("core '%s' of %d:\t%.70s\n", --- 198,221 ---- ppriv->pr_infosize > sz || sz > 1024 * 1024) { (void) fprintf(stderr, "%s: %s: bad PRNOTES section, size = %lx\n", command, arg, (long)sz); Prelease(Pr, 0); + free(ppriv); return (1); } if (set) { privupdate(ppriv, arg); if (Psetpriv(Pr, ppriv) != 0) { perr(command); Prelease(Pr, 0); + free(ppriv); return (1); } Prelease(Pr, 0); + free(ppriv); return (0); } if (Pstate(Pr) == PS_DEAD) { (void) printf("core '%s' of %d:\t%.70s\n",
*** 296,305 **** --- 286,296 ---- (void) printf("%08x", pc[j]); (void) putchar('\n'); } } Prelease(Pr, 0); + free(ppriv); return (0); } static void fatal(const char *s)