1 --- libldm-0.2.3/src/Makefile.am.orig 2012-09-20 12:31:03.000000000 +0200
2 +++ libldm-0.2.3/src/Makefile.am 2013-01-07 19:20:40.782494058 +0100
4 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6 AM_CFLAGS = -Wall -Werror -Wshadow -Wextra \
7 - -Wno-unused-local-typedefs \
8 + -Wno-missing-field-initializers \
11 libname = libldm-1.0.la
12 --- libldm-0.2.3/src/mbr.c.orig 2012-07-23 17:47:49.000000000 +0200
13 +++ libldm-0.2.3/src/mbr.c 2013-01-07 19:20:16.992494554 +0100
19 - while (read < sizeof(_mbr)) {
20 - ssize_t in = pread(fd, &_mbr + read, sizeof(struct _mbr) - read, read);
22 + while (nread < sizeof(_mbr)) {
23 + ssize_t in = pread(fd, &_mbr + nread, sizeof(struct _mbr) - nread, nread);
24 if (in == 0) return -MBR_ERROR_INVALID;
25 if (in == -1) return -MBR_ERROR_READ;
31 if (_mbr.magic[0] != 0x55 || _mbr.magic[1] != 0xAA)
32 --- libldm-0.2.3/src/gpt.c.orig 2012-09-20 12:31:03.000000000 +0200
33 +++ libldm-0.2.3/src/gpt.c 2013-01-07 19:29:04.812483553 +0100
35 const off_t gpt_start = secsize;
37 struct _gpt_head head;
39 - while (read < sizeof(head)) {
40 - ssize_t in = pread(fd, &head + read, sizeof(head) - read,
43 + while (nread < sizeof(head)) {
44 + ssize_t in = pread(fd, &head + nread, sizeof(head) - nread,
46 if (in == 0) return -GPT_ERROR_INVALID;
47 if (in == -1) return -GPT_ERROR_READ;
53 if (memcmp(head.magic, "EFI PART", 8) != 0) return -GPT_ERROR_INVALID;
56 struct _gpt *_gpt = (*h)->gpt;
57 memcpy(_gpt, &head, sizeof(head));
58 - while (read < le32toh(head.size)) {
59 - ssize_t in = pread(fd, (char *)(_gpt) + read, le32toh(head.size) - read,
61 + while (nread < le32toh(head.size)) {
62 + ssize_t in = pread(fd, (char *)(_gpt) + nread, le32toh(head.size) - nread,
65 err = -GPT_ERROR_INVALID;
75 uint32_t header_crc = _gpt->header_crc;
77 if ((*h)->pte_array == NULL) abort();
79 const off_t pte_array_start = _gpt->pte_array_start_lba * secsize;
81 - while (read < pte_array_size) {
82 - ssize_t in = pread(fd, (*h)->pte_array + read, pte_array_size - read,
83 - read + pte_array_start);
85 + while (nread < pte_array_size) {
86 + ssize_t in = pread(fd, (*h)->pte_array + nread, pte_array_size - nread,
87 + nread + pte_array_start);
89 err = -GPT_ERROR_INVALID;
99 crc = crc32(0L, Z_NULL, 0);
100 --- libldm-0.2.3/src/ldm.c.orig 2012-09-21 12:21:17.000000000 +0200
101 +++ libldm-0.2.3/src/ldm.c 2013-01-07 19:31:35.259147085 +0100
102 @@ -1170,15 +1170,15 @@
103 void ** const config, GError ** const err)
105 /* Sanity check ldm_config_start and ldm_config_size */
107 - if (fstat(fd, &stat) == -1) {
109 + if (fstat(fd, &sstat) == -1) {
110 g_set_error(err, LDM_ERROR, LDM_ERROR_IO,
111 "Unable to stat %s: %m", path);
115 - uint64_t size = stat.st_size;
116 - if (S_ISBLK(stat.st_mode)) {
117 + uint64_t size = sstat.st_size;
118 + if (S_ISBLK(sstat.st_mode)) {
119 if (ioctl(fd, BLKGETSIZE64, &size) == -1) {
120 g_set_error(err, LDM_ERROR, LDM_ERROR_IO,
121 "Unable to get block device size for %s: %m", path);
122 @@ -1205,10 +1205,10 @@
125 *config = g_malloc(config_size);
127 - while (read < config_size) {
128 - ssize_t in = pread(fd, *config + read, config_size - read,
129 - config_start + read);
131 + while (nread < config_size) {
132 + ssize_t in = pread(fd, *config + nread, config_size - nread,
133 + config_start + nread);
135 g_set_error(err, LDM_ERROR, LDM_ERROR_INVALID,
136 "%s contains invalid LDM metadata", path);
137 @@ -1221,7 +1221,7 @@
146 @@ -1236,11 +1236,11 @@
147 const uint64_t ph_start,
148 struct _privhead * const privhead, GError **err)
151 - while (read < sizeof(*privhead)) {
152 - ssize_t in = pread(fd, (char *) privhead + read,
153 - sizeof(*privhead) - read,
156 + while (nread < sizeof(*privhead)) {
157 + ssize_t in = pread(fd, (char *) privhead + nread,
158 + sizeof(*privhead) - nread,
161 g_set_error(err, LDM_ERROR, LDM_ERROR_INVALID,
162 "%s contains invalid LDM metadata", path);
163 @@ -1253,7 +1253,7 @@
171 if (memcmp(privhead->magic, "PRIVHEAD", 8) != 0) {