hal/volume_id util.c, 1.6, 1.7 volume_id.c, 1.10, 1.11 volume_id.h, 1.9, 1.10

Kay Sievers kay at freedesktop.org
Tue Aug 23 14:14:15 PDT 2005


Update of /cvs/hal/hal/volume_id
In directory gabe:/tmp/cvs-serv1411/volume_id

Modified Files:
	util.c volume_id.c volume_id.h 
Log Message:
2005-08-23  Kay Sievers  <kay.sievers at vrfy.org>

        Fix sloppy error handling in volume_id.

        * volume_id/util.c: (volume_id_get_buffer):
        * volume_id/volume_id.c: (volume_id_probe_all):
        * volume_id/volume_id.h:


Index: util.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/util.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- util.c	12 Aug 2005 22:28:30 -0000	1.6
+++ util.c	23 Aug 2005 21:14:13 -0000	1.7
@@ -204,19 +204,30 @@
 	if (off + len <= SB_BUFFER_SIZE) {
 		if (id->sbbuf == NULL) {
 			id->sbbuf = malloc(SB_BUFFER_SIZE);
-			if (id->sbbuf == NULL)
+			if (id->sbbuf == NULL) {
+				dbg("error malloc");
 				return NULL;
+			}
 		}
 
 		/* check if we need to read */
 		if ((off + len) > id->sbbuf_len) {
 			dbg("read sbbuf len:0x%llx", (unsigned long long) (off + len));
-			lseek(id->fd, 0, SEEK_SET);
+			if (lseek(id->fd, 0, SEEK_SET) < 0) {
+				dbg("lseek failed (%s)", strerror(errno));
+				return NULL;
+			}
 			buf_len = read(id->fd, id->sbbuf, off + len);
+			if (buf_len < 0) {
+				dbg("read failed (%s)", strerror(errno));
+				return NULL;
+			}
 			dbg("got 0x%zx (%zi) bytes", buf_len, buf_len);
 			id->sbbuf_len = buf_len;
-			if (buf_len < off + len)
+			if (buf_len < off + len) {
+				dbg("requested 0x%zx bytes, got only 0x%zx bytes", len, buf_len);
 				return NULL;
+			}
 		}
 
 		return &(id->sbbuf[off]);
@@ -229,16 +240,24 @@
 		/* get seek buffer */
 		if (id->seekbuf == NULL) {
 			id->seekbuf = malloc(SEEK_BUFFER_SIZE);
-			if (id->seekbuf == NULL)
+			if (id->seekbuf == NULL) {
+				dbg("error malloc");
 				return NULL;
+			}
 		}
 
 		/* check if we need to read */
 		if ((off < id->seekbuf_off) || ((off + len) > (id->seekbuf_off + id->seekbuf_len))) {
 			dbg("read seekbuf off:0x%llx len:0x%zx", (unsigned long long) off, len);
-			if (lseek(id->fd, off, SEEK_SET) == -1)
+			if (lseek(id->fd, off, SEEK_SET) < 0) {
+				dbg("lseek failed (%s)", strerror(errno));
 				return NULL;
+			}
 			buf_len = read(id->fd, id->seekbuf, len);
+			if (buf_len < 0) {
+				dbg("read failed (%s)", strerror(errno));
+				return NULL;
+			}
 			dbg("got 0x%zx (%zi) bytes", buf_len, buf_len);
 			id->seekbuf_off = off;
 			id->seekbuf_len = buf_len;

Index: volume_id.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/volume_id.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- volume_id.c	12 Aug 2005 22:28:30 -0000	1.10
+++ volume_id.c	23 Aug 2005 21:14:13 -0000	1.11
@@ -118,9 +118,6 @@
 	if (volume_id_probe_vfat(id, off) == 0)
 		goto exit;
 
-	if (volume_id_probe_mac_partition_map(id, off) == 0)
-		goto exit;
-
 	if (volume_id_probe_xfs(id, off) == 0)
 		goto exit;
 

Index: volume_id.h
===================================================================
RCS file: /cvs/hal/hal/volume_id/volume_id.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- volume_id.h	12 Aug 2005 22:28:30 -0000	1.9
+++ volume_id.h	23 Aug 2005 21:14:13 -0000	1.10
@@ -23,7 +23,7 @@
 
 #include <stdint.h>
 
-#define VOLUME_ID_VERSION		47
+#define VOLUME_ID_VERSION		48
 
 #define VOLUME_ID_LABEL_SIZE		64
 #define VOLUME_ID_UUID_SIZE		36




More information about the hal-commit mailing list