summaryrefslogtreecommitdiff
path: root/usr/src/lib/libpkg/common/ncgrpw.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@nexenta.com>2010-11-15 20:03:27 -0800
committerGarrett D'Amore <garrett@nexenta.com>2010-11-15 20:03:27 -0800
commit4656d4747c8743290bfbe910c64cd75eb4e4af8d (patch)
tree241d8b3f0b8796e33937c6a27c670eba002f8f04 /usr/src/lib/libpkg/common/ncgrpw.c
parent60bec29ea42d65ac648c69b0fb189273e286ca57 (diff)
downloadillumos-joyent-4656d4747c8743290bfbe910c64cd75eb4e4af8d.tar.gz
420 remove patch (sparse package) support from svr4 pkg
421 libpkg and libadm need to be lint clean Reviewed by: gwr@nexenta.com Reviewed by: peter.tribble@gmail.com Approved by: gwr@nexenta.com
Diffstat (limited to 'usr/src/lib/libpkg/common/ncgrpw.c')
-rw-r--r--usr/src/lib/libpkg/common/ncgrpw.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/usr/src/lib/libpkg/common/ncgrpw.c b/usr/src/lib/libpkg/common/ncgrpw.c
index cf3151164e..52eb9f813b 100644
--- a/usr/src/lib/libpkg/common/ncgrpw.c
+++ b/usr/src/lib/libpkg/common/ncgrpw.c
@@ -595,15 +595,16 @@ clgrnam(char *nam)
struct group *gr;
char *instroot, *buf;
FILE *gr_ptr;
+ size_t bufsz;
if ((instroot = get_install_root()) != NULL) {
- if ((buf = (char *)malloc(strlen(instroot) +
- strlen(GROUP) + 1)) == NULL) {
+ bufsz = strlen(instroot) + strlen(GROUP) + 1;
+ if ((buf = (char *)malloc(bufsz)) == NULL) {
(void) fprintf(stderr,
- pkg_gt(ERR_MALLOC), "clgrnam()",
- strlen(instroot) + strlen(GROUP), "buf");
+ pkg_gt(ERR_MALLOC), "clgrnam()",
+ strlen(instroot) + strlen(GROUP), "buf");
}
- (void) sprintf(buf, "%s%s", instroot, GROUP);
+ (void) snprintf(buf, bufsz, "%s%s", instroot, GROUP);
if ((gr_ptr = fopen(buf, "r")) == NULL) {
free(buf);
return (NULL);
@@ -636,13 +637,12 @@ clpwnam(char *nam)
FILE *pw_ptr;
if ((instroot = get_install_root()) != NULL) {
- if ((buf = (char *)malloc(strlen(instroot) +
- strlen(PASSWD) + 1)) == NULL) {
+ if (asprintf(&buf, "%s%s", instroot, PASSWD) < 0) {
(void) fprintf(stderr,
- pkg_gt(ERR_MALLOC), "clpwnam()",
- strlen(instroot) + strlen(PASSWD), "buf");
+ pkg_gt(ERR_MALLOC), "clpwnam()",
+ strlen(instroot) + strlen(PASSWD), "buf");
+ return (NULL);
}
- (void) sprintf(buf, "%s%s", instroot, PASSWD);
if ((pw_ptr = fopen(buf, "r")) == NULL) {
free(buf);
return (NULL);
@@ -675,13 +675,13 @@ clgrgid(gid_t gid)
FILE *gr_ptr;
if ((instroot = get_install_root()) != NULL) {
- if ((buf = (char *)malloc(strlen(instroot) +
- strlen(GROUP) + 1)) == NULL) {
+ if (asprintf(&buf, "%s%s", instroot, GROUP) < 0) {
(void) fprintf(stderr,
- pkg_gt(ERR_MALLOC), "clgrgid()",
- strlen(instroot) + strlen(GROUP), "buf");
+ pkg_gt(ERR_MALLOC), "clgrgid()",
+ strlen(instroot) + strlen(GROUP), "buf");
+ return (NULL);
}
- (void) sprintf(buf, "%s%s", instroot, GROUP);
+
if ((gr_ptr = fopen(buf, "r")) == NULL) {
free(buf);
return (NULL);
@@ -714,13 +714,11 @@ clpwuid(uid_t uid)
FILE *pw_ptr;
if ((instroot = get_install_root()) != NULL) {
- if ((buf = (char *)malloc(strlen(instroot) +
- strlen(PASSWD) + 1)) == NULL) {
- (void) fprintf(stderr,
- pkg_gt(ERR_MALLOC), "clpwuid()",
- strlen(instroot) + strlen(PASSWD), "buf");
+ if (asprintf(&buf, "%s%s", instroot, PASSWD) < 0) {
+ (void) fprintf(stderr, pkg_gt(ERR_MALLOC), "clpwuid()",
+ strlen(instroot) + strlen(PASSWD), "buf");
+ return (NULL);
}
- (void) sprintf(buf, "%s%s", instroot, PASSWD);
if ((pw_ptr = fopen(buf, "r")) == NULL) {
free(buf);
return (NULL);