[BusyBox] [PATCH] BB_BUFFER problem

Magnus Damm damm at opensource.se
Tue Apr 30 04:20:06 UTC 2002


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
-------------- next part --------------
--- 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;


More information about the busybox mailing list