Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 1472801 Details for
Bug 1611784
libxcrypt: crypt no longer returns NULL on failure, but "*0"
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Reproducer
salt.c (text/plain), 1.34 KB, created by
Jesse Haber-Kucharsky
on 2018-08-02 17:52:21 UTC
(
hide
)
Description:
Reproducer
Filename:
MIME Type:
Creator:
Jesse Haber-Kucharsky
Created:
2018-08-02 17:52:21 UTC
Size:
1.34 KB
patch
obsolete
>#include <stdbool.h> >#include <errno.h> >#include <stdlib.h> >#include <string.h> >#include <stdio.h> > >#include <crypt.h> > >struct crypt_data* get_crypt_state(void) { > static _Thread_local struct crypt_data* instance = NULL; > > if (instance) { > return instance; > } > > instance = malloc(sizeof(struct crypt_data)); > instance->initialized = 0; > return instance; >} > >#define NUM_ALGORITHMS 4 > >static char* const algorithms[] = { > "$2y$", // bcrypt > "$2a$", // bcrypt > "$5$", // SHA-256 > "$6$", // SHA-512 >}; > >char* generate_random_salt(char* const algorithm) { > // 16 bytes for the random part plus the algorithm, plus some extra. > static _Thread_local char buffer[16 + 8]; > buffer[0] = '\0'; > // "Random". > char const* random_part = "aaaabbbbccccdddd$"; > strcat(buffer, algorithm); > return strcat(buffer, random_part); >} > >int main(void) { > char* const cleartext = "super_secret"; > > for (int i = 0; i < NUM_ALGORITHMS; ++i) { > char* const salt = generate_random_salt(algorithms[i]); > char* const e = crypt_r(cleartext, salt, get_crypt_state()); > > if (!e || (e[0] == '*')) { > printf("%5s: Failed with `%s`\n", algorithms[i], strerror(errno)); > } else { > printf("%5s: Got `%s`\n", algorithms[i], e); > } > } > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1611784
: 1472801