1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../embutils/mount.patch
5 # Copyright (C) 2004 - 2018 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
17 Hardened mount to not crash when the directory was not found in /etc/fstab and
18 improved the tokenizing to strip white spaces, since the files are often
19 indented in tabular form and fixed the entry parsing to not overwrite memory.
21 - Rene Rebe <rene@exactcode.de>
23 --- embutils-0.19/mount.c 2006-11-05 20:10:18.000000000 +0000
24 +++ embutils-0.19-fixed/mount.c 2007-08-25 09:20:23.000000000 +0000
30 + /* skip leading spaces */
31 + while(*buffer && isspace(*buffer))
35 for(;*buffer;++buffer) {
36 if(isspace(*buffer)) {
41 - entries[i]=spacetok(buffer);
42 - while((entries[++i]=spacetok(NULL)) &&
44 + entries[i++]=spacetok(buffer);
46 + while((entries[i++]=spacetok(NULL)) &&
47 + i<(sizeof(entries)/sizeof(char*)));
54 while((mnt=mnt_entry(fh)))
55 - if(!strcmp(mnt->dir,device)) {
56 + if(mnt->dir && !strcmp(mnt->dir,device)) {
60 parse_options(mnt->opts,&flags,data+data_size,DATA_BUFFER_SIZE-data_size);
65 + write(2," no found in /etc/fstab\n",24);
72 Added bind mount and fixed the option_parser to be able to parse options
73 with only one part and no , seperator ...
75 Rene Rebe <rene@exactcode.de>
77 --- embutils-0.17/mount.c 2004-01-09 17:03:48.000000000 +0100
78 +++ embutils-0.17-mount/mount.c 2005-06-19 15:13:34.000000000 +0200
81 #include <sys/mount.h>
83 +#include <linux/fs.h> /* MS_MOVE */
85 const char *const mtab=_PATH_MOUNTED;
88 {"suid", ~MS_NOSUID, 0},
89 {"sync", ~0, MS_SYNCHRONOUS},
90 {"bind", ~0, MS_BIND},
92 + {"move", ~0, MS_MOVE},
100 const struct mount_options *i;
101 - char *ptr=strchr(str,',');
109 + ptr=strchr(str,',');
110 + if(!ptr) ptr=(char*)str+strlen(str)-1;
113 for(i=options; i->name; ++i)
114 if(!strcmp(str,i->name)) {
117 Do not segfault by default when no type was give, also none might be needed
118 due bind or move mounts.
120 - Rene Rebe <rene@exactcode.de>
122 --- embutils-0.17/mount.c 2005-12-18 23:49:12.000000000 +0100
123 +++ embutils-0.17-patched/mount.c 2005-12-19 10:02:38.000000000 +0100
126 int main(int argc, char **argv) {
127 unsigned long flags=0;
128 - const char *fs_type=NULL;
129 + const char *fs_type="";
130 const char *device=NULL;
131 const char *dir=NULL;
132 enum { DATA_BUFFER_SIZE=100 };
134 The option code was relying on accidently zero initialization, although
135 the code even had explicit zeroing later on. Depending on compiler,
136 optimization and architecture coudl pass random data to the kernel, and
137 also failed to parse more than one option.
139 - Rene Rebe <rene@exactcode.de>
141 --- ./mount.c.vanilla 2016-06-25 03:10:40.130000362 +0000
142 +++ ./mount.c 2018-08-21 10:55:29.969876048 +0000
143 @@ -267,12 +268,12 @@
146 if(!i->name) { /*no options was found*/
147 - size_t option_length=strlen(str)+1;
148 + size_t option_length=strlen(str);
150 *(data+data_set)=',';
153 - memcpy(data+data_set,str,option_length);
154 + memcpy(data+data_set,str,option_length+1);/*incl 0*/
155 data_set+=option_length;
156 if(data_set>=data_size)
157 return; /*too many options*/
159 const char *dir=NULL;
160 enum { DATA_BUFFER_SIZE=100 };
161 char data[DATA_BUFFER_SIZE];
164 bool write_mtab=true;
171 - memset(data,0,DATA_BUFFER_SIZE);
174 show_mounts(fs_type);