···11#include "errno.h"
22#include "base.h"
33#include "duct_errno.h"
44+#include <stddef.h>
4556static const int linux_to_darwin[512] = {
67···9091 [LINUX_ETIME] = ETIME,
9192 [LINUX_EOPNOTSUPP] = EOPNOTSUPP,
9293};
9494+const size_t length_of_translation_array = sizeof(linux_to_darwin)/sizeof(const int);
93959496int errno_linux_to_bsd(int err)
9597{
···9799 if (v < 0)
98100 v = -v;
99101100100- if (linux_to_darwin[v])
102102+ if ((v < length_of_translation_array) && (linux_to_darwin[v]))
101103 {
102104 v = linux_to_darwin[v];
103105 return (err < 0) ? -v : v;
+1-1
src/kernel/libsyscall/bsdsyscalls/___syscall.S
···3737 pushl %ecx
3838 UNIX_SYSCALL_TRAP
3939 movl (%esp),%edx // add one element to stack so
4040- pushl %ecx // caller "pop" will work
4040+ pushl %edx // caller "pop" will work
4141 jnb 2f
4242 BRANCH_EXTERN(tramp_cerror)
43432:
+30-2
src/startup/darling.c
···501501 }
502502}
503503504504+// Replace each quote character (') with the sequence '\''
505505+// (copying the result to dest, if non-null)
506506+// and return the length of the result.
507507+static size_t escapeQuotes(char *dest, const char *src)
508508+{
509509+ size_t len = 0;
510510+511511+ for (; *src != 0; src++)
512512+ {
513513+ if (*src == '\'')
514514+ {
515515+ if (dest)
516516+ memcpy(&dest[len], "'\\''", 4);
517517+ len += 4;
518518+ }
519519+ else
520520+ {
521521+ if (dest)
522522+ dest[len] = *src;
523523+ len++;
524524+ }
525525+ }
526526+ if (dest)
527527+ dest[len] = 0;
528528+529529+ return len;
530530+}
531531+504532void spawnShell(const char** argv)
505533{
506534 size_t total_len = 0;
···514542 if (argv != NULL)
515543 {
516544 for (count = 0; argv[count] != NULL; count++)
517517- total_len += strlen(argv[count]);
545545+ total_len += escapeQuotes(NULL, argv[count]);
518546519547 buffer = malloc(total_len + count*3);
520548···524552 if (to != buffer)
525553 to = stpcpy(to, " ");
526554 to = stpcpy(to, "'");
527527- to = stpcpy(to, argv[i]);
555555+ to += escapeQuotes(to, argv[i]);
528556 to = stpcpy(to, "'");
529557 }
530558 }