Fossil SCM

Do not allow the "fossil add" command to add files beneath a symlink.

drh 2020-08-19 00:15 sec2020
Commit a6abfb911b31d8f814be147299b6c0cd9e45740b00a96f6de7e4ff64bb9ebf2c
1 file changed +12 -2
+12 -2
--- src/add.c
+++ src/add.c
@@ -186,11 +186,13 @@
186186
}
187187
188188
/*
189189
** Add all files in the sfile temp table.
190190
**
191
-** Automatically exclude the repository file.
191
+** Automatically exclude the repository file and any other files
192
+** with reserved names. Also exclude files that are beneath an
193
+** existing symlink.
192194
*/
193195
static int add_files_in_sfile(int vid){
194196
const char *zRepo; /* Name of the repository database file */
195197
int nAdd = 0; /* Number of files added */
196198
int i; /* Loop counter */
@@ -208,11 +210,19 @@
208210
if( filenames_are_case_sensitive() ){
209211
xCmp = fossil_strcmp;
210212
}else{
211213
xCmp = fossil_stricmp;
212214
}
213
- db_prepare(&loop, "SELECT pathname FROM sfile ORDER BY pathname");
215
+ db_prepare(&loop,
216
+ "SELECT pathname FROM sfile"
217
+ " WHERE pathname NOT IN ("
218
+ "SELECT sfile.pathname FROM vfile, sfile"
219
+ " WHERE vfile.islink"
220
+ " AND NOT vfile.deleted"
221
+ " AND sfile.pathname>(vfile.pathname||'/')"
222
+ " AND sfile.pathname<(vfile.pathname||'0'))"
223
+ " ORDER BY pathname");
214224
while( db_step(&loop)==SQLITE_ROW ){
215225
const char *zToAdd = db_column_text(&loop, 0);
216226
if( fossil_strcmp(zToAdd, zRepo)==0 ) continue;
217227
if( strchr(zToAdd,'/') ){
218228
if( file_is_reserved_name(zToAdd, -1) ) continue;
219229
--- src/add.c
+++ src/add.c
@@ -186,11 +186,13 @@
186 }
187
188 /*
189 ** Add all files in the sfile temp table.
190 **
191 ** Automatically exclude the repository file.
 
 
192 */
193 static int add_files_in_sfile(int vid){
194 const char *zRepo; /* Name of the repository database file */
195 int nAdd = 0; /* Number of files added */
196 int i; /* Loop counter */
@@ -208,11 +210,19 @@
208 if( filenames_are_case_sensitive() ){
209 xCmp = fossil_strcmp;
210 }else{
211 xCmp = fossil_stricmp;
212 }
213 db_prepare(&loop, "SELECT pathname FROM sfile ORDER BY pathname");
 
 
 
 
 
 
 
 
214 while( db_step(&loop)==SQLITE_ROW ){
215 const char *zToAdd = db_column_text(&loop, 0);
216 if( fossil_strcmp(zToAdd, zRepo)==0 ) continue;
217 if( strchr(zToAdd,'/') ){
218 if( file_is_reserved_name(zToAdd, -1) ) continue;
219
--- src/add.c
+++ src/add.c
@@ -186,11 +186,13 @@
186 }
187
188 /*
189 ** Add all files in the sfile temp table.
190 **
191 ** Automatically exclude the repository file and any other files
192 ** with reserved names. Also exclude files that are beneath an
193 ** existing symlink.
194 */
195 static int add_files_in_sfile(int vid){
196 const char *zRepo; /* Name of the repository database file */
197 int nAdd = 0; /* Number of files added */
198 int i; /* Loop counter */
@@ -208,11 +210,19 @@
210 if( filenames_are_case_sensitive() ){
211 xCmp = fossil_strcmp;
212 }else{
213 xCmp = fossil_stricmp;
214 }
215 db_prepare(&loop,
216 "SELECT pathname FROM sfile"
217 " WHERE pathname NOT IN ("
218 "SELECT sfile.pathname FROM vfile, sfile"
219 " WHERE vfile.islink"
220 " AND NOT vfile.deleted"
221 " AND sfile.pathname>(vfile.pathname||'/')"
222 " AND sfile.pathname<(vfile.pathname||'0'))"
223 " ORDER BY pathname");
224 while( db_step(&loop)==SQLITE_ROW ){
225 const char *zToAdd = db_column_text(&loop, 0);
226 if( fossil_strcmp(zToAdd, zRepo)==0 ) continue;
227 if( strchr(zToAdd,'/') ){
228 if( file_is_reserved_name(zToAdd, -1) ) continue;
229

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button