Fossil SCM

Fix several blob leaks that can lead to out of memory conditions for very large push operations.

mistachkin 2012-01-20 15:22 UTC trunk
Commit 81c685e0976c5a90640611099d72df6f4efdb71c
1 file changed +6
+6
--- src/xfer.c
+++ src/xfer.c
@@ -127,14 +127,16 @@
127127
blob_zero(&content);
128128
blob_zero(&hash);
129129
blob_extract(pXfer->pIn, n, &content);
130130
if( !cloneFlag && uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
131131
/* Ignore files that have been shunned */
132
+ blob_reset(&content);
132133
return;
133134
}
134135
if( isPriv && !g.perm.Private ){
135136
/* Do not accept private files if not authorized */
137
+ blob_reset(&content);
136138
return;
137139
}
138140
if( cloneFlag ){
139141
if( pXfer->nToken==4 ){
140142
srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv);
@@ -156,10 +158,12 @@
156158
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid,
157159
0, isPriv);
158160
pXfer->nDanglingFile++;
159161
db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid);
160162
if( !isPriv ) content_make_public(rid);
163
+ blob_reset(&src);
164
+ blob_reset(&content);
161165
return;
162166
}
163167
pXfer->nDeltaRcvd++;
164168
blob_delta_apply(&src, &content, &next);
165169
blob_reset(&src);
@@ -235,10 +239,11 @@
235239
}
236240
blob_zero(&content);
237241
blob_extract(pXfer->pIn, szC, &content);
238242
if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
239243
/* Ignore files that have been shunned */
244
+ blob_reset(&content);
240245
return;
241246
}
242247
if( pXfer->nToken==5 ){
243248
srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv);
244249
pXfer->nDeltaRcvd++;
@@ -420,10 +425,11 @@
420425
blob_append(pXfer->pOut, blob_buffer(&content), size);
421426
pXfer->nFileSent++;
422427
}else{
423428
pXfer->nDeltaSent++;
424429
}
430
+ blob_reset(&content);
425431
}
426432
remote_has(rid);
427433
blob_reset(&uuid);
428434
#if 0
429435
if( blob_buffer(pXfer->pOut)[blob_size(pXfer->pOut)-1]!='\n' ){
430436
--- 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

Keyboard Shortcuts

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