Fossil SCM

Refuse a "file" or "cfile" card whose content is cut short by the end of the message. A truncated delta whose source had not yet arrived was stored without any check, and once the source arrived the artifact read back as the content of its source.

dmestas 2026-11-12 04:04 UTC small-fixes
Commit c319e8744de96ca4d65d0c1f37500e2d03e38298afa6d5e6fb89a0ee5ea0b284
1 file changed +13 -2
+13 -2
--- src/xfer.c
+++ src/xfer.c
@@ -155,11 +155,18 @@
155155
){
156156
blob_appendf(&pXfer->err, "malformed file line");
157157
return;
158158
}
159159
blob_zero(&content);
160
- blob_extract(pXfer->pIn, n, &content);
160
+ if( blob_extract(pXfer->pIn, n, &content)!=n ){
161
+ /* The message ends before the content does. What there is must not
162
+ ** be stored: if it is a delta whose source has not arrived, nothing
163
+ ** would ever check it. */
164
+ blob_appendf(&pXfer->err, "truncated file card");
165
+ blob_reset(&content);
166
+ return;
167
+ }
161168
pUuid = &pXfer->aToken[1];
162169
if( !cloneFlag && uuid_is_shunned(blob_str(pUuid)) ){
163170
/* Ignore files that have been shunned */
164171
blob_reset(&content);
165172
return;
@@ -277,11 +284,15 @@
277284
if( isPriv && !g.perm.Private ){
278285
/* Do not accept private files if not authorized */
279286
return;
280287
}
281288
blob_zero(&content);
282
- blob_extract(pXfer->pIn, szC, &content);
289
+ if( blob_extract(pXfer->pIn, szC, &content)!=szC ){
290
+ blob_appendf(&pXfer->err, "truncated cfile card");
291
+ blob_reset(&content);
292
+ return;
293
+ }
283294
if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
284295
/* Ignore files that have been shunned */
285296
blob_reset(&content);
286297
return;
287298
}
288299
--- src/xfer.c
+++ src/xfer.c
@@ -155,11 +155,18 @@
155 ){
156 blob_appendf(&pXfer->err, "malformed file line");
157 return;
158 }
159 blob_zero(&content);
160 blob_extract(pXfer->pIn, n, &content);
 
 
 
 
 
 
 
161 pUuid = &pXfer->aToken[1];
162 if( !cloneFlag && uuid_is_shunned(blob_str(pUuid)) ){
163 /* Ignore files that have been shunned */
164 blob_reset(&content);
165 return;
@@ -277,11 +284,15 @@
277 if( isPriv && !g.perm.Private ){
278 /* Do not accept private files if not authorized */
279 return;
280 }
281 blob_zero(&content);
282 blob_extract(pXfer->pIn, szC, &content);
 
 
 
 
283 if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
284 /* Ignore files that have been shunned */
285 blob_reset(&content);
286 return;
287 }
288
--- src/xfer.c
+++ src/xfer.c
@@ -155,11 +155,18 @@
155 ){
156 blob_appendf(&pXfer->err, "malformed file line");
157 return;
158 }
159 blob_zero(&content);
160 if( blob_extract(pXfer->pIn, n, &content)!=n ){
161 /* The message ends before the content does. What there is must not
162 ** be stored: if it is a delta whose source has not arrived, nothing
163 ** would ever check it. */
164 blob_appendf(&pXfer->err, "truncated file card");
165 blob_reset(&content);
166 return;
167 }
168 pUuid = &pXfer->aToken[1];
169 if( !cloneFlag && uuid_is_shunned(blob_str(pUuid)) ){
170 /* Ignore files that have been shunned */
171 blob_reset(&content);
172 return;
@@ -277,11 +284,15 @@
284 if( isPriv && !g.perm.Private ){
285 /* Do not accept private files if not authorized */
286 return;
287 }
288 blob_zero(&content);
289 if( blob_extract(pXfer->pIn, szC, &content)!=szC ){
290 blob_appendf(&pXfer->err, "truncated cfile card");
291 blob_reset(&content);
292 return;
293 }
294 if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
295 /* Ignore files that have been shunned */
296 blob_reset(&content);
297 return;
298 }
299

Keyboard Shortcuts

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