mirror of
https://github.com/clearlinux/usrbinjava.git
synced 2026-09-04 12:51:37 +00:00
Initial commit
Signed-off-by: Athenas Jimenez <athenas.jimenez.gonzalez@intel.com>
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Software Updater - client side
|
||||
*
|
||||
* Copyright © 2012-2015 Intel Corporation.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 2 or later of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors:
|
||||
* Arjan van de Ven <arjan@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
void dump_file_descriptor_leaks(void)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
|
||||
dir = opendir("/proc/self/fd");
|
||||
if (!dir)
|
||||
return;
|
||||
|
||||
while (1) {
|
||||
char *filename;
|
||||
char buffer[PATH_MAX + 1];
|
||||
entry = readdir(dir);
|
||||
size_t size;
|
||||
if (!entry)
|
||||
break;
|
||||
if (strcmp(entry->d_name, ".") == 0)
|
||||
continue;
|
||||
if (strcmp(entry->d_name, "..") == 0)
|
||||
continue;
|
||||
/* skip stdin/out/err */
|
||||
if (strcmp(entry->d_name, "0") == 0)
|
||||
continue;
|
||||
if (strcmp(entry->d_name, "1") == 0)
|
||||
continue;
|
||||
if (strcmp(entry->d_name, "2") == 0)
|
||||
continue;
|
||||
|
||||
/* we hold an fd open, the one from opendir above */
|
||||
sprintf(buffer, "%i", dirfd(dir));
|
||||
if (strcmp(entry->d_name, buffer) == 0)
|
||||
continue;
|
||||
|
||||
if (asprintf(&filename, "/proc/self/fd/%s", entry->d_name) <= 0)
|
||||
abort();
|
||||
memset(&buffer, 0, sizeof(buffer));
|
||||
size = readlink(filename, buffer, PATH_MAX);
|
||||
if (size)
|
||||
printf("Possible filedescriptor leak : %s (%s)", entry->d_name, buffer);
|
||||
free(filename);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* usrbinjava - java wrapper
|
||||
*
|
||||
* Copyright (C) 2015 Intel Corporation.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3, with OpenSSL-exception.
|
||||
*
|
||||
* Alternatively, you can chose to redistribute and/or modifiy this
|
||||
* software under the terms of the Apache-2.0 license as published
|
||||
* by the Apache Software Foundation.
|
||||
*
|
||||
* If you want to contribute code to this project using only one,
|
||||
* instead of both, of these licenses, you need to remove the other
|
||||
* license text from this file as part of your contribution.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* Likewise, you should have received a copy of the Apache-2.0 license,
|
||||
* which can also be found at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Authors:
|
||||
* Arjan van de Ven <arjan@linux.intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char java[4096];
|
||||
strcpy(java, "/usr/bin/false");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user