1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-01 09:24:05 +02:00

fw/image.c (image_first): call image_more to process the payload

This makes things work also for zero-sized files. I.e.,

./antorcha /dev/null

does precisely what one would expect. (Before, the transfer was
accepted, but the first salt block became the new image.)
This commit is contained in:
Werner Almesberger 2012-06-20 18:39:29 -03:00
parent 2011c515c8
commit 2bac5e74a7

View File

@ -61,24 +61,6 @@ static void add_payload(const uint8_t *payload)
} }
static bool image_first(uint8_t limit, const uint8_t *payload)
{
hash_init();
hash_merge(image_secret, sizeof(image_secret));
if (image == images[0])
p = images[1];
else
p = images[0];
next_image = p;
end = p+MAX_LINES;
memset(p, 0, (char *) end-(char *) p);
add_payload(payload);
hash_merge(payload, PAYLOAD);
failed = 0;
return 1;
}
static bool image_more(uint8_t seq, uint8_t limit, const uint8_t *payload) static bool image_more(uint8_t seq, uint8_t limit, const uint8_t *payload)
{ {
switch (limit-seq) { switch (limit-seq) {
@ -105,6 +87,22 @@ static bool image_more(uint8_t seq, uint8_t limit, const uint8_t *payload)
} }
static bool image_first(uint8_t limit, const uint8_t *payload)
{
hash_init();
hash_merge(image_secret, sizeof(image_secret));
if (image == images[0])
p = images[1];
else
p = images[0];
next_image = p;
end = p+MAX_LINES;
memset(p, 0, (char *) end-(char *) p);
failed = 0;
return image_more(0, limit, payload);;
}
struct handler image_handler = { struct handler image_handler = {
.type = IMAGE, .type = IMAGE,
.first = image_first, .first = image_first,