Change-Id: Ia63c65c74aeb119097acdb4000c6b4bc153e7937
static void get_binary_basename(int32_t pid, char *buf, int len)
{
int fd;
static void get_binary_basename(int32_t pid, char *buf, int len)
{
int fd;
- char path[256];
- char cmdline[1024];
+ char path[PATH_MAX];
+ char cmdline[PATH_MAX];
char *bnam;
ssize_t size;
char *bnam;
ssize_t size;
+ /* If we read more than allocated, truncate */
+ if (size >= PATH_MAX)
+ cmdline[PATH_MAX - 1] = 0;
+ else
+ cmdline[size] = 0;
+
bnam = basename(cmdline);
strncpy(buf, bnam, len-1);
bnam = basename(cmdline);
strncpy(buf, bnam, len-1);