memory leak in putty PSCP

From: Volker Wehrhahn (v.wehrhahn@autoonline-gmbh.de)
Date: 02/28/02


From: "Volker Wehrhahn" <v.wehrhahn@autoonline-gmbh.de>
Date: Thu, 28 Feb 2002 15:28:21 +0100

Hello,
im using Putty Version 0.52.
I think i have found a memory leak in Program PSCP.

I changed the Funktion fxp_read() in File SFTP.C and the leak disapers.
 //sfree(pktin); <---- Original
 sftp_pkt_free(pktin); // <-- Changed

HTH
Volker Wehrhahn
V.Wehrhahnh@autoonline-gmbh.de

....
int fxp_read(struct fxp_handle *handle, char *buffer, uint64 offset,
      int len)
{
    struct sftp_packet *pktin, *pktout;
    int id;

    pktout = sftp_pkt_init(SSH_FXP_READ);
    sftp_pkt_adduint32(pktout, 0xBCD); /* request id */
    sftp_pkt_addstring_start(pktout);
    sftp_pkt_addstring_data(pktout, handle->hstring, handle->hlen);
    sftp_pkt_adduint64(pktout, offset);
    sftp_pkt_adduint32(pktout, len);
    sftp_send(pktout);
    pktin = sftp_recv();
    if (!pktin) {
 fxp_internal_error("did not receive a valid SFTP packet\n");
 return -1;
    }
    id = sftp_pkt_getuint32(pktin);
    if (id != 0xBCD) {
 fxp_internal_error("request ID mismatch");
 return -1;
    }
    if (pktin->type == SSH_FXP_DATA) {
 char *str;
 int rlen;

 sftp_pkt_getstring(pktin, &str, &rlen);

 if (rlen > len || rlen < 0) {
     fxp_internal_error("READ returned more bytes than requested");
     return -1;
 }

 memcpy(buffer, str, rlen);
 //sfree(pktin); <---- Original
 sftp_pkt_free(pktin); // <-- Changed
 return rlen;
    } else {
 fxp_got_status(pktin);
 return -1;
    }
}
....



Relevant Pages

  • Re: How does "new" work in a loop?
    ... freeware program that does this, but it requires all input and output ... My program seems to work fine, but I'm wondering about this loop: ... fsOut.Write(inputBuffer, 0, (int) inputBuffer.Length); ... Unlikely that you are creating a memory leak. ...
    (microsoft.public.dotnet.languages.csharp)
  • [PATCH 1/3] Audit: break up execve argument lists into multiple records
    ... The limit is currently around 7.5k of arguments as userspace ... memory leak on a malloc failure code path. ... making it harder on the kernel to have the memory it needs. ... int audit_n_rules; ...
    (Linux-Kernel)
  • Memory leak problem
    ... After following the advice received in this list, I have isolated the memory leak problem I am having. ... List = initVoiceChannels(List, TempEvent); ... float generateRandomNumber(int intervalA, int intervalB, int incValues) { ... DLLIST *DLCreate(int Tag, void *Object, size_t Size) ...
    (comp.lang.c)
  • Memory Leak Explanation
    ... that Valgrind identifies this program as having a memory leak. ... Linux Mag Code Sample 2003 May ... int main ...
    (alt.comp.lang.learn.c-cpp)
  • Is there a way to write a memory leak detector supporting new(nothrow)?
    ... Is there a way to write a memory leak detector supporting new? ... int main ...
    (microsoft.public.vc.mfc)