Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For ASCII string values do not leak NULL terminating character, which is a C thing, into perl. #3

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

glebius
Copy link

@glebius glebius commented Feb 25, 2021

This is an old bug in the module that still, I believe, should to be fixed. Of course it can be workaround by unpack("A*", $value) for any string value returned, and many old-timers do that already. However, for any new user this is extremely annoying. Especially since it is virtually impossible to understand what's going wrong from inside one's perl program.

cat t.pl
#!/usr/local/bin/perl

use BSD::Sysctl 'sysctl';

$n = BSD::Sysctl->iterator('kern');
$n->next;
$v = $n->value;
$V = 'FreeBSD';

printf(""%s" is %s to "%s"\n", $v, ($v eq $V) ? 'equal' : 'not equal', $V);

./t.pl
"FreeBSD" is not equal to "FreeBSD"

@glebius glebius force-pushed the master branch 3 times, most recently from a60ceb9 to fc7e43d Compare March 4, 2021 17:51
glebius added 8 commits March 5, 2021 09:25
there are no declarations of sysctl format that start with "T".
- Use the same namespace that sys/sysctl.h uses.
- For real types (e.g. string, int, long) use directly values
  from sys/sysctl.h.  Generate bsd-sysctl.ph from sys/sysctl.h.
- For structures that we know add more types in the same
  namespace and valuespace.
- In _mib_info() prefer digital kind marker over format string.
  Parse the format string only for CTLTYPE_OPAQUE in search of
  known structures.
While here:
- Include bsd-sysctl.ph into Sysctl.pm during build, a TODO item.
- Don't put copyright into generated files.
- Add support for CTLTYPE_S32 and CTLTYPE_U32
which is a C thing, into perl.  Add a test.
module-starter does.  While here create .gitignore.
The sysctl was removed in c29ba5fe6e3aa26e4fa68b1efa16703b55ac8c05
in 2006.  Recently the dead code started to fail to compile.

NB: very likely many (or most) of the recognized structures defined
in the __DATA__ part of the Makefile.PL are also a dead code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants