summaryrefslogtreecommitdiff
path: root/src/device/oprom/x86emu
diff options
context:
space:
mode:
authorVladimir Serbinenko <phcoder@gmail.com>2013-11-26 02:41:26 +0100
committerVladimir Serbinenko <phcoder@gmail.com>2014-01-10 18:08:16 +0100
commita37383db8081b66eafc3860ede23edbfd39ac8ad (patch)
tree3f793f4b2342aa440efe3fa649244ec064ced5d8 /src/device/oprom/x86emu
parent4b5012a4a2bf804d395ae3a72c76f50c4a9189db (diff)
Replace all occurences of sprintf with snprintf
THis reduces risks of bufer overflows. Change-Id: I77f80e76efec16ac0a0af83d76430a8126a7602d Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com> Reviewed-on: http://review.coreboot.org/4279 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src/device/oprom/x86emu')
-rw-r--r--src/device/oprom/x86emu/debug.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/device/oprom/x86emu/debug.c b/src/device/oprom/x86emu/debug.c
index b3f4b6ebfb..e7a111b4f2 100644
--- a/src/device/oprom/x86emu/debug.c
+++ b/src/device/oprom/x86emu/debug.c
@@ -163,15 +163,15 @@ void x86emu_inc_decoded_inst_len (int x)
void x86emu_decode_printf (const char *x)
{
- sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",x);
+ strcpy(M.x86.decoded_buf+M.x86.enc_str_pos,x);
M.x86.enc_str_pos += strlen(x);
}
void x86emu_decode_printf2 (const char *x, int y)
{
char temp[100];
- sprintf(temp,x,y);
- sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",temp);
+ snprintf(temp, sizeof (temp), x,y);
+ strcpy(M.x86.decoded_buf+M.x86.enc_str_pos,temp);
M.x86.enc_str_pos += strlen(temp);
}
@@ -186,7 +186,7 @@ static void print_encoded_bytes (u16 s, u16 o)
int i;
char buf1[64];
for (i=0; i< M.x86.enc_pos; i++) {
- sprintf(buf1+2*i,"%02x", fetch_data_byte_abs(s,o+i));
+ snprintf(buf1+2*i, 64 - 2 * i, "%02x", fetch_data_byte_abs(s,o+i));
}
printf("%-20s ",buf1);
}