[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [BusyBox] [PATCH] BB_BUFFER problem
From:       Magnus Damm <damm () opensource ! se>
Date:       2002-04-30 4:20:06
[Download RAW message or body]

Hi all,

What's the plan with RESERVE/RELEASE_BB_BUFFER code?
I understand what it's used for but...

Take busybox-0.60.3 and grep for BB_BUFFER:
syslogd.c:      RESERVE_BB_BUFFER(tmpbuf, BUFSIZE + 1);
syslogd.c:      RELEASE_BB_BUFFER (tmpbuf);
grep: tests: Is a directory
tftp.c: /* Can't use RESERVE_BB_BUFFER here since the allocation
tftp.c:        RELEASE_BB_BUFFER(buf);
tr.c:   RESERVE_BB_BUFFER(output, BUFSIZ);
tr.c:   RESERVE_BB_BUFFER(input,  BUFSIZ);
tr.c:   RESERVE_BB_BUFFER(invec,  ASCII+1);
tr.c:   RESERVE_BB_BUFFER(outvec, ASCII+1);
uuencode.c:     RESERVE_BB_BUFFER(src_buf, src_buf_size + 1);
uuencode.c:     RESERVE_BB_BUFFER(dst_buf, dst_buf_size + 1);

Here we can see that syslogd acts nice and releases the buffer.
The other applications does not. The default BUFFER settings in 
Config.h results that buffers are xmalloc():ed. 
tftp will RELEASE_BB_BUFFER() on a xmalloc():ed buffer, bad 
but works by default.
And tr and uuencode does not RELEASE_BB_BUFFER() at all.

A fix for tftp is trivial, patch is attached.

But tr and uuencode both use show_usage(), and tr might do a
error_msg_and_die(). This exit():ing makes it hard to release
buffers correctly... 

This problem exists in the development branch too.

/ Magnus
["busybox-0.60.3-tftp-bb_fix.patch" (text/plain)]

--- busybox-0.60.3/tftp.c	Mon Apr 15 09:40:24 2002
+++ busybox-0.60.3-bb_fix/tftp.c	Tue Apr 30 11:24:44 2002
@@ -478,7 +478,7 @@
 #ifdef BB_FEATURE_CLEAN_UP
 	close(socketfd);
 
-        RELEASE_BB_BUFFER(buf);
+        free(buf);
 #endif
 
 	return finished ? EXIT_SUCCESS : EXIT_FAILURE;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic