Reset errno before system calls

This commit is contained in:
0x1eef 2024-03-10 11:19:45 -03:00
parent b6e28f02b0
commit a67db2277d
2 changed files with 2 additions and 0 deletions

View file

@ -20,6 +20,7 @@ feature_set(VALUE self, VALUE rb_path, VALUE rb_state)
static VALUE static VALUE
__set(VALUE rb_path, VALUE rb_feature, VALUE rb_state) __set(VALUE rb_path, VALUE rb_feature, VALUE rb_state)
{ {
errno = 0;
int result = hbsdcontrol_set_feature_state( int result = hbsdcontrol_set_feature_state(
RSTRING_PTR(rb_path), RSTRING_PTR(rb_path),
RSTRING_PTR(rb_feature), RSTRING_PTR(rb_feature),

View file

@ -73,6 +73,7 @@ ffi_status(VALUE self, VALUE rb_feature, VALUE rb_path)
char enable_data[2], disable_data[2]; char enable_data[2], disable_data[2];
int ns; int ns;
errno = 0;
options = __options_init(rb_feature, rb_path); options = __options_init(rb_feature, rb_path);
if (extattr_string_to_namespace("system", &ns) == -1) { if (extattr_string_to_namespace("system", &ns) == -1) {
rb_syserr_fail(errno, "extattr_string_to_namespace"); rb_syserr_fail(errno, "extattr_string_to_namespace");