Changes On Branch clientSyncLeakFix
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch clientSyncLeakFix Excluding Merge-Ins

This is equivalent to a diff from 0b61e3c019 to 7611406fd7

2012-01-24
13:28
Fix several blob leaks that can lead to out of memory conditions for very large push operations. Revise the order of error messages so that simple HTTP timeout produces a better diagnostic. The HTTP trace files need to be opened in binary mode. check-in: 1e39808853 user: mistachkin tags: trunk
2012-01-22
06:52
Make sure that autosetup ends up defining FOSSIL_ENABLE_TCL in the Makefile when necessary. check-in: 21555be397 user: mistachkin tags: trunk
2012-01-20
17:32
The HTTP trace files need to be opened in binary mode. Closed-Leaf check-in: 7611406fd7 user: mistachkin tags: clientSyncLeakFix
17:16
Revise the order of error messages so that simple HTTP timeout produces a better diagnostic. check-in: dd71069bfe user: mistachkin tags: clientSyncLeakFix
15:22
Fix several blob leaks that can lead to out of memory conditions for very large push operations. check-in: 81c685e097 user: mistachkin tags: clientSyncLeakFix
2012-01-18
13:22
Merge trunk changes into the retro-sbsdiff branch. check-in: 6daee94fac user: drh tags: retro-sbsdiff
13:21
Add the ability to run TH1 scripts before and after each xfer request. check-in: 0b61e3c019 user: drh tags: trunk
12:56
Add xfersetup to the makemake.tcl script. Closed-Leaf check-in: 9441f6fbcf user: mistachkin tags: pushScript
12:47
Correct casing typos. check-in: 0c042ce7d1 user: mistachkin tags: trunk

Changes to src/http.c.

   172    172     */
   173    173     if( g.fHttpTrace ){
   174    174       static int traceCnt = 0;
   175    175       char *zOutFile;
   176    176       FILE *out;
   177    177       traceCnt++;
   178    178       zOutFile = mprintf("http-request-%d.txt", traceCnt);
   179         -    out = fopen(zOutFile, "w");
          179  +    out = fopen(zOutFile, "wb");
   180    180       if( out ){
   181    181         fwrite(blob_buffer(&hdr), 1, blob_size(&hdr), out);
   182    182         fwrite(blob_buffer(&payload), 1, blob_size(&payload), out);
   183    183         fclose(out);
   184    184       }
   185    185       free(zOutFile);
   186    186       zOutFile = mprintf("http-reply-%d.txt", traceCnt);
   187         -    out = fopen(zOutFile, "w");
          187  +    out = fopen(zOutFile, "wb");
   188    188       transport_log(out);
   189    189       free(zOutFile);
   190    190     }
   191    191   
   192    192     /*
   193    193     ** Send the request to the server.
   194    194     */
................................................................................
   251    251                             "application/x-fossil-uncompressed", -1)==0 ){
   252    252           isCompressed = 0;
   253    253         }else if( fossil_strnicmp(&zLine[14], "application/x-fossil", -1)!=0 ){
   254    254           isError = 1;
   255    255         }
   256    256       }
   257    257     }
          258  +  if( iLength<0 ){
          259  +    fossil_fatal("server did not reply");
          260  +    goto write_err;
          261  +  }
   258    262     if( rc!=200 ){
   259    263       fossil_warning("\"location:\" missing from 302 redirect reply");
   260    264       goto write_err;
   261    265     }
   262    266   
   263    267     /*
   264    268     ** Extract the reply payload that follows the header
   265    269     */
   266         -  if( iLength<0 ){
   267         -    fossil_fatal("server did not reply");
   268         -    goto write_err;
   269         -  }
   270    270     blob_zero(pReply);
   271    271     blob_resize(pReply, iLength);
   272    272     iLength = transport_receive(blob_buffer(pReply), iLength);
   273    273     blob_resize(pReply, iLength);
   274    274     if( isError ){
   275    275       char *z;
   276    276       int i, j;

Changes to src/xfer.c.

   125    125       return;
   126    126     }
   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);
   141    143         pXfer->nDeltaRcvd++;
   142    144       }else{
................................................................................
   154    156       srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv);
   155    157       if( content_get(srcid, &src)==0 ){
   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);
   166    170       blob_reset(&content);
   167    171       content = next;
................................................................................
   233    237       /* Do not accept private files if not authorized */
   234    238       return;
   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++;
   245    250     }else{
   246    251       srcid = 0;
................................................................................
   418    423         if( isPriv ) blob_append(pXfer->pOut, "private\n", -1);
   419    424         blob_appendf(pXfer->pOut, "file %b %d\n", pUuid, size);
   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       blob_appendf(pXfer->pOut, "\n", 1);
   431    437     }