Perl attribute: length vs 0-byte termination

Julius Plenz plenz at cis.fu-berlin.de
Fri Mar 28 20:03:47 CET 2014


Hi,

some recent change seems to have broken the "rlm_perl" attribute
handling. For a string, instead of adding a scalar value with
appropriate length, it seems the whole buffer (including 0-byte) is
inserted into the Perl hash. Consider this authorize() method:

  sub authorize {
    $RAD_REPLY{'Reply-Message'} = "Username >>".$RAD_REQUEST{'User-Name'}."<<";
    return RLM_MODULE_UPDATED;
  }

This leads, wrongly, to a prematurely terminated string:

  rlm_perl: Added pair Reply-Message = Username >>user

When you add a line like this at the beginning of the subroutine:

  $RAD_REQUEST{'User-Name'} =~ s/\0//g;

...then you'll receive the typical garbage that's in uncleared memory:

  rlm_perl: Added pair Reply-Message = Username >>user ??"c¨?ìå ??...

Somehow, the length computation of the SVs must be fixed, but I don't
know what broke it or how to repair it...

Any help appreciated, thanks in advance!

Julius

P.S.: I've tested this with FreeRADIUS Git tag "release_3_0_2".


More information about the Freeradius-Users mailing list