Skip to content

Commit 4b0f421

Browse files
committed
8307855: update for deprecated sprintf for src/utils
Reviewed-by: thartmann
1 parent 39dc40f commit 4b0f421

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/utils/hsdis/binutils/hsdis-binutils.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -219,6 +219,8 @@ static void* decode(struct hsdis_app_data* app_data, const char* options) {
219219
const decode_func_vtype decode_func_virtual_address = &decode_instructions_virtual;
220220
const decode_func_stype decode_func_address = &decode_instructions;
221221

222+
#define remaining_buflen(buf, bufsize, p) ((bufsize) - ((p) - (buf)))
223+
222224
static const char* format_insn_close(const char* close,
223225
disassemble_info* dinfo,
224226
char* buf, size_t bufsize) {
@@ -244,9 +246,9 @@ static const char* format_insn_close(const char* close,
244246

245247
strcpy(buf, close);
246248
char* p = buf;
247-
if (type) sprintf(p += strlen(p), " type='%s'", type);
248-
if (dsize) sprintf(p += strlen(p), " dsize='%d'", dsize);
249-
if (delays) sprintf(p += strlen(p), " delay='%d'", delays);
249+
if (type) snprintf(p += strlen(p), remaining_buflen(buf, bufsize, p), " type='%s'", type);
250+
if (dsize) snprintf(p += strlen(p), remaining_buflen(buf, bufsize, p), " dsize='%d'", dsize);
251+
if (delays) snprintf(p += strlen(p), remaining_buflen(buf, bufsize, p), " delay='%d'", delays);
250252
return buf;
251253
}
252254

0 commit comments

Comments
 (0)