From a67db2277d59120faee016317acc75e0018dc367 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sun, 10 Mar 2024 11:19:45 -0300 Subject: [PATCH] Reset errno before system calls --- ext/hbsdctl.rb/feature.c | 1 + ext/hbsdctl.rb/ffi.c | 1 + 2 files changed, 2 insertions(+) diff --git a/ext/hbsdctl.rb/feature.c b/ext/hbsdctl.rb/feature.c index 35a1469..1295da9 100644 --- a/ext/hbsdctl.rb/feature.c +++ b/ext/hbsdctl.rb/feature.c @@ -20,6 +20,7 @@ feature_set(VALUE self, VALUE rb_path, VALUE rb_state) static VALUE __set(VALUE rb_path, VALUE rb_feature, VALUE rb_state) { + errno = 0; int result = hbsdcontrol_set_feature_state( RSTRING_PTR(rb_path), RSTRING_PTR(rb_feature), diff --git a/ext/hbsdctl.rb/ffi.c b/ext/hbsdctl.rb/ffi.c index c3326c9..8645af3 100644 --- a/ext/hbsdctl.rb/ffi.c +++ b/ext/hbsdctl.rb/ffi.c @@ -73,6 +73,7 @@ ffi_status(VALUE self, VALUE rb_feature, VALUE rb_path) char enable_data[2], disable_data[2]; int ns; + errno = 0; options = __options_init(rb_feature, rb_path); if (extattr_string_to_namespace("system", &ns) == -1) { rb_syserr_fail(errno, "extattr_string_to_namespace");