aboutsummaryrefslogtreecommitdiff
path: root/src/util/os_installation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-01-02 11:24:26 +0100
committerChristian Grothoff <christian@grothoff.org>2021-01-02 11:24:26 +0100
commit0d4337da23548f4779d44c1416f51f087261141e (patch)
treef7245034610181fa0e2b1f8b703465809b130680 /src/util/os_installation.c
parent155aa7bb9c96c9eed6f3ce1007ecbb7d7ee823c7 (diff)
downloadgnunet-0d4337da23548f4779d44c1416f51f087261141e.tar.gz
gnunet-0d4337da23548f4779d44c1416f51f087261141e.zip
fix /proc/PID/maps parser format string
Diffstat (limited to 'src/util/os_installation.c')
-rw-r--r--src/util/os_installation.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index 6e783a95a..d1e5e0da5 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -142,7 +142,7 @@ GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd)
142 * @return NULL on error 142 * @return NULL on error
143 */ 143 */
144static char * 144static char *
145get_path_from_proc_maps () 145get_path_from_proc_maps (void)
146{ 146{
147 char fn[64]; 147 char fn[64];
148 char line[1024]; 148 char line[1024];
@@ -152,15 +152,19 @@ get_path_from_proc_maps ()
152 152
153 if (NULL == current_pd->libname) 153 if (NULL == current_pd->libname)
154 return NULL; 154 return NULL;
155 GNUNET_snprintf (fn, sizeof(fn), "/proc/%u/maps", getpid ()); 155 GNUNET_snprintf (fn,
156 sizeof(fn),
157 "/proc/%u/maps",
158 getpid ());
156 if (NULL == (f = fopen (fn, "r"))) 159 if (NULL == (f = fopen (fn, "r")))
157 return NULL; 160 return NULL;
158 while (NULL != fgets (line, sizeof(line), f)) 161 while (NULL != fgets (line, sizeof(line), f))
159 { 162 {
160 if ((1 == sscanf (line, 163 if ((1 == sscanf (line,
161 "%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%1023s", 164 "%*p-%*p %*c%*c%*c%*c %*x %*x:%*x %*u%*[ ]%1023s",
162 dir)) && 165 dir)) &&
163 (NULL != (lgu = strstr (dir, current_pd->libname)))) 166 (NULL != (lgu = strstr (dir,
167 current_pd->libname))))
164 { 168 {
165 lgu[0] = '\0'; 169 lgu[0] = '\0';
166 fclose (f); 170 fclose (f);
@@ -178,7 +182,7 @@ get_path_from_proc_maps ()
178 * @return NULL on error 182 * @return NULL on error
179 */ 183 */
180static char * 184static char *
181get_path_from_proc_exe () 185get_path_from_proc_exe (void)
182{ 186{
183 char fn[64]; 187 char fn[64];
184 char lnk[1024]; 188 char lnk[1024];
@@ -232,7 +236,7 @@ typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t *bufsize);
232 * @return NULL on error 236 * @return NULL on error
233 */ 237 */
234static char * 238static char *
235get_path_from_NSGetExecutablePath () 239get_path_from_NSGetExecutablePath (void)
236{ 240{
237 static char zero = '\0'; 241 static char zero = '\0';
238 char *path; 242 char *path;
@@ -270,7 +274,7 @@ get_path_from_NSGetExecutablePath ()
270 * @return NULL on error 274 * @return NULL on error
271 */ 275 */
272static char * 276static char *
273get_path_from_dyld_image () 277get_path_from_dyld_image (void)
274{ 278{
275 const char *path; 279 const char *path;
276 char *p; 280 char *p;
@@ -359,7 +363,7 @@ get_path_from_PATH (const char *binary)
359 * @return NULL on error (environment variable not set) 363 * @return NULL on error (environment variable not set)
360 */ 364 */
361static char * 365static char *
362get_path_from_GNUNET_PREFIX () 366get_path_from_GNUNET_PREFIX (void)
363{ 367{
364 const char *p; 368 const char *p;
365 369
@@ -380,7 +384,7 @@ get_path_from_GNUNET_PREFIX ()
380 * @return a pointer to the executable path, or NULL on error 384 * @return a pointer to the executable path, or NULL on error
381 */ 385 */
382static char * 386static char *
383os_get_gnunet_path () 387os_get_gnunet_path (void)
384{ 388{
385 char *ret; 389 char *ret;
386 390
@@ -461,7 +465,6 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
461 * guess for the current app */ 465 * guess for the current app */
462 if (NULL == execpath) 466 if (NULL == execpath)
463 execpath = os_get_gnunet_path (); 467 execpath = os_get_gnunet_path ();
464
465 if (NULL == execpath) 468 if (NULL == execpath)
466 return NULL; 469 return NULL;
467 470