"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/utils_luks2.c" between
cryptsetup-2.3.6.tar.xz and cryptsetup-2.4.0.tar.xz

About: cryptsetup is a utility used to conveniently setup disk encryption based on the dm-crypt kernel module. These include plain dm-crypt volumes, LUKS volumes, loop-AES and TrueCrypt compatible format.

utils_luks2.c  (cryptsetup-2.3.6.tar.xz):utils_luks2.c  (cryptsetup-2.4.0.tar.xz)
skipping to change at line 30 skipping to change at line 30
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "cryptsetup.h" #include "cryptsetup.h"
/* /*
* FIXME: 4MiBs is max LUKS2 mda length (including binary header). * FIXME: 4MiBs is max LUKS2 mda length (including binary header).
* In future, read max allowed JSON size from config section. * In future, read max allowed JSON size from config section.
*/ */
#define LUKS2_MAX_MDA_SIZE 0x400000 #define LUKS2_MAX_MDA_SIZE 0x400000
int tools_read_json_file(struct crypt_device *cd, const char *file, char **json, size_t *json_size) int tools_read_json_file(const char *file, char **json, size_t *json_size, bool batch_mode)
{ {
ssize_t ret; ssize_t ret;
int fd, block, r; int fd, block, r;
void *buf = NULL; void *buf = NULL;
block = tools_signals_blocked(); block = tools_signals_blocked();
if (block) if (block)
set_int_block(0); set_int_block(0);
if (tools_is_stdin(file)) { if (tools_is_stdin(file)) {
skipping to change at line 59 skipping to change at line 59
goto out; goto out;
} }
} }
buf = malloc(LUKS2_MAX_MDA_SIZE); buf = malloc(LUKS2_MAX_MDA_SIZE);
if (!buf) { if (!buf) {
r = -ENOMEM; r = -ENOMEM;
goto out; goto out;
} }
if (isatty(fd) && !opt_batch_mode) if (isatty(fd) && !batch_mode)
log_std(_("Provide valid LUKS2 token JSON:\n")); log_std(_("Provide valid LUKS2 token JSON:\n"));
/* we expect JSON (string) */ /* we expect JSON (string) */
r = 0; r = 0;
ret = read_buffer_intr(fd, buf, LUKS2_MAX_MDA_SIZE - 1, &quit); ret = read_buffer_intr(fd, buf, LUKS2_MAX_MDA_SIZE - 1, &quit);
if (ret < 0) { if (ret < 0) {
r = -EIO; r = -EIO;
log_err(_("Failed to read JSON file.")); log_err(_("Failed to read JSON file."));
goto out; goto out;
} }
skipping to change at line 91 skipping to change at line 91
set_int_block(1); set_int_block(1);
if (fd >= 0 && fd != STDIN_FILENO) if (fd >= 0 && fd != STDIN_FILENO)
close(fd); close(fd);
if (r && buf) { if (r && buf) {
memset(buf, 0, LUKS2_MAX_MDA_SIZE); memset(buf, 0, LUKS2_MAX_MDA_SIZE);
free(buf); free(buf);
} }
return r; return r;
} }
int tools_write_json_file(struct crypt_device *cd, const char *file, const char *json) int tools_write_json_file(const char *file, const char *json)
{ {
int block, fd, r; int block, fd, r;
size_t json_len; size_t json_len;
ssize_t ret; ssize_t ret;
if (!json || !(json_len = strlen(json)) || json_len >= LUKS2_MAX_MDA_SIZE ) if (!json || !(json_len = strlen(json)) || json_len >= LUKS2_MAX_MDA_SIZE )
return -EINVAL; return -EINVAL;
block = tools_signals_blocked(); block = tools_signals_blocked();
if (block) if (block)
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)