Fossil SCM

Added missing checks for negative result value from symbolic_name_to_rid() (indicating an ambiguous name).

stephan 2020-05-05 23:31 fileedit-ajaxify
Commit d8c21f2f09089fc31c883557510ae807b0571a3061eb53da8b5dbbf1b18030ae
1 file changed +7 -1
+7 -1
--- src/fileedit.c
+++ src/fileedit.c
@@ -1103,10 +1103,14 @@
11031103
*vid = symbolic_name_to_rid(zRev, "ci");
11041104
if(0==*vid){
11051105
fileedit_ajax_error(404,"Cannot resolve name as a checkin: %s",
11061106
zRev);
11071107
return 0;
1108
+ }else if(*vid<0){
1109
+ fileedit_ajax_error(400,"Checkin name is ambiguous: %s",
1110
+ zRev);
1111
+ return 0;
11081112
}
11091113
zFileUuid = fileedit_file_uuid(zFilename, *vid, 0);
11101114
if(zFileUuid==0){
11111115
fileedit_ajax_error(404,"Checkin does not contain file.");
11121116
return 0;
@@ -1119,11 +1123,10 @@
11191123
}else{
11201124
fossil_free(zCi);
11211125
}
11221126
return 1;
11231127
}
1124
-
11251128
11261129
/*
11271130
** WEBPAGE: fileedit_content
11281131
**
11291132
** Query parameters:
@@ -1293,10 +1296,13 @@
12931296
}
12941297
vid = symbolic_name_to_rid(zFlag, "ci");
12951298
if(0==vid){
12961299
rc = 404;
12971300
fail((pErr,"Could not resolve checkin version."));
1301
+ }else if(vid<0){
1302
+ rc = 400;
1303
+ fail((pErr,"Checkin name is ambiguous."));
12981304
}
12991305
p->zParentUuid = rid_to_uuid(vid)/*fully expand it*/;
13001306
13011307
zFileUuid = fileedit_file_uuid(p->zFilename, vid, &p->filePerm);
13021308
if(!zFileUuid){
13031309
--- src/fileedit.c
+++ src/fileedit.c
@@ -1103,10 +1103,14 @@
1103 *vid = symbolic_name_to_rid(zRev, "ci");
1104 if(0==*vid){
1105 fileedit_ajax_error(404,"Cannot resolve name as a checkin: %s",
1106 zRev);
1107 return 0;
 
 
 
 
1108 }
1109 zFileUuid = fileedit_file_uuid(zFilename, *vid, 0);
1110 if(zFileUuid==0){
1111 fileedit_ajax_error(404,"Checkin does not contain file.");
1112 return 0;
@@ -1119,11 +1123,10 @@
1119 }else{
1120 fossil_free(zCi);
1121 }
1122 return 1;
1123 }
1124
1125
1126 /*
1127 ** WEBPAGE: fileedit_content
1128 **
1129 ** Query parameters:
@@ -1293,10 +1296,13 @@
1293 }
1294 vid = symbolic_name_to_rid(zFlag, "ci");
1295 if(0==vid){
1296 rc = 404;
1297 fail((pErr,"Could not resolve checkin version."));
 
 
 
1298 }
1299 p->zParentUuid = rid_to_uuid(vid)/*fully expand it*/;
1300
1301 zFileUuid = fileedit_file_uuid(p->zFilename, vid, &p->filePerm);
1302 if(!zFileUuid){
1303
--- src/fileedit.c
+++ src/fileedit.c
@@ -1103,10 +1103,14 @@
1103 *vid = symbolic_name_to_rid(zRev, "ci");
1104 if(0==*vid){
1105 fileedit_ajax_error(404,"Cannot resolve name as a checkin: %s",
1106 zRev);
1107 return 0;
1108 }else if(*vid<0){
1109 fileedit_ajax_error(400,"Checkin name is ambiguous: %s",
1110 zRev);
1111 return 0;
1112 }
1113 zFileUuid = fileedit_file_uuid(zFilename, *vid, 0);
1114 if(zFileUuid==0){
1115 fileedit_ajax_error(404,"Checkin does not contain file.");
1116 return 0;
@@ -1119,11 +1123,10 @@
1123 }else{
1124 fossil_free(zCi);
1125 }
1126 return 1;
1127 }
 
1128
1129 /*
1130 ** WEBPAGE: fileedit_content
1131 **
1132 ** Query parameters:
@@ -1293,10 +1296,13 @@
1296 }
1297 vid = symbolic_name_to_rid(zFlag, "ci");
1298 if(0==vid){
1299 rc = 404;
1300 fail((pErr,"Could not resolve checkin version."));
1301 }else if(vid<0){
1302 rc = 400;
1303 fail((pErr,"Checkin name is ambiguous."));
1304 }
1305 p->zParentUuid = rid_to_uuid(vid)/*fully expand it*/;
1306
1307 zFileUuid = fileedit_file_uuid(p->zFilename, vid, &p->filePerm);
1308 if(!zFileUuid){
1309

Keyboard Shortcuts

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