I’m using Perl for a security-related task and am wondering when a statement such as:
$test = "new value"
is executed, is the old value that $test created overwritten in RAM?
If not, is there a way to force that to happen?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the scalar isn’t magical and it has a string buffer and the string fits in the string buffer, then that portion of the string buffer will be overwritten.
Note that
leaves “xxx\0ef\0” in the scalar’s buffer. You want the buffer’s length, and not the length of the string inside the buffer.
I meant to say that neither of
will affect the string buffer whatsoever. It won’t even be deallocated. Similarly, assigning a string to a scalar will not affect the other fields of the scalar, such as fields to hold numbers.
I forgot that if string being assigned to the scalar is a
TEMP, the buffer of the target is replaced instead of being overwritten.