[CRIU] [PATCH 3/3] sk: handle erorors of lseek

Andrey Vagin avagin at openvz.org
Thu Apr 7 10:29:44 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

CID 159475 (#1 of 1): Unchecked return value from library (CHECKED_RETURN)
1. check_return: Calling lseek(img_raw_fd(img), pkt->entry->length, 1)
   without checking return value. This library function may fail and return an error code.

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 criu/sk-queue.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/criu/sk-queue.c b/criu/sk-queue.c
index c278e0a..50854d7 100644
--- a/criu/sk-queue.c
+++ b/criu/sk-queue.c
@@ -44,7 +44,10 @@ static int collect_one_packet(void *obj, ProtobufCMessage *msg, struct cr_img *i
 	 * will be broken.
 	 */
 	list_add_tail(&pkt->list, &packets_list);
-	lseek(img_raw_fd(img), pkt->entry->length, SEEK_CUR);
+	if (lseek(img_raw_fd(img), pkt->entry->length, SEEK_CUR) < 0) {
+		pr_perror("Unable to change an image offset");
+		return -1;
+	}
 
 	return 0;
 }
-- 
2.5.0



More information about the CRIU mailing list