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.
Commit
c319e8744de96ca4d65d0c1f37500e2d03e38298afa6d5e6fb89a0ee5ea0b284
Parent
7266ff3e93e8341…
1 file changed
+13
-2
+13
-2
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -155,11 +155,18 @@ | ||
| 155 | 155 | ){ |
| 156 | 156 | blob_appendf(&pXfer->err, "malformed file line"); |
| 157 | 157 | return; |
| 158 | 158 | } |
| 159 | 159 | 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 | + } | |
| 161 | 168 | pUuid = &pXfer->aToken[1]; |
| 162 | 169 | if( !cloneFlag && uuid_is_shunned(blob_str(pUuid)) ){ |
| 163 | 170 | /* Ignore files that have been shunned */ |
| 164 | 171 | blob_reset(&content); |
| 165 | 172 | return; |
| @@ -277,11 +284,15 @@ | ||
| 277 | 284 | if( isPriv && !g.perm.Private ){ |
| 278 | 285 | /* Do not accept private files if not authorized */ |
| 279 | 286 | return; |
| 280 | 287 | } |
| 281 | 288 | 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 | + } | |
| 283 | 294 | if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 284 | 295 | /* Ignore files that have been shunned */ |
| 285 | 296 | blob_reset(&content); |
| 286 | 297 | return; |
| 287 | 298 | } |
| 288 | 299 |
| --- 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 |