Hello,

On 06/20/16 10:17, Shigio YAMAGUCHI wrote:
> Hi
>> +/* MAX_PATH is not defined in some platforms, most notably GNU/Hurd.
>> +   In that case we define it here to some constant. */
> 
> Since PATH_MAX is buffer size that realpath(3) assumes,
> setting a wrong size would destroy memory.
> How can we know correct size?
> 

Then maybe it would be safer to use the same size as defined in
"linux/limits.h".

#define PATH_MAX        4096    /* # chars in a path name including nul */

This patch does not change anything for systems which PATH_MAX is
defined, and this number will not create an issue for GNU/Hurd. WDYT?

Thank you,
Manolis
/*
 * With this patch, libutil can be built on systems which PATH_MAX is
 * not defined.
 */

diff --git a/libutil/find.h b/libutil/find.h
index 45e3603..b7b908e 100644
--- a/libutil/find.h
+++ b/libutil/find.h
@@ -21,6 +21,12 @@
 #ifndef _FIND_H_
 #define _FIND_H_
 
+/* MAX_PATH is not defined in some platforms, most notably GNU/Hurd.
+   In that case we define it here to some constant. */
+#ifndef PATH_MAX
+# define PATH_MAX 4096
+#endif
+
 void set_accept_dotfiles(void);
 void set_skip_unreadable(void);
 int skipthisfile(const char *);
_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global

Reply via email to