Patrick Rudolph (siro(a)das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14511
-gerrit
commit df9588057effcaa676dc2e803eceaa6f3ee6c964
Author: Patrick Rudolph <siro(a)das-labor.org>
Date: Mon Apr 25 12:25:30 2016 +0200
qemu-0.15.x/serialice-com: Error on memory allocation failure
Exit on memory allocation error.
Change-Id: Ia72b12e974f84d157fcb64fd5c223d848b31521a
Signed-off-by: Patrick Rudolph <siro(a)das-labor.org>
---
qemu-0.15.x/serialice-com.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/qemu-0.15.x/serialice-com.c b/qemu-0.15.x/serialice-com.c
index 2e59094..9211b6f 100644
--- a/qemu-0.15.x/serialice-com.c
+++ b/qemu-0.15.x/serialice-com.c
@@ -209,6 +209,10 @@ const SerialICE_target *serialice_serial_init(void)
{
s = mallocz(sizeof(SerialICEState));
+ if (!s) {
+ printf("Out of memory.\n");
+ exit(1);
+ }
if (serialice_device == NULL) {
printf("You need to specify a serial device to use SerialICE.\n");
exit(1);
@@ -278,7 +282,10 @@ const SerialICE_target *serialice_serial_init(void)
s->buffer = mallocz(BUFFER_SIZE);
s->command = mallocz(BUFFER_SIZE);
-
+ if (!s->buffer || !s->command) {
+ printf("Out of memory.\n");
+ exit(1);
+ }
printf("SerialICE: Waiting for handshake with target... ");
handshake_mode = 1; // Readback errors are to be expected in this phase.
Patrick Rudolph (siro(a)das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14510
-gerrit
commit 7618a741867826c664c46fb1d1405b54bf5184c5
Author: Patrick Rudolph <siro(a)das-labor.org>
Date: Mon Apr 25 12:24:03 2016 +0200
qemu-0.15.x/serialice-com: Fix parsing of version string
Check buffer contents after writing to it.
Fixes version string wasn't parsed at all, as it starts
with \r\n.
Change-Id: Ia012434b3806f936971c8f9e99ed198f85171111
Signed-off-by: Patrick Rudolph <siro(a)das-labor.org>
---
qemu-0.15.x/serialice-com.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/qemu-0.15.x/serialice-com.c b/qemu-0.15.x/serialice-com.c
index 1373f57..2e59094 100644
--- a/qemu-0.15.x/serialice-com.c
+++ b/qemu-0.15.x/serialice-com.c
@@ -360,9 +360,9 @@ static void msg_version(void)
memset(s->buffer, 0, BUFFER_SIZE);
serialice_read(s, s->buffer, 1);
serialice_read(s, s->buffer, 1);
- while (s->buffer[len++] != '\n') {
+ do {
serialice_read(s, s->buffer + len, 1);
- }
+ } while (s->buffer[len++] != '\n');
s->buffer[len - 1] = '\0';
printf("%s\n", s->buffer);
Patrick Rudolph (siro(a)das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14511
-gerrit
commit 1a14a31123ce6a2e76cd803fc7a5bc3e12370431
Author: Patrick Rudolph <siro(a)das-labor.org>
Date: Mon Apr 25 12:25:30 2016 +0200
qemu-0.15.x/serialice-com: Error on memory allocation failure
Exit on memory allocation error.
Change-Id: Ia72b12e974f84d157fcb64fd5c223d848b31521a
Signed-off-by: Patrick Rudolph <siro(a)das-labor.org>
---
qemu-0.15.x/serialice-com.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/qemu-0.15.x/serialice-com.c b/qemu-0.15.x/serialice-com.c
index cb3794c..25ccaf5 100644
--- a/qemu-0.15.x/serialice-com.c
+++ b/qemu-0.15.x/serialice-com.c
@@ -195,6 +195,10 @@ const SerialICE_target *serialice_serial_init(void)
{
s = mallocz(sizeof(SerialICEState));
+ if (!s) {
+ printf("Out of memory.\n");
+ exit(1);
+ }
if (serialice_device == NULL) {
printf("You need to specify a serial device to use SerialICE.\n");
exit(1);
@@ -264,7 +268,10 @@ const SerialICE_target *serialice_serial_init(void)
s->buffer = mallocz(BUFFER_SIZE);
s->command = mallocz(BUFFER_SIZE);
-
+ if (!s->buffer || !s->command) {
+ printf("Out of memory.\n");
+ exit(1);
+ }
printf("SerialICE: Waiting for handshake with target... ");
handshake_mode = 1; // Readback errors are to be expected in this phase.
Patrick Rudolph (siro(a)das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14510
-gerrit
commit 9f9e54237af11e1f96c9737200f1627508fbf170
Author: Patrick Rudolph <siro(a)das-labor.org>
Date: Mon Apr 25 12:24:03 2016 +0200
qemu-0.15.x/serialice-com: Fix parsing of version string
Check buffer contents after writing to it.
Fixes version string wasn't parsed at all, as it starts
with \r\n.
Change-Id: Ia012434b3806f936971c8f9e99ed198f85171111
Signed-off-by: Patrick Rudolph <siro(a)das-labor.org>
---
qemu-0.15.x/serialice-com.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/qemu-0.15.x/serialice-com.c b/qemu-0.15.x/serialice-com.c
index 54f293b..cb3794c 100644
--- a/qemu-0.15.x/serialice-com.c
+++ b/qemu-0.15.x/serialice-com.c
@@ -346,9 +346,9 @@ static void msg_version(void)
memset(s->buffer, 0, BUFFER_SIZE);
serialice_read(s, s->buffer, 1);
serialice_read(s, s->buffer, 1);
- while (s->buffer[len++] != '\n') {
+ do {
serialice_read(s, s->buffer + len, 1);
- }
+ } while (s->buffer[len++] != '\n');
s->buffer[len - 1] = '\0';
printf("%s\n", s->buffer);