--- ../util-linux-ng-2.13-orig/mount/lomount.c 2007-08-27 22:00:34 +0900 +++ mount/lomount.c 2007-12-23 23:52:35 +0900 @@ -336,8 +336,13 @@ pass = xgetpass(pfd, _("Password: ")); gotpass: memset(loopinfo64.lo_encrypt_key, 0, LO_KEY_SIZE); - xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE); - memset(pass, 0, strlen(pass)); + /* We can't use xstrncpy: it would cut off the last byte of + * an LO_KEY_SIZE key */ + i = strlen(pass); + if (i > LO_KEY_SIZE) + i = LO_KEY_SIZE; + memcpy(loopinfo64.lo_encrypt_key, pass, i); + memset(pass, 0, i); loopinfo64.lo_encrypt_key_size = LO_KEY_SIZE; }