[patch] opensync opie plugin patches

Erik Hovland <[email protected]> Wed, 13 Aug 2008 16:27:47 -0700
Newsgroups gmane.comp.handhelds.opie.devel
Message-ID <[email protected]>
--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I finally got around to running my static analysis tool on the opie
plugin of opensync. It found some interesting defects.

Let me know if there is anything I can do to improve these patches.

Thanks

E

-- 
Erik Hovland
mail: [email protected]
web: http://hovland.org/
PGP/GPG public key available on request

--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=opie-sync-deadcode

start_time and end_time are never set. This makes the code
a little farther down dead (never possible to execute).

I assume that start and end come from the DateStarted and
DateEnd fields, so I assign them there.

---

 opie-sync/CMakeLists.txt    |    1 +
 opie-sync/src/opie_format.c |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/opie-sync/CMakeLists.txt b/opie-sync/CMakeLists.txt
index c8a1249..3b8dfd1 100644
--- a/opie-sync/CMakeLists.txt
+++ b/opie-sync/CMakeLists.txt
@@ -1,3 +1,4 @@
+cmake_minimum_required(VERSION 2.6)
 PROJECT( libopensync-plugin-opie C )
 
 SET( VERSION "0.36" )
diff --git a/opie-sync/src/opie_format.c b/opie-sync/src/opie_format.c
index dd1548b..cf4ca77 100644
--- a/opie-sync/src/opie_format.c
+++ b/opie-sync/src/opie_format.c
@@ -1100,10 +1100,10 @@ static osync_bool conv_xml_event_to_opie_xml_event(char *input, unsigned int inp
 			xmlfield_vtime_to_attr_time_t(in_xmlfield, on_event, "created");
 		}
 		else if(!strcmp("DateStarted", fieldname)) {
-			xmlfield_vtime_to_attr_time_t(in_xmlfield, on_event, "start");
+			start_time = xmlfield_vtime_to_attr_time_t(in_xmlfield, on_event, "start");
 		}
 		else if(!strcmp("DateEnd", fieldname)) {
-			xmlfield_vtime_to_attr_time_t(in_xmlfield, on_event, "end");
+			start_time = xmlfield_vtime_to_attr_time_t(in_xmlfield, on_event, "end");
 		}
 		else if(!strcmp("Categories", fieldname)) {
 			xmlfield_categories_to_attr(in_xmlfield, on_event, "Categories");

--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=header-analysis

The removed headers provide no useful symbols to the code
that includes them.
---

 opie-sync/src/opie_comms.c  |    1 -
 opie-sync/src/opie_format.c |    1 -
 opie-sync/src/opie_xml.c    |    1 -
 3 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/opie-sync/src/opie_comms.c b/opie-sync/src/opie_comms.c
index edc8b3e..29e3a4e 100644
--- a/opie-sync/src/opie_comms.c
+++ b/opie-sync/src/opie_comms.c
@@ -35,7 +35,6 @@
 #include <glib/gstdio.h>
 
 #include <curl/curl.h>
-#include <curl/types.h>
 #include <curl/easy.h>
 
 #include <opensync/opensync.h>
diff --git a/opie-sync/src/opie_format.c b/opie-sync/src/opie_format.c
index cf4ca77..15fe86c 100644
--- a/opie-sync/src/opie_format.c
+++ b/opie-sync/src/opie_format.c
@@ -29,7 +29,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <opensync/opensync.h>
 #include <opensync/opensync-time.h>
 #include <opensync/opensync-format.h>
-#include <opensync/opensync-data.h>
 #include <opensync/opensync-merger.h>
 
 enum OpieTodoState {
diff --git a/opie-sync/src/opie_xml.c b/opie-sync/src/opie_xml.c
index fe024b5..3ab7d01 100644
--- a/opie-sync/src/opie_xml.c
+++ b/opie-sync/src/opie_xml.c
@@ -27,7 +27,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "opie_xml.h"
 #include "opie_sync.h"
-#include "opie_comms.h"
 #include "md5.h"
 
 #include <string.h>

--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=wrap-mkstemp

mkstemp is the best temp file call. But we need to wrap the
call with umask to make sure it is extra secure.
---

 opie-sync/src/opie_comms.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/opie-sync/src/opie_comms.c b/opie-sync/src/opie_comms.c
index 29e3a4e..e80185a 100644
--- a/opie-sync/src/opie_comms.c
+++ b/opie-sync/src/opie_comms.c
@@ -93,7 +93,9 @@ TempFile *create_temp_file(void) {
 	
 	TempFile *tmpfile = g_malloc(sizeof(TempFile));
 	char *template = g_strdup("/tmp/opie-sync.XXXXXX");
+        mode_t current_mode = umask(S_IRWXG | S_IRWXO);
 	tmpfile->fd = mkstemp(template);
+	umask(current_mode);
 	if(tmpfile->fd == -1) {
 		osync_trace( TRACE_EXIT_ERROR, "failed to create temporary file" );
 		g_free(template);

--J/dobhs11T7y2rNN
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________

http://opie.handhelds.org/cgi-bin/moin.cgi/DeveloperWikiIndex

Opie-devel mailing list
[email protected]
https://handhelds.org/mailman/listinfo/opie-devel

--J/dobhs11T7y2rNN--