Changeset 3539

Show
Ignore:
Timestamp:
08/16/08 13:13:34 (4 months ago)
Author:
dgollub
Message:

1. osync_queue_connect can fail. It should be checked in the callback

connect.

2. Since digits is passed to sscanf, it might be uninitialized before

it is used. Initialize it and then check sscanf for errors.

3. Same thing with sscanf as above. But this time we error out if we

don't have a good month value.

Signed-off-by: Erik Hovland <erik@…>
Tested-by: Daniel Gollub <dgollub@…>

Location:
trunk/opensync
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/opensync/client/opensync_client.c

    r3538 r3539  
    14191419         
    14201420        /* We now connect to our incoming queue */ 
    1421         osync_queue_connect(client->incoming, OSYNC_QUEUE_RECEIVER, NULL); 
     1421        if (!osync_queue_connect(client->incoming, OSYNC_QUEUE_RECEIVER, NULL)) 
     1422                return TRUE; 
    14221423         
    14231424        return FALSE; 
  • trunk/opensync/engine/opensync_mapping_engine.c

    r3538 r3539  
    760760         
    761761        if (osync_engine_check_get_changes(objengine->parent) && osync_bitcount(objengine->sink_errors | objengine->sink_get_changes) == g_list_length(objengine->sink_engines)) { 
    762                 osync_obj_engine_command(objengine, OSYNC_ENGINE_COMMAND_WRITE, error); 
     762                if (!osync_obj_engine_command(objengine, OSYNC_ENGINE_COMMAND_WRITE, error)) 
     763                        goto error; 
    763764        } else 
    764765                osync_trace(TRACE_INTERNAL, "Not triggering write. didnt receive all reads yet"); 
  • trunk/opensync/format/opensync_time.c

    r3173 r3539  
    953953        osync_trace(TRACE_ENTRY, "%s(%s)", __func__, alarm); 
    954954 
    955         int i, secs, digits; 
     955        int i, secs, digits = 0; 
    956956        int is_digit = 0; 
    957957        int sign = 1;   // when ical stamp doesn't start with '-' => seconds after event 
     
    10001000                                        break; 
    10011001 
    1002                                 sscanf((char*)(alarm+i),"%d",&digits); 
     1002                                if (sscanf((char*)(alarm+i),"%d",&digits) == EOF) 
     1003                                        return -1; 
     1004 
    10031005                                is_digit = 1; 
    10041006                                break; 
     
    11421144struct tm *osync_time_dstchange(xmlNode *dstNode) 
    11431145{ 
    1144         int month; 
     1146        int month = -1; 
    11451147        struct tm *dst_change = NULL, *tm_started = NULL; 
    11461148        char *started = NULL, *rule = NULL, *byday = NULL; 
     
    11601162                if (strstr(rule, "BYDAY=")) 
    11611163                        byday = g_strdup(rule + 6); 
    1162                 else if (strstr(rule, "BYMONTH=")) 
    1163                         sscanf(rule, "BYMONTH=%d", &month); 
     1164                else if (strstr(rule, "BYMONTH=")) { 
     1165                        if (sscanf(rule, "BYMONTH=%d", &month) == EOF) 
     1166                                return NULL; 
     1167                } 
    11641168                 
    11651169                xmlFree(rule); 
     
    11671171                current = current->next; 
    11681172        } 
     1173 
     1174        if (month == -1) 
     1175                return NULL; 
    11691176 
    11701177        dst_change = osync_time_relative2tm(byday, month, tm_started->tm_year + 1900);