* killall: look at all namespaces by default
* killall: Fix -INT option parsing #11
* killall: change to getopt_long without _only #12
+ * pslog: Define PATH_MAX if required Debian:#905797
+
Changes in 23.1
===============
* killall: Remove debug output Debian: #864753
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
+#include <stdio.h>
#include "i18n.h"
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif /* PATH_MAX */
+
static int
usage ()
{
{
regex_t re_log;
regex_t re_pid;
+ char *fullpath = NULL;
if (argc < 2) {
usage();
struct dirent *namelist;
- char* fullpath = (char*) malloc(PATH_MAX+1);
- if (!fullpath) {
- perror ("malloc");
- return 1;
- }
-
char* linkpath = (char*) malloc(PATH_MAX+1);
if (!linkpath) {
perror ("malloc");
DIR *pid_dir;
if (argv[1][0] != '/') {
- strncpy(fullpath, "/proc/", PATH_MAX);
- strncat(fullpath, argv[1], PATH_MAX - strlen(fullpath));
- strncat(fullpath, "/fd/", PATH_MAX - strlen(fullpath));
+ if (asprintf(&fullpath, "/proc/%s/fd/", argv[1]) < 0) {
+ perror ("asprintf");
+ return 1;
+ }
} else {
- strncpy(fullpath, argv[1], PATH_MAX);
- strncat(fullpath, "/fd/", PATH_MAX - strlen(fullpath));
+ if (asprintf(&fullpath, "%s/fd/", argv[1]) < 0) {
+ perror("asprintf");
+ return 1;
}
+ }
pid_dir = opendir(fullpath);
if (!pid_dir) {
perror("opendir");
+ free(fullpath);
return 1;
}