From 550040474fd80e29b568c4b76b3ed89e1acef66b Mon Sep 17 00:00:00 2001 From: Joe Evans Date: Fri, 1 Nov 2013 14:11:48 -0700 Subject: [PATCH 1/2] Cast content_length to signed int for error-check comparison, preventing segfault when attempting to read buffer. --- src/zm_remote_camera_http.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_remote_camera_http.cpp b/src/zm_remote_camera_http.cpp index 59c6f53e0..c83db6401 100644 --- a/src/zm_remote_camera_http.cpp +++ b/src/zm_remote_camera_http.cpp @@ -1092,7 +1092,7 @@ int RemoteCameraHttp::Capture( Image &image ) Warning( "Unable to capture image, retrying" ); return( 1 ); } - if ( content_length < 0 ) + if ( (int)content_length < 0 ) { Error( "Unable to get response" ); Disconnect(); From 4e1d23669f1a2c1e98bd32363d2c28a1f703b2fd Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Mon, 4 Nov 2013 10:54:39 +0200 Subject: [PATCH 2/2] Revert content_length to be int --- src/zm_remote_camera_http.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/zm_remote_camera_http.cpp b/src/zm_remote_camera_http.cpp index c83db6401..80cdca430 100644 --- a/src/zm_remote_camera_http.cpp +++ b/src/zm_remote_camera_http.cpp @@ -1086,13 +1086,13 @@ int RemoteCameraHttp::PreCapture() int RemoteCameraHttp::Capture( Image &image ) { - unsigned int content_length = GetResponse(); + int content_length = GetResponse(); if ( content_length == 0 ) { Warning( "Unable to capture image, retrying" ); return( 1 ); } - if ( (int)content_length < 0 ) + if ( content_length < 0 ) { Error( "Unable to get response" ); Disconnect(); @@ -1112,7 +1112,7 @@ int RemoteCameraHttp::Capture( Image &image ) } case X_RGB : { - if ( content_length != image.Size() ) + if ( (unsigned int)content_length != image.Size() ) { Error( "Image length mismatch, expected %d bytes, content length was %d", image.Size(), content_length ); Disconnect();