Skip to content

Fix empty token on swift package-registry login (Issue #7453) #7454

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

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ private func readpassword(_ prompt: String) throws -> String {

#if canImport(Darwin)
var buffer = [CChar](repeating: 0, count: PackageRegistryCommand.Login.passwordBufferSize)
password = try withExtendedLifetime(buffer) {
guard let passwordPtr = readpassphrase(prompt, &buffer, buffer.count, 0) else {
throw StringError("unable to read input")
}

guard let passwordPtr = readpassphrase(prompt, &buffer, buffer.count, 0) else {
throw StringError("unable to read input")
return String(cString: passwordPtr)
}

password = String(cString: passwordPtr)
#else
// GNU C implementation of getpass has no limit on the password length
// (https://man7.org/linux/man-pages/man3/getpass.3.html)
Expand Down