aboutsummaryrefslogtreecommitdiff
path: root/src/util/os_installation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/os_installation.c')
-rw-r--r--src/util/os_installation.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index 1226c5966..2e35de681 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2006-2016 GNUnet e.V. 3 Copyright (C) 2006-2018 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -152,14 +152,21 @@ get_path_from_proc_exe ()
152 ssize_t size; 152 ssize_t size;
153 char *lep; 153 char *lep;
154 154
155 GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/exe", getpid ()); 155 GNUNET_snprintf (fn,
156 size = readlink (fn, lnk, sizeof (lnk) - 1); 156 sizeof (fn),
157 "/proc/%u/exe",
158 getpid ());
159 size = readlink (fn,
160 lnk,
161 sizeof (lnk) - 1);
157 if (size <= 0) 162 if (size <= 0)
158 { 163 {
159 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "readlink", fn); 164 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
165 "readlink",
166 fn);
160 return NULL; 167 return NULL;
161 } 168 }
162 GNUNET_assert (size < sizeof (lnk)); 169 GNUNET_assert ( ((size_t) size) < sizeof (lnk));
163 lnk[size] = '\0'; 170 lnk[size] = '\0';
164 while ((lnk[size] != '/') && (size > 0)) 171 while ((lnk[size] != '/') && (size > 0))
165 size--; 172 size--;
@@ -167,12 +174,13 @@ get_path_from_proc_exe ()
167 "/%s/libexec/", 174 "/%s/libexec/",
168 current_pd->project_dirname); 175 current_pd->project_dirname);
169 /* test for being in lib/gnunet/libexec/ or lib/MULTIARCH/gnunet/libexec */ 176 /* test for being in lib/gnunet/libexec/ or lib/MULTIARCH/gnunet/libexec */
170 if ( (size > strlen (lep)) && 177 if ( (((size_t) size) > strlen (lep)) &&
171 (0 == strcmp (lep, 178 (0 == strcmp (lep,
172 &lnk[size - strlen (lep)])) ) 179 &lnk[size - strlen (lep)])) )
173 size -= strlen (lep) - 1; 180 size -= strlen (lep) - 1;
174 GNUNET_free (lep); 181 GNUNET_free (lep);
175 if ((size < 4) || (lnk[size - 4] != '/')) 182 if ( (size < 4) ||
183 (lnk[size - 4] != '/') )
176 { 184 {
177 /* not installed in "/bin/" -- binary path probably useless */ 185 /* not installed in "/bin/" -- binary path probably useless */
178 return NULL; 186 return NULL;
@@ -903,6 +911,7 @@ GNUNET_OS_check_helper_binary (const char *binary,
903 if (check_suid) 911 if (check_suid)
904 { 912 {
905#ifndef MINGW 913#ifndef MINGW
914 (void) params;
906 if ( (0 != (statbuf.st_mode & S_ISUID)) && 915 if ( (0 != (statbuf.st_mode & S_ISUID)) &&
907 (0 == statbuf.st_uid) ) 916 (0 == statbuf.st_uid) )
908 { 917 {