diff options
author | truckman <truckman@FreeBSD.org> | 2016-05-25 05:12:56 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2016-05-25 05:12:56 +0000 |
commit | 01033af8a17669d80647004092e350d756fef029 (patch) | |
tree | f20d70c47de4845e91ee8b78687b5b3a061f2f46 /bin/ps/ps.h | |
parent | 2a3e3576d0fa51c3ead7a13253e68e84849a1bf9 (diff) | |
download | FreeBSD-src-01033af8a17669d80647004092e350d756fef029.zip FreeBSD-src-01033af8a17669d80647004092e350d756fef029.tar.gz |
Fix CID 1011370 (Resource leak) in ps.
There is no need to to call strdup() on the value returned by fmt().
The latter calls fmt_argv() which always returns a dynamically
allocated string, and calling strdup() on that leaks the memory
allocated by fmt_argv(). Wave some const magic on ki_args and
ki_env to make the direct assignment happy. This requires a tweak
to the asprintf() case to avoid a const vs. non-const mismatch.
Reported by: Coverity
CID: 1011370
MFC after: 1 week
Diffstat (limited to 'bin/ps/ps.h')
-rw-r--r-- | bin/ps/ps.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/bin/ps/ps.h b/bin/ps/ps.h index 314fbf2..613871a 100644 --- a/bin/ps/ps.h +++ b/bin/ps/ps.h @@ -42,8 +42,8 @@ typedef struct kinfo_str { typedef struct kinfo { struct kinfo_proc *ki_p; /* kinfo_proc structure */ - char *ki_args; /* exec args */ - char *ki_env; /* environment */ + const char *ki_args; /* exec args */ + const char *ki_env; /* environment */ int ki_valid; /* 1 => uarea stuff valid */ double ki_pcpu; /* calculated in main() */ segsz_t ki_memsize; /* calculated in main() */ |