diff --git a/config.h.in b/config.h.in deleted file mode 100644 index dbc77857..00000000 --- a/config.h.in +++ /dev/null @@ -1,165 +0,0 @@ -/* config.h.in. Generated from configure.in by autoheader. */ - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -#undef ENABLE_NLS - -/* Definition for the gettext package name */ -#undef GETTEXT_PACKAGE - -/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the - CoreFoundation framework. */ -#undef HAVE_CFLOCALECOPYCURRENT - -/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in - the CoreFoundation framework. */ -#undef HAVE_CFPREFERENCESCOPYAPPVALUE - -/* Define to 1 if you have the header file. */ -#undef HAVE_CTYPE_H - -/* Define if the GNU dcgettext() function is already present or preinstalled. - */ -#undef HAVE_DCGETTEXT - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_DIRENT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define if the GNU gettext() function is already present or preinstalled. */ -#undef HAVE_GETTEXT - -/* Define if you have the iconv() function. */ -#undef HAVE_ICONV - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `devmapper' library (-ldevmapper). */ -#undef HAVE_LIBDEVMAPPER - -/* Define to 1 if you have the `popt' library (-lpopt). */ -#undef HAVE_LIBPOPT - -/* Define to 1 if you have the `selinux' library (-lselinux). */ -#undef HAVE_LIBSELINUX - -/* Define to 1 if you have the `sepol' library (-lsepol). */ -#undef HAVE_LIBSEPOL - -/* Define to 1 if you have the `uuid' library (-luuid). */ -#undef HAVE_LIBUUID - -/* Define to 1 if you have the header file. */ -#undef HAVE_LOCALE_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MALLOC_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -#undef HAVE_NDIR_H - -/* Define to 1 if you have the `setlocale' function. */ -#undef HAVE_SETLOCALE - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if `st_rdev' is member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_RDEV - -/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use - `HAVE_STRUCT_STAT_ST_RDEV' instead. */ -#undef HAVE_ST_RDEV - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_SYS_DIR_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_IOCTL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_MMAN_H - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#undef HAVE_SYS_NDIR_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UUID_UUID_H - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define if you wish to use the plugin loader */ -#undef USE_PLUGINS - -/* Version number of package */ -#undef VERSION - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -#undef WORDS_BIGENDIAN - -/* Number of bits in a file offset, on hosts where this is settable. */ -#undef _FILE_OFFSET_BITS - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif - -/* Define for large files, on AIX-style hosts. */ -#undef _LARGE_FILES - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `long int' if does not define. */ -#undef off_t diff --git a/lib/setup.c b/lib/setup.c index 5ac7028d..60621a9f 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -418,7 +418,7 @@ static int __crypt_luks_format(int arg, struct setup_backend *backend, struct cr } mk = LUKS_generate_masterkey(options->key_size); - if(NULL == mk) return -ENOMEM; + if(NULL == mk) return -ENOMEM; // FIXME This may be misleading, since we don't know what went wrong #ifdef LUKS_DEBUG #define printoffset(entry) logger(options, CRYPT_LOG_ERROR, ("offset of " #entry " = %d\n", (char *)(&header.entry)-(char *)(&header)) diff --git a/lib/utils.c b/lib/utils.c index 4d0e10d9..32e447f7 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -243,6 +243,7 @@ ssize_t write_lseek_blockwise(int fd, const char *buf, size_t count, off_t offse memcpy(frontPadBuf+frontHang, buf, innerCount); + lseek(fd, offset - frontHang, SEEK_SET); r = write(fd,frontPadBuf,bsize); if(r < 0) return -1; @@ -251,7 +252,7 @@ ssize_t write_lseek_blockwise(int fd, const char *buf, size_t count, off_t offse } if(count <= 0) return buf - orig_buf; - return write_blockwise(fd, buf, count); + return write_blockwise(fd, buf, count) + innerCount; } /* Password reading helpers */ diff --git a/luks/keymanage.c b/luks/keymanage.c index 56556ab0..53147e99 100644 --- a/luks/keymanage.c +++ b/luks/keymanage.c @@ -50,6 +50,7 @@ static inline int round_up_modulo(int x, int m) { struct luks_masterkey *LUKS_alloc_masterkey(int keylength) { struct luks_masterkey *mk=malloc(sizeof(*mk) + keylength); + if(NULL == mk) return NULL; mk->keyLength=keylength; return mk; } @@ -66,7 +67,13 @@ void LUKS_dealloc_masterkey(struct luks_masterkey *mk) struct luks_masterkey *LUKS_generate_masterkey(int keylength) { struct luks_masterkey *mk=LUKS_alloc_masterkey(keylength); - getRandom(mk->key,keylength); + if(NULL == mk) return NULL; + + int r = getRandom(mk->key,keylength); + if(r < 0) { + LUKS_dealloc_masterkey(mk); + return NULL; + } return mk; } diff --git a/luks/random.c b/luks/random.c index a4c71322..711a7b5a 100644 --- a/luks/random.c +++ b/luks/random.c @@ -23,8 +23,6 @@ int openRandom() { closeRandom */ int getRandom(char *buf, size_t len) { - int r = 0; - if(openRandom() == -1) { perror("getRandom:"); return -EINVAL; @@ -37,7 +35,7 @@ int getRandom(char *buf, size_t len) } len-= r; buf += r; } - return r; + return 0; } void closeRandom() {