mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 568079: Fix potential buffer overflows
Change-Id: I79898944575f895bfe4d99ce2aabaa88ea58d678 Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
This commit is contained in:
parent
7f7a310c07
commit
60bdeb63ca
5 changed files with 3 additions and 3 deletions
|
@ -53,7 +53,7 @@ static void closeAndthrowIOException(HANDLE handle, JNIEnv *env, const char *msg
|
|||
#endif
|
||||
char buff[256];
|
||||
#ifndef __MINGW32__
|
||||
sprintf(buff, "%s: %s", msg, strerror(errno));
|
||||
snprintf(buff, sizeof(buff), "%s: %s", msg, strerror(errno));
|
||||
close(fd);
|
||||
#else
|
||||
sprintf_s(buff, sizeof(buff), "%s (%d)", msg, GetLastError());
|
||||
|
@ -67,7 +67,7 @@ static void closeAndthrowIOException(HANDLE handle, JNIEnv *env, const char *msg
|
|||
static void throwIOException(JNIEnv *env, const char *msg) {
|
||||
char buff[256];
|
||||
#ifndef __MINGW32__
|
||||
sprintf(buff, "%s: %s", msg, strerror(errno));
|
||||
snprintf(buff, sizeof(buff), "%s: %s", msg, strerror(errno));
|
||||
#else
|
||||
sprintf_s(buff, sizeof(buff), "%s (%d)", msg, GetLastError());
|
||||
#endif
|
||||
|
@ -82,7 +82,7 @@ JNIEXPORT jlong JNICALL FUNC(open0)(JNIEnv *env, jobject jobj, jstring portName,
|
|||
int fd = open(cportName, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd < 0) {
|
||||
char msg[256];
|
||||
sprintf(msg, "Error opening %s", cportName);
|
||||
snprintf(msg, sizeof(msg), "Error opening %s", cportName);
|
||||
(*env)->ReleaseStringUTFChars(env, portName, cportName);
|
||||
throwIOException(env, msg);
|
||||
return fd;
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue