summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/my_getgrgid.c6
-rw-r--r--libbb/my_getpwuid.c6
-rw-r--r--libbb/procps.c2
3 files changed, 7 insertions, 7 deletions
diff --git a/libbb/my_getgrgid.c b/libbb/my_getgrgid.c
index 907a474..e6b8776 100644
--- a/libbb/my_getgrgid.c
+++ b/libbb/my_getgrgid.c
@@ -27,16 +27,16 @@
/* gets a groupname given a gid */
-char * my_getgrgid(char *group, long gid)
+char * my_getgrgid(char *group, long gid, int bufsize)
{
struct group *mygroup;
mygroup = getgrgid(gid);
if (mygroup==NULL) {
- sprintf(group, "%ld", gid);
+ snprintf(group, bufsize, "%ld", gid);
return NULL;
} else {
- return strcpy(group, mygroup->gr_name);
+ return safe_strncpy(group, mygroup->gr_name, bufsize);
}
}
diff --git a/libbb/my_getpwuid.c b/libbb/my_getpwuid.c
index 21a037f..53f6c77 100644
--- a/libbb/my_getpwuid.c
+++ b/libbb/my_getpwuid.c
@@ -28,16 +28,16 @@
/* gets a username given a uid */
-char * my_getpwuid(char *name, long uid)
+char * my_getpwuid(char *name, long uid, int bufsize)
{
struct passwd *myuser;
myuser = getpwuid(uid);
if (myuser==NULL) {
- sprintf(name, "%ld", (long)uid);
+ snprintf(name, bufsize, "%ld", (long)uid);
return NULL;
} else {
- return strcpy(name, myuser->pw_name);
+ return safe_strncpy(name, myuser->pw_name, bufsize);
}
}
diff --git a/libbb/procps.c b/libbb/procps.c
index 46e9827..e405fb7 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -57,7 +57,7 @@ extern procps_status_t * procps_scan(int save_user_arg0
sprintf(status, "/proc/%d", pid);
if(stat(status, &sb))
continue;
- my_getpwuid(curstatus.user, sb.st_uid);
+ my_getpwuid(curstatus.user, sb.st_uid, sizeof(curstatus.user));
sprintf(status, "/proc/%d/stat", pid);
if((fp = fopen(status, "r")) == NULL)