Subject: Re: malloc error

From: CHAPAN <[email-masked]>
Date: Wed, 7 Oct 1998 11:23:13 -0500

I think I had the same problem. Try circumventing it by doing this:

In the source code ftpd.c, find the label 'case TYPE_L:'.  The following 
line should be

        if ((buf = (char *) malloc((u_int) blksize)) == NULL) {

Replace it with:

        if ((buf = (char *)  malloc(8192)) == NULL) {

Recompile and test.  I would be curious to know if it fixed your problem. 
 It fixed mine, but
I am enough of a 'C' expert to know exactly why.

---

From: Gregory A Lundberg <[email-masked]>
Date: Wed, 7 Oct 1998 13:39:29 -0400 (EDT)

>         if ((buf = (char *)  malloc(8192)) == NULL) {

[email-masked] reports errors on AIX with malloc.
[email-masked] confirms a problem in send_data().  This patch is
experimental against VR8 to attempt to correct the problem.  I'm working
on the supposition that the problem is data alignment; the 'blksize' is
off_t and malloc() wants a size_t.  I've added a conversion step which
should eliminate the problem.

While this patch is against VR8, it should work against all VR versions
and against the base, beta-18 version.  Hand editing will be required
against beta-18 and VR versions up to VR4 since the THROUGHPUT first
appeared in VR5.  After VR5, this patch should apply cleanly.

diff -c src/ftpd.c.orig src/ftpd.c
*** src/ftpd.c.orig	Mon Sep 28 12:57:31 1998
--- src/ftpd.c	Wed Oct  7 13:28:34 1998
***************
*** 3791,3796 ****
--- 3791,3797 ----
      static char *buf;
      int netfd,
        filefd;
+     size_t size_t_blksize;
  #ifdef THROUGHPUT
      int bps;
      double bpsmult;
***************
*** 3866,3872 ****
          if (bps != -1)
              blksize = bps;
  #endif
!         if ((buf = (char *) malloc((u_int) blksize)) == NULL) {
              transflag = 0;
              perror_reply(451, "Local resource failure: malloc");
              retrieve_is_data = 1;
--- 3867,3874 ----
          if (bps != -1)
              blksize = bps;
  #endif
!         size_t_blksize = blksize;
!         if ((buf = (char *) malloc(size_t_blksize)) == NULL) {
              transflag = 0;
              perror_reply(451, "Local resource failure: malloc");
              retrieve_is_data = 1;
***************
*** 3879,3885 ****
          if (bps != -1)
              t1 = time(NULL);
  #endif
!         while ((cnt = read(filefd, buf, (u_int) blksize)) > 0 &&
                 write(netfd, buf, cnt) == cnt){
  	  alarm((unsigned)timeout);
  	  byte_count += cnt;
--- 3881,3887 ----
          if (bps != -1)
              t1 = time(NULL);
  #endif
!         while ((cnt = read(filefd, buf, size_t_blksize)) > 0 &&
                 write(netfd, buf, cnt) == cnt){
  	  alarm((unsigned)timeout);
  	  byte_count += cnt;

-- 

Gregory A Lundberg		Senior Partner, VRnet Company
1441 Elmdale Drive              [email-masked]
Kettering, OH 45409-1615 USA    1-800-809-2195