Skip to content

Commit 88c1e28

Browse files
committed
use snprintf to guard against overflows in exception messages
1 parent a99d9b9 commit 88c1e28

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utils.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
try { \
2626
OpenZWave::Manager::Get() -> METHOD ( __VA_ARGS__ ); \
2727
} catch ( OpenZWave::OZWException& e ) { \
28-
char buffer [100]; \
29-
sprintf(buffer, "Exception calling OpenZWave::Manager::%s in %s(%d): %s", \
28+
char buffer [200]; \
29+
snprintf(buffer, 200, "Exception calling OpenZWave::Manager::%s in %s(%d): %s", \
3030
stringify(METHOD), e.GetFile().c_str(), e.GetLine(), e.GetMsg().c_str()); \
3131
Nan::ThrowError( buffer ); \
3232
}
@@ -35,8 +35,8 @@
3535
try { \
3636
VALUE = OpenZWave::Manager::Get() -> METHOD ( __VA_ARGS__ ); \
3737
} catch ( OpenZWave::OZWException& e ) { \
38-
char buffer [100]; \
39-
sprintf(buffer, "Exception calling OpenZWave::Manager::%s in %s(%d): %s", \
38+
char buffer [200]; \
39+
snprintf(buffer, 200, "Exception calling OpenZWave::Manager::%s in %s(%d): %s", \
4040
stringify(METHOD), e.GetFile().c_str(), e.GetLine(), e.GetMsg().c_str()); \
4141
Nan::ThrowError( buffer ); \
4242
}

0 commit comments

Comments
 (0)