-
Notifications
You must be signed in to change notification settings - Fork 425
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
Support MacPorts (installing and running) #429
Comments
Hi, yes, it'd be great to get MacPorts to work. The choice-title thing is tracked at #366. The state of user/groups conformance is indeed quite dismal (and package managers are the ones that care most about this), see #354, we'd appreciate any ideas how to make this work better. (Having some version of As for the |
Installing now gives this error:
and running gives this error:
|
This might be related to https://reviews.llvm.org/D40856. |
Yes, we need to implement This is an optional API the underlying filesystem may not support. Pretty much all of Apple's code falls back to |
This is the current state. We need to implement more of CoreCrypto:
I don't have a backtrace yet, but this is the crash:
|
Current state after libsystem_trace fix:
|
So, repeatedly using libcurl definitely uncovers this memory corruption. Something within corecrypto is probably stepping out of bounds. This is something for @ahyattdev. Either way, without working corecrypto, MacPorts support won't move forward.
|
This is simple (with libgmalloc 🙂). Compare to this just above: On another note, this function leaks the buffers on errors. Would be better off |
Proposed patch to fix the above: --- a/src/ccrsa.c
+++ b/src/ccrsa.c
@@ -85,7 +85,7 @@ int ccrsa_verify_pkcs1v15(ccrsa_pub_ctx_t key, const uint8_t *oid,
cc_size sig_units = ccn_nof_size(sig_len);
cc_size sig_bytes = ccn_sizeof_n(sig_units);
- cc_unit *s = malloc(sig_bytes);
+ cc_unit *s = alloca(sig_bytes);
if (ccn_read_uint(sig_units, s, sig_len, sig))
{
#if DEBUG
@@ -104,14 +104,15 @@ int ccrsa_verify_pkcs1v15(ccrsa_pub_ctx_t key, const uint8_t *oid,
return 1;
}
- cc_size m_size = ccn_sizeof_size(digest_len);
- cc_unit *m = malloc(m_size);
- ccn_read_uint(m_size, m, digest_len, digest);
+ cc_size digest_units = ccn_sizeof_size(digest_len);
+ cc_size digest_bytes = ccn_sizeof_n(digest_units);
+ cc_unit *m = alloca(digest_bytes);
+ ccn_read_uint(digest_units, m, digest_len, digest);
// m = s^e mod n
-
- struct cczp *zp = malloc(cczp_size(m_size));
+
+ struct cczp *zp = alloca(cczp_size(digest_units));
CCZP_N(zp) = ccn_nof_size(digest_len);
// maybe we should copy modulus into cczp_prime
cc_unit *zp_mod = (void *)zp + sizeof(struct cczp) /*+ ccn_sizeof_n(1)*/;
@@ -120,17 +121,11 @@ int ccrsa_verify_pkcs1v15(ccrsa_pub_ctx_t key, const uint8_t *oid,
ccn = zp_mod;
cczp_init(zp);
//void cczp_power(cczp_const_t zp, cc_unit *r, const cc_unit *m, const cc_unit *e);
-
- cc_unit *r = malloc(sig_bytes);
+
+ cc_unit *r = alloca(sig_bytes);
cczp_power(zp, r, m, exponent);
printf("we get here \n");
-
- free(s);
- free(zp);
- free(m);
-
-
}
/*
then we crash in (malloc shouldn't be used there either). |
--- a/src/cczp.c
+++ b/src/cczp.c
@@ -20,7 +20,7 @@ void cczp_mod(cczp_const_t zp, cc_unit *r, const cc_unit *s2n, cc_ws_t ws)
/*
if D = 0 then error(DivisionByZeroException) end
Q := 0 -- Initialize quotient and remainder to zero
-R := 0
+R := 0
for i := n <E2><88><92> 1 .. 0 do -- Where n is number of bits in N
R := R << 1 -- Left-shift R by 1 bit
R(0) := N(i) -- Set the least-significant bit of R equal to bit i of the numerator
@@ -133,21 +133,19 @@ void cczp_power(cczp_const_t zp, cc_unit *r, const cc_unit *m,
}
// TODO: Assert :: (modulus - 1) * (modulus - 1) does not overflow base
-
+
// Result is still one at this point
-
- cc_unit *base = malloc(n_sizeof*2);
+
+ cc_unit *base = alloca(n_sizeof*2);
memset(base, 0, n_sizeof*2);
memcpy(base, m, n_sizeof);
// Use a workspace size 2n+1 because ws.end is non-inclusive end pointer
- cc_ws_t ws;
- ws->start = malloc(n*2+1);
- ws->end = ws->start+(n*2);
+ cc_ws ws;
+ ws.start = alloca(n*2+1);
+ ws.end = ws.start+(n*2);
// ccn integers are little endian, so it's OK that the 3rd parameter
// is length 2n (despite not needing it)
- cczp_mod_prime(zp)(zp, base, base, ws);
-
- free(ws->start);
+ cczp_mod_prime(zp)(zp, base, base, &ws);
} With this, the example seems to no longer crash, whether run with gmalloc or not. |
I've build and installed the latest darling master on an up to date Archlinux.
Installing MacPorts
Being optimistic I tried to install the MacPorts pkg, but the darling installer failed due to a missing "title" attribute in some "choice" tags in the bundled XML. I was able to workaround this by using xar to extract the pkg, edit the XML (copied the id attribute content to a new title attribute) and create a new pkg. This new pkg was installable using the darling installer, though some warnings/errors is displayed:
Running MacPorts
Since macport did actually install I then (of course) tried to run it:
I will admit that I did not install Xcode as normally required for MacPorts since I hoped to use MacPorts binary packages, without compiling. So some of the errors shown above might disappear if Xcode is installed, though I think the installer should support the macport pkg format (without title attributes in choice tags).
The text was updated successfully, but these errors were encountered: