Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Milter Code Review.

1 view
Skip to first unread message

stevfl...@gmail.com

unread,
Oct 1, 2008, 4:20:01 PM10/1/08
to
Hi everyone,

I was wondering if anyone had any suggestions on where I could go to
get some advice on a milter I wrote. It seems to be leaking memory
and I am not sure why. Please understand this is my first project in
c and I have also used it in learning c. Previous to this I have only
written a small hand full of programs no more than about 30 lines each
in c.

If any of you would like to take a look the source code is located at
http://www.fletchcom.com/spamhammilt-0.1.tar.gz and thank you in
advance for any help and pointers, no pun intended, with this.

Thanks

Steven

seaPea

unread,
Oct 2, 2008, 9:12:43 AM10/2/08
to
stevfletch...@gmail.com wrote:
> Hi everyone,
>
> I was wondering if anyone had any suggestions on where I could go to
> get some advice on a milter I wrote. It seems to be leaking memory
> and I am not sure why. Please understand this is my first project in
> c and I have also used it in learning c. Previous to this I have only
> written a small hand full of programs no more than about 30 lines each
> in c.
> [...]

have you tried tek-tips or experts-exchange ?

H.Janssen

unread,
Oct 5, 2008, 3:37:52 AM10/5/08
to
Hello Steven,

stevfl...@gmail.com wrote:

I'm not an expert programmer, but it looks very good, with all kind of error
handling, clearing memory and so on.

But what definitively is wrong is the regexp: the regex_t structure contains
a pointer to a character array which is filled by regcomp.... and never
freed. You have to add "regfree(&rx)" and to be sure that it is called
always:

err = regcomp ( &rx,expr,REG_EXTENDED|REG_ICASE|REG_NOSUB );
regfree(&rx);


Nevertheless, on my system the program crashes under extreme load, so there
is another thing not 100% ok, but I'm do not know what.....

Test:
cat /etc/profile | mail -s "test" username in a loop over 1000 times,
which may load the system more then ever in normal use....

Good luck!

H.Janssen
Alkmaar
The Netherlands


H.Janssen

unread,
Oct 5, 2008, 4:15:27 AM10/5/08
to
H.Janssen wrote:

Sorry,

> err = regcomp ( &rx,expr,REG_EXTENDED|REG_ICASE|REG_NOSUB );
> regfree(&rx);
>
>

Of course, regfree should not be directly behind regcomp,
because in that case regexec will fail,
but behind regexec().

I only do not know whether you must call regfree() in case
regcomp() returns an error, that's not clear from the documentation.

stevfl...@gmail.com

unread,
Oct 7, 2008, 2:36:05 PM10/7/08
to
On Oct 5, 2:15 am, "H.Janssen" <he...@nospam.hmmsjan.dosgg.nlnospam>
wrote:

Thank you very much for the review and the idea about the regex. I'll
give it a try and continue digging for leaks.

Steven Fletcher

0 new messages