~ubuntu-branches/ubuntu/karmic/cryptsetup/karmic-proposed

« back to all changes in this revision

Viewing changes to lib/utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2009-05-10 17:29:32 UTC
  • mfrom: (0.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090510172932-1e485f99qk3psrg0
Tags: 2:1.0.6+20090405.svn49-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Ubuntu specific:
    + debian/rules: link dynamically for better security supportability and
      smaller packages.
    + debian/control: Depend on initramfs-tools so system is not potentially
      rendered unbootable.
  - debian/initramfs/cryptroot-script wait for encrypted device to appear,
    report with log_*_msg (debian bug 488271).
  - debian/initramfs/cryptroot-hook: fix support for UUID and LABEL
    correlation between fstab and crypttab (debian bug 522041).
  - debian/askpass.c, debian/initramfs/cryptroot-script: using newline
    escape in passphrase prompt to avoid line-wrapping (debian bug 528133).
* Drop 04_fix_udevsettle_call.patch: fixed upstream differently.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
            error=NULL;
33
33
        }
34
34
 
35
 
        vasprintf(&error, fmt, va);
 
35
        if(!fmt) return;
 
36
 
 
37
        vasprintf(&error, fmt, va);
36
38
}
37
39
 
38
40
void set_error(const char *fmt, ...)
230
232
        char frontPadBuf[bsize];
231
233
        int frontHang = offset % bsize;
232
234
        int r;
 
235
        int innerCount = count < bsize ? count : bsize;
233
236
 
234
237
        if (bsize < 0)
235
238
                return bsize;
236
239
 
237
240
        lseek(fd, offset - frontHang, SEEK_SET);
238
241
        if(offset % bsize) {
239
 
                int innerCount = count<bsize?count:bsize;
240
 
 
241
242
                r = read(fd,frontPadBuf,bsize);
242
243
                if(r < 0) return -1;
243
244
 
244
245
                memcpy(frontPadBuf+frontHang, buf, innerCount);
245
246
 
 
247
                lseek(fd, offset - frontHang, SEEK_SET);
246
248
                r = write(fd,frontPadBuf,bsize);
247
249
                if(r < 0) return -1;
248
250
 
251
253
        }
252
254
        if(count <= 0) return buf - orig_buf;
253
255
 
254
 
        return write_blockwise(fd, buf, count);
 
256
        return write_blockwise(fd, buf, count) + innerCount;
255
257
}
256
258
 
257
259
/* Password reading helpers */
345
347
 * reading can be retried as for interactive terminals).
346
348
 */
347
349
 
348
 
int get_key(char *prompt, char **key, int *passLen, int key_size, const char *key_file, int passphrase_fd, int timeout, int how2verify)
 
350
int get_key(char *prompt, char **key, unsigned int *passLen, int key_size,
 
351
            const char *key_file, int passphrase_fd, int timeout, int how2verify)
349
352
{
350
353
        int fd;
351
354
        const int verify = how2verify & CRYPT_FLAG_VERIFY;