Calculate remaining buffer length based on current rule length

We found that rules were being generated that were longer than the
1024 character limit.  With this fix, the buffer size is calculated
based on the starting buffer size minus the current rule size to
take into account things like "OR" or spaces added into the rule.