Fossil SCM
Fix several blob leaks that can lead to out of memory conditions for very large push operations.
Commit
81c685e0976c5a90640611099d72df6f4efdb71c
Parent
0b61e3c019dc4e0…
1 file changed
+6
+6
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -127,14 +127,16 @@ | ||
| 127 | 127 | blob_zero(&content); |
| 128 | 128 | blob_zero(&hash); |
| 129 | 129 | blob_extract(pXfer->pIn, n, &content); |
| 130 | 130 | if( !cloneFlag && uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 131 | 131 | /* Ignore files that have been shunned */ |
| 132 | + blob_reset(&content); | |
| 132 | 133 | return; |
| 133 | 134 | } |
| 134 | 135 | if( isPriv && !g.perm.Private ){ |
| 135 | 136 | /* Do not accept private files if not authorized */ |
| 137 | + blob_reset(&content); | |
| 136 | 138 | return; |
| 137 | 139 | } |
| 138 | 140 | if( cloneFlag ){ |
| 139 | 141 | if( pXfer->nToken==4 ){ |
| 140 | 142 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| @@ -156,10 +158,12 @@ | ||
| 156 | 158 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, |
| 157 | 159 | 0, isPriv); |
| 158 | 160 | pXfer->nDanglingFile++; |
| 159 | 161 | db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid); |
| 160 | 162 | if( !isPriv ) content_make_public(rid); |
| 163 | + blob_reset(&src); | |
| 164 | + blob_reset(&content); | |
| 161 | 165 | return; |
| 162 | 166 | } |
| 163 | 167 | pXfer->nDeltaRcvd++; |
| 164 | 168 | blob_delta_apply(&src, &content, &next); |
| 165 | 169 | blob_reset(&src); |
| @@ -235,10 +239,11 @@ | ||
| 235 | 239 | } |
| 236 | 240 | blob_zero(&content); |
| 237 | 241 | blob_extract(pXfer->pIn, szC, &content); |
| 238 | 242 | if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 239 | 243 | /* Ignore files that have been shunned */ |
| 244 | + blob_reset(&content); | |
| 240 | 245 | return; |
| 241 | 246 | } |
| 242 | 247 | if( pXfer->nToken==5 ){ |
| 243 | 248 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| 244 | 249 | pXfer->nDeltaRcvd++; |
| @@ -420,10 +425,11 @@ | ||
| 420 | 425 | blob_append(pXfer->pOut, blob_buffer(&content), size); |
| 421 | 426 | pXfer->nFileSent++; |
| 422 | 427 | }else{ |
| 423 | 428 | pXfer->nDeltaSent++; |
| 424 | 429 | } |
| 430 | + blob_reset(&content); | |
| 425 | 431 | } |
| 426 | 432 | remote_has(rid); |
| 427 | 433 | blob_reset(&uuid); |
| 428 | 434 | #if 0 |
| 429 | 435 | if( blob_buffer(pXfer->pOut)[blob_size(pXfer->pOut)-1]!='\n' ){ |
| 430 | 436 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -127,14 +127,16 @@ | |
| 127 | blob_zero(&content); |
| 128 | blob_zero(&hash); |
| 129 | blob_extract(pXfer->pIn, n, &content); |
| 130 | if( !cloneFlag && uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 131 | /* Ignore files that have been shunned */ |
| 132 | return; |
| 133 | } |
| 134 | if( isPriv && !g.perm.Private ){ |
| 135 | /* Do not accept private files if not authorized */ |
| 136 | return; |
| 137 | } |
| 138 | if( cloneFlag ){ |
| 139 | if( pXfer->nToken==4 ){ |
| 140 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| @@ -156,10 +158,12 @@ | |
| 156 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, |
| 157 | 0, isPriv); |
| 158 | pXfer->nDanglingFile++; |
| 159 | db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid); |
| 160 | if( !isPriv ) content_make_public(rid); |
| 161 | return; |
| 162 | } |
| 163 | pXfer->nDeltaRcvd++; |
| 164 | blob_delta_apply(&src, &content, &next); |
| 165 | blob_reset(&src); |
| @@ -235,10 +239,11 @@ | |
| 235 | } |
| 236 | blob_zero(&content); |
| 237 | blob_extract(pXfer->pIn, szC, &content); |
| 238 | if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 239 | /* Ignore files that have been shunned */ |
| 240 | return; |
| 241 | } |
| 242 | if( pXfer->nToken==5 ){ |
| 243 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| 244 | pXfer->nDeltaRcvd++; |
| @@ -420,10 +425,11 @@ | |
| 420 | blob_append(pXfer->pOut, blob_buffer(&content), size); |
| 421 | pXfer->nFileSent++; |
| 422 | }else{ |
| 423 | pXfer->nDeltaSent++; |
| 424 | } |
| 425 | } |
| 426 | remote_has(rid); |
| 427 | blob_reset(&uuid); |
| 428 | #if 0 |
| 429 | if( blob_buffer(pXfer->pOut)[blob_size(pXfer->pOut)-1]!='\n' ){ |
| 430 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -127,14 +127,16 @@ | |
| 127 | blob_zero(&content); |
| 128 | blob_zero(&hash); |
| 129 | blob_extract(pXfer->pIn, n, &content); |
| 130 | if( !cloneFlag && uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 131 | /* Ignore files that have been shunned */ |
| 132 | blob_reset(&content); |
| 133 | return; |
| 134 | } |
| 135 | if( isPriv && !g.perm.Private ){ |
| 136 | /* Do not accept private files if not authorized */ |
| 137 | blob_reset(&content); |
| 138 | return; |
| 139 | } |
| 140 | if( cloneFlag ){ |
| 141 | if( pXfer->nToken==4 ){ |
| 142 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| @@ -156,10 +158,12 @@ | |
| 158 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, |
| 159 | 0, isPriv); |
| 160 | pXfer->nDanglingFile++; |
| 161 | db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid); |
| 162 | if( !isPriv ) content_make_public(rid); |
| 163 | blob_reset(&src); |
| 164 | blob_reset(&content); |
| 165 | return; |
| 166 | } |
| 167 | pXfer->nDeltaRcvd++; |
| 168 | blob_delta_apply(&src, &content, &next); |
| 169 | blob_reset(&src); |
| @@ -235,10 +239,11 @@ | |
| 239 | } |
| 240 | blob_zero(&content); |
| 241 | blob_extract(pXfer->pIn, szC, &content); |
| 242 | if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 243 | /* Ignore files that have been shunned */ |
| 244 | blob_reset(&content); |
| 245 | return; |
| 246 | } |
| 247 | if( pXfer->nToken==5 ){ |
| 248 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| 249 | pXfer->nDeltaRcvd++; |
| @@ -420,10 +425,11 @@ | |
| 425 | blob_append(pXfer->pOut, blob_buffer(&content), size); |
| 426 | pXfer->nFileSent++; |
| 427 | }else{ |
| 428 | pXfer->nDeltaSent++; |
| 429 | } |
| 430 | blob_reset(&content); |
| 431 | } |
| 432 | remote_has(rid); |
| 433 | blob_reset(&uuid); |
| 434 | #if 0 |
| 435 | if( blob_buffer(pXfer->pOut)[blob_size(pXfer->pOut)-1]!='\n' ){ |
| 436 |