1 Description: Fix symlink directory traversal.
2 Do not allow symlinks that traverse the current directoru, nor absolute
6 Author: Guillem Jover <guillem@debian.org>
8 Bug-Debian: https://bugs.debian.org/774434
10 Last-Update: 2015-03-28
13 uxspec.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
14 1 file changed, 54 insertions(+)
18 @@ -120,6 +120,58 @@ int query_uxspecial(char FAR **dest, cha
23 +static int is_link_traversal(const char *name)
29 + } state = STATE_NONE;
38 + if ((state == STATE_DOTS) && (dots == 2))
42 + if ((state == STATE_DOTS && dots == 1) && ndir == 0)
44 + if (state == STATE_NONE && ndir == 0)
46 + if ((state == STATE_DOTS) && (dots > 2))
53 + if (state == STATE_NONE)
59 + if (state == STATE_NONE)
65 + if ((state == STATE_DOTS) && (dots == 2))
67 + if ((state == STATE_DOTS) && (dots > 2))
74 /* Restores the UNIX special file data */
76 int set_uxspecial(char FAR *storage, char *name)
77 @@ -156,6 +208,8 @@ int set_uxspecial(char FAR *storage, cha
79 far_memmove((char FAR *)tmp_name, dptr, l);
81 + if (is_link_traversal(tmp_name))
82 + return(UXSPEC_RC_ERROR);
83 rc=(id==UXSB_HLNK)?link(tmp_name, name):symlink(tmp_name, name);