aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/win32
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2012-09-25 18:01:23 +0200
committerBjörn-Egil Dahlberg <[email protected]>2012-09-25 18:01:23 +0200
commitd6089c81ce6d3184738be4f936e2cbd5008e077f (patch)
tree25a3a84235e7f43dfaf4bf33a2c506a249abe97d /erts/emulator/sys/win32
parentec28e2668b2e45d70efeb0005dcb2a70766cc7cb (diff)
parent32286d6523d0f46163f1c5e23253516d61c46c78 (diff)
downloadotp-d6089c81ce6d3184738be4f936e2cbd5008e077f.tar.gz
otp-d6089c81ce6d3184738be4f936e2cbd5008e077f.tar.bz2
otp-d6089c81ce6d3184738be4f936e2cbd5008e077f.zip
Merge branch 'egil/r16/strengthen-buffer-copies'
* egil/r16/strengthen-buffer-copies: Replace sprintf with erts_snprintf in beam Replace sprintf with erts_snprintf in epmd Replace sprintf with erts_snprintf in inet_gethost
Diffstat (limited to 'erts/emulator/sys/win32')
-rwxr-xr-xerts/emulator/sys/win32/sys.c7
-rw-r--r--erts/emulator/sys/win32/sys_float.c8
2 files changed, 8 insertions, 7 deletions
diff --git a/erts/emulator/sys/win32/sys.c b/erts/emulator/sys/win32/sys.c
index c4e748ed3c..6c69fecbf3 100755
--- a/erts/emulator/sys/win32/sys.c
+++ b/erts/emulator/sys/win32/sys.c
@@ -2835,10 +2835,10 @@ static void stop_select(ErlDrvEvent e, void* _)
** no interpretation of this should be done by the rest of the
** emulator. The buffer should be at least 21 bytes long.
*/
-void sys_get_pid(char *buffer){
+void sys_get_pid(char *buffer, size_t buffer_size){
DWORD p = GetCurrentProcessId();
/* The pid is scalar and is an unsigned long. */
- sprintf(buffer,"%lu",(unsigned long) p);
+ erts_snprintf(buffer, buffer_size, "%lu",(unsigned long) p);
}
void
@@ -3178,7 +3178,8 @@ erl_assert_error(char* expr, char* file, int line)
{
char message[1024];
- sprintf(message, "File %hs, line %d: %hs", file, line, expr);
+ erts_snprintf(message, sizeof(message),
+ "File %hs, line %d: %hs", file, line, expr);
MessageBox(GetActiveWindow(), message, "Assertion failed",
MB_OK | MB_ICONERROR);
#if 0
diff --git a/erts/emulator/sys/win32/sys_float.c b/erts/emulator/sys/win32/sys_float.c
index 6558ad2d99..09dad89140 100644
--- a/erts/emulator/sys/win32/sys_float.c
+++ b/erts/emulator/sys/win32/sys_float.c
@@ -118,18 +118,18 @@ sys_chars_to_double(char *buf, double *fp)
*/
int
-sys_double_to_chars(double fp, char *buf)
+sys_double_to_chars(double fp, char *buffer, size_t buffer_size)
{
- char *s = buf;
+ char *s = buffer;
- (void) sprintf(buf, "%.20e", fp);
+ (void) erts_snprintf(buffer, buffer_size, "%.20e", fp);
/* Search upto decimal point */
if (*s == '+' || *s == '-') s++;
while (isdigit(*s)) s++;
if (*s == ',') *s++ = '.'; /* Replace ',' with '.' */
/* Scan to end of string */
while (*s) s++;
- return s-buf; /* i.e strlen(buf) */
+ return s-buffer; /* i.e strlen(buffer) */
}
int