mirror of
git://git.openwrt.org/openwrt/openwrt.git
synced 2025-12-07 21:22:10 -05:00
ucode: update to Git HEAD (2025-11-07)
e8a7290e55c0 socket: fix `recv()` incorrectly reporting unrelated errors ddde611fb9d4 socket: fix convertion of hw addresses to ucode strings 924ccc95be32 vm: make sure uc_vm_insn_to_name() always returns a value 754590d26f23 lexer: fix parsing \xHH and \0OOO escape sequences 623f550e579a fs: add dup2() function 6c9385a99edd fs: add mkdtemp() method for creating temporary directories ea579046a619 fs: reset errno to zero in get_fd() The removed patches are integrated upstream. Fixes: https://github.com/jow-/ucode/issues/332 Fixes: https://github.com/jow-/ucode/issues/337 Link: https://github.com/openwrt/openwrt/pull/20718 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
6af5b8033c
commit
985394bf26
@ -12,9 +12,9 @@ PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=https://github.com/jow-/ucode.git
|
||||
PKG_SOURCE_DATE:=2025-09-29
|
||||
PKG_SOURCE_VERSION:=1090abb125490d2f541f68453cc251daf94f8b04
|
||||
PKG_MIRROR_HASH:=b68d893867add47b92d519a631c4e3bacec52eafae088b6a64ba3935f169bb15
|
||||
PKG_SOURCE_DATE:=2025-11-07
|
||||
PKG_SOURCE_VERSION:=ea579046a619e5325b994780bf2ce1ffde448794
|
||||
PKG_MIRROR_HASH:=4c152c337963eda588650f439f7633fc1ead20864d8939e45fd95563ea2b0b4f
|
||||
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
|
||||
PKG_LICENSE:=ISC
|
||||
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Sun, 5 Oct 2025 11:25:15 +0200
|
||||
Subject: [PATCH] lexer: fix parsing \xHH and \0OOO escape sequences
|
||||
|
||||
Both need to add add bytes, not UTF-8 sequences.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/lexer.c
|
||||
+++ b/lexer.c
|
||||
@@ -277,7 +277,7 @@ parse_escape(uc_lexer_t *lex, const char
|
||||
code = code * 16 + hex(ch);
|
||||
}
|
||||
|
||||
- append_utf8(lex, code);
|
||||
+ uc_vector_push(&lex->buffer, code);
|
||||
}
|
||||
|
||||
/* octal or letter */
|
||||
@@ -293,7 +293,7 @@ parse_escape(uc_lexer_t *lex, const char
|
||||
if (code > 255)
|
||||
return emit_op(lex, -3, TK_ERROR, ucv_string_new("Invalid escape sequence"));
|
||||
|
||||
- append_utf8(lex, code);
|
||||
+ uc_vector_push(&lex->buffer, code);
|
||||
}
|
||||
|
||||
/* ... no octal sequence, handle potential regex macros */
|
||||
@ -1,75 +0,0 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Wed, 8 Oct 2025 22:15:42 +0200
|
||||
Subject: [PATCH] fs: add dup2() function
|
||||
|
||||
Add dup2() function to duplicate file descriptors, useful for redirecting
|
||||
standard streams in child processes.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/lib/fs.c
|
||||
+++ b/lib/fs.c
|
||||
@@ -1278,6 +1278,54 @@ uc_fs_fdopen(uc_vm_t *vm, size_t nargs)
|
||||
return ucv_resource_create(vm, "fs.file", fp);
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * Duplicates a file descriptor.
|
||||
+ *
|
||||
+ * This function duplicates the file descriptor `oldfd` to `newfd`. If `newfd`
|
||||
+ * was previously open, it is silently closed before being reused.
|
||||
+ *
|
||||
+ * Returns `true` on success.
|
||||
+ * Returns `null` on error.
|
||||
+ *
|
||||
+ * @function module:fs#dup2
|
||||
+ *
|
||||
+ * @param {number} oldfd
|
||||
+ * The file descriptor to duplicate.
|
||||
+ *
|
||||
+ * @param {number} newfd
|
||||
+ * The file descriptor number to duplicate to.
|
||||
+ *
|
||||
+ * @returns {?boolean}
|
||||
+ *
|
||||
+ * @example
|
||||
+ * // Redirect stderr to a log file
|
||||
+ * const logfile = open('/tmp/error.log', 'w');
|
||||
+ * dup2(logfile.fileno(), 2);
|
||||
+ * logfile.close();
|
||||
+ */
|
||||
+static uc_value_t *
|
||||
+uc_fs_dup2(uc_vm_t *vm, size_t nargs)
|
||||
+{
|
||||
+ uc_value_t *oldfd_arg = uc_fn_arg(0);
|
||||
+ uc_value_t *newfd_arg = uc_fn_arg(1);
|
||||
+ int oldfd, newfd;
|
||||
+
|
||||
+ oldfd = get_fd(vm, oldfd_arg);
|
||||
+
|
||||
+ if (oldfd == -1)
|
||||
+ err_return(errno ? errno : EBADF);
|
||||
+
|
||||
+ newfd = get_fd(vm, newfd_arg);
|
||||
+
|
||||
+ if (newfd == -1)
|
||||
+ err_return(errno ? errno : EBADF);
|
||||
+
|
||||
+ if (dup2(oldfd, newfd) == -1)
|
||||
+ err_return(errno);
|
||||
+
|
||||
+ return ucv_boolean_new(true);
|
||||
+}
|
||||
+
|
||||
|
||||
/**
|
||||
* Represents a handle for interacting with a directory opened by `opendir()`.
|
||||
@@ -2890,6 +2938,7 @@ static const uc_function_list_t global_f
|
||||
{ "error", uc_fs_error },
|
||||
{ "open", uc_fs_open },
|
||||
{ "fdopen", uc_fs_fdopen },
|
||||
+ { "dup2", uc_fs_dup2 },
|
||||
{ "opendir", uc_fs_opendir },
|
||||
{ "popen", uc_fs_popen },
|
||||
{ "readlink", uc_fs_readlink },
|
||||
@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
--- a/lib/fs.c
|
||||
+++ b/lib/fs.c
|
||||
@@ -674,6 +674,116 @@ uc_fs_read(uc_vm_t *vm, size_t nargs)
|
||||
@@ -675,6 +675,116 @@ uc_fs_read(uc_vm_t *vm, size_t nargs)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +127,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
* Writes a chunk of data to the file handle.
|
||||
*
|
||||
* In case the given data is not a string, it is converted to a string before
|
||||
@@ -2910,6 +3020,7 @@ static const uc_function_list_t proc_fns
|
||||
@@ -2991,6 +3101,7 @@ static const uc_function_list_t proc_fns
|
||||
|
||||
static const uc_function_list_t file_fns[] = {
|
||||
{ "read", uc_fs_read },
|
||||
|
||||
@ -1,107 +0,0 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Thu, 9 Oct 2025 14:11:55 +0200
|
||||
Subject: [PATCH] fs: add mkdtemp() method for creating temporary directories
|
||||
|
||||
Returns the directory path as a string, following the same template
|
||||
handling pattern as mkstemp().
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/lib/fs.c
|
||||
+++ b/lib/fs.c
|
||||
@@ -2636,6 +2636,86 @@ uc_fs_mkstemp(uc_vm_t *vm, size_t nargs)
|
||||
}
|
||||
|
||||
/**
|
||||
+ * Creates a unique temporary directory based on the given template.
|
||||
+ *
|
||||
+ * If the template argument is given and contains a relative path, the created
|
||||
+ * directory will be placed relative to the current working directory.
|
||||
+ *
|
||||
+ * If the template argument is given and contains an absolute path, the created
|
||||
+ * directory will be placed relative to the given directory.
|
||||
+ *
|
||||
+ * If the template argument is given but does not contain a directory separator,
|
||||
+ * the directory will be placed in `/tmp/`.
|
||||
+ *
|
||||
+ * If no template argument is given, the default `/tmp/XXXXXX` is used.
|
||||
+ *
|
||||
+ * The template argument must end with six consecutive X characters (`XXXXXX`),
|
||||
+ * which will be replaced with a random string to create the unique directory name.
|
||||
+ * If the template does not end with `XXXXXX`, it will be automatically appended.
|
||||
+ *
|
||||
+ * Returns a string containing the path of the created directory on success.
|
||||
+ *
|
||||
+ * Returns `null` if an error occurred, e.g. on insufficient permissions or
|
||||
+ * inaccessible directory.
|
||||
+ *
|
||||
+ * @function module:fs#mkdtemp
|
||||
+ *
|
||||
+ * @param {string} [template="/tmp/XXXXXX"]
|
||||
+ * The path template to use when forming the temporary directory name.
|
||||
+ *
|
||||
+ * @returns {?string}
|
||||
+ *
|
||||
+ * @example
|
||||
+ * // Create a unique temporary directory in the current working directory
|
||||
+ * const tempDir = mkdtemp('./data-XXXXXX');
|
||||
+ */
|
||||
+static uc_value_t *
|
||||
+uc_fs_mkdtemp(uc_vm_t *vm, size_t nargs)
|
||||
+{
|
||||
+ uc_value_t *template = uc_fn_arg(0);
|
||||
+ bool ends_with_template = false;
|
||||
+ char *path, *t, *result;
|
||||
+ uc_value_t *rv;
|
||||
+ size_t l;
|
||||
+
|
||||
+ if (template && ucv_type(template) != UC_STRING)
|
||||
+ err_return(EINVAL);
|
||||
+
|
||||
+ t = ucv_string_get(template);
|
||||
+ l = ucv_string_length(template);
|
||||
+
|
||||
+ ends_with_template = (l >= 6 && strcmp(&t[l - 6], "XXXXXX") == 0);
|
||||
+
|
||||
+ if (t && strchr(t, '/')) {
|
||||
+ if (ends_with_template)
|
||||
+ xasprintf(&path, "%s", t);
|
||||
+ else
|
||||
+ xasprintf(&path, "%s.XXXXXX", t);
|
||||
+ }
|
||||
+ else if (t) {
|
||||
+ if (ends_with_template)
|
||||
+ xasprintf(&path, "/tmp/%s", t);
|
||||
+ else
|
||||
+ xasprintf(&path, "/tmp/%s.XXXXXX", t);
|
||||
+ }
|
||||
+ else {
|
||||
+ xasprintf(&path, "/tmp/XXXXXX");
|
||||
+ }
|
||||
+
|
||||
+ result = mkdtemp(path);
|
||||
+
|
||||
+ if (!result) {
|
||||
+ free(path);
|
||||
+ err_return(errno);
|
||||
+ }
|
||||
+
|
||||
+ rv = ucv_string_new(result);
|
||||
+ free(path);
|
||||
+
|
||||
+ return rv;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
* Checks the accessibility of a file or directory.
|
||||
*
|
||||
* The optional modes argument specifies the access modes which should be
|
||||
@@ -3069,6 +3149,7 @@ static const uc_function_list_t global_f
|
||||
{ "basename", uc_fs_basename },
|
||||
{ "lsdir", uc_fs_lsdir },
|
||||
{ "mkstemp", uc_fs_mkstemp },
|
||||
+ { "mkdtemp", uc_fs_mkdtemp },
|
||||
{ "access", uc_fs_access },
|
||||
{ "readfile", uc_fs_readfile },
|
||||
{ "writefile", uc_fs_writefile },
|
||||
Loading…
Reference in New Issue
Block a user