From 85aa81613dc213acd51c96e00b53d1d855aebc84 Mon Sep 17 00:00:00 2001 From: Celine Buret Date: Wed, 1 Sep 2010 16:45:23 +0200 Subject: cleo/u-boot/net: copy current_version and wanted_version in appropriate cases, closes #1668 --- cleopatre/u-boot-1.1.6/net/spidupd.c | 108 +++++++++++++++++------------------ 1 file changed, 53 insertions(+), 55 deletions(-) diff --git a/cleopatre/u-boot-1.1.6/net/spidupd.c b/cleopatre/u-boot-1.1.6/net/spidupd.c index 9bd2fd9fd2..ef0c2cc72a 100644 --- a/cleopatre/u-boot-1.1.6/net/spidupd.c +++ b/cleopatre/u-boot-1.1.6/net/spidupd.c @@ -353,7 +353,7 @@ static int select_image(int img_nb, ulong img_0_addr, ulong img_max_size, struct sel_img_ok = i; } /* Store max index */ - if (desc->index > max_index) + if (desc->index >= max_index) { max_index = desc->index; /* Store the version */ @@ -762,62 +762,60 @@ static void SpidupdHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len ctx.state = STATE_UPD_TRANSFER; /* shape the response to client */ - if(place->correct_img_exist) + if(vs_update_start_req->proto_version > SPIDUPD_PROTOCOL_VERSION) { - if(vs_update_start_req->proto_version > SPIDUPD_PROTOCOL_VERSION) - { - /* Request with a newer SPiDUpdate protocol */ - printf("Error (New SPidUpdate protocol %d, can't understand).\n", - vs_update_start_req->proto_version); - ctx.modem_busy = 0; - ctx.start_cnf.start_update = SPIDUPD_BAD_PROTOCOL; - ctx.state = STATE_UPD_START; - - /* Abort the update */ - NetState = NETLOOP_FAIL; - break; - } - if(place->correct_archi != vs_update_start_req->arch) - { - /* Request bad architecture */ - printf("Error (New image bad Architecture).\n"); - ctx.modem_busy = 0; - ctx.start_cnf.start_update = SPIDUPD_BAD_ARCH; - ctx.state = STATE_UPD_START; - - /* Abort the update */ - NetState = NETLOOP_FAIL; - break; - } - if(place->correct_type != vs_update_start_req->upd_type) - { - /* Request doesn't concern a sImage */ - printf("Error (New image bad type).\n" ); - ctx.modem_busy = 0; - ctx.start_cnf.start_update = SPIDUPD_BAD_UPD_TYPE; - ctx.state = STATE_UPD_START; - - /* Abort the update */ - NetState = NETLOOP_FAIL; - break; - } - - if((vs_update_start_req->version[0] == '\0') || - (memcmp(place->current_version, vs_update_start_req->version, SPIDUPD_STRING_VERSION_SIZE) == 0)) - { - printf("Error (Bad Version).\n" ); - ctx.modem_busy = 0; - ctx.start_cnf.start_update = SPIDUPD_BAD_VERSION; - ctx.state = STATE_UPD_START; - - /* Abort the update */ - NetState = NETLOOP_FAIL; - break; - } - - /* Save wanted version */ - memcpy(ctx.wanted_version, vs_update_start_req->version, SPIDUPD_STRING_VERSION_SIZE); + /* Request with a newer SPiDUpdate protocol */ + printf("Error (New SPidUpdate protocol %d, can't understand).\n", + vs_update_start_req->proto_version); + ctx.modem_busy = 0; + ctx.start_cnf.start_update = SPIDUPD_BAD_PROTOCOL; + ctx.state = STATE_UPD_START; + + /* Abort the update */ + NetState = NETLOOP_FAIL; + break; + } + if(SPIDCOM_IMG_DESC_SPC300 != vs_update_start_req->arch) + { + /* Request bad architecture */ + printf("Error (New image bad Architecture).\n"); + ctx.modem_busy = 0; + ctx.start_cnf.start_update = SPIDUPD_BAD_ARCH; + ctx.state = STATE_UPD_START; + + /* Abort the update */ + NetState = NETLOOP_FAIL; + break; + } + if(SPIDCOM_IMG_DESC_NORMAL_TYPE != vs_update_start_req->upd_type) + { + /* Request doesn't concern a sImage */ + printf("Error (New image bad type).\n" ); + ctx.modem_busy = 0; + ctx.start_cnf.start_update = SPIDUPD_BAD_UPD_TYPE; + ctx.state = STATE_UPD_START; + + /* Abort the update */ + NetState = NETLOOP_FAIL; + break; + } + + if(place->correct_img_exist + && ((vs_update_start_req->version[0] == '\0') + || (memcmp(place->current_version, vs_update_start_req->version, SPIDUPD_STRING_VERSION_SIZE) == 0))) + { + printf("Error (Bad Version).\n" ); + ctx.modem_busy = 0; + ctx.start_cnf.start_update = SPIDUPD_BAD_VERSION; + ctx.state = STATE_UPD_START; + + /* Abort the update */ + NetState = NETLOOP_FAIL; + break; } + + /* Save wanted version */ + memcpy(ctx.wanted_version, vs_update_start_req->version, SPIDUPD_STRING_VERSION_SIZE); } else { -- cgit v1.2.3