[OpenSIPS/opensips] 04eaa1: cfg preprocessor: Fix a dirty buffer management bug

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[OpenSIPS/opensips] 04eaa1: cfg preprocessor: Fix a dirty buffer management bug

Răzvan Crainea-3
  Branch: refs/heads/3.0
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 04eaa15dab8c632b24fe07e961a0b877458dd7ca
      https://github.com/OpenSIPS/opensips/commit/04eaa15dab8c632b24fe07e961a0b877458dd7ca
  Author: Liviu Chircu <[hidden email]>
  Date:   2019-07-27 (Sat, 27 Jul 2019)

  Changed paths:
    M cfg_pp.c

  Log Message:
  -----------
  cfg preprocessor: Fix a dirty buffer management bug

One of those pesky bugs, caused by not knowing your snprintf's well...
This strange, seemingly inexplicable bug only manifested whenever a
series of config file lines + preprocessor tokens formed a multiple
of 4096 bytes, the amount by which the preprocessor buffer gets extended
with each reallocation.

With such config files, the snprintf() would truncate the last byte of
the config file line adding up to N*4096 bytes (usually a '\n'), and put
a '\0' instead, after which the preprocessing continued normally.

However, it seems Yacc isn't too happy when you feed it with a buffer
which includes '\0' characters, as this will cause it to barf some
binary data to stdout, somewhat ruining the logfile.

(cherry picked from commit bf968d01679a48b9ff79f4edb9abf2743d3586b1)



_______________________________________________
Devel mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel