summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaehoon.you <jaehoon.you@samsung.com>2013-01-08 20:37:24 +0900
committerjaehoon.you <jaehoon.you@samsung.com>2013-01-08 20:37:24 +0900
commit0f1291b433f8154857e9fc70cbfdf71546d465b0 (patch)
tree08c1e41fa5ec25d4d432d9c278b549a126819b6c
parent291e403d3041ec5c7074feefc5f9cb508e49c7de (diff)
downloadlthor-0f1291b433f8154857e9fc70cbfdf71546d465b0.tar.gz
lthor-0f1291b433f8154857e9fc70cbfdf71546d465b0.tar.bz2
lthor-0f1291b433f8154857e9fc70cbfdf71546d465b0.zip
[Prevent] fix Tizen 36515,36516,37705 - STRING_OVERFLOW, RESOURCE_LEAK
Change-Id: I184458fd8419d4e32a9a493f2258dbbdd2637980 Signed-off-by: jaehoon.you <jaehoon.you@samsung.com>
-rwxr-xr-xlthor.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lthor.c b/lthor.c
index c0dbbf4..e9419f0 100755
--- a/lthor.c
+++ b/lthor.c
@@ -445,7 +445,7 @@ const char* find_usb_device(void)
char buffer[11];
const char *dirname = "/sys/bus/usb/devices";
char usbpath[0x400];
- char usbdir[0x40];
+ char usbdir[0x100];
char *tty = NULL;
d = opendir(dirname);
@@ -583,6 +583,7 @@ int open_port(const char *portname, int wait)
r = tcgetattr(fd, &tios);
if (r < 0) {
fprintf(stderr, "line %d: tcgetattr failed\n", __LINE__);
+ close(fd);
return -1;
}
@@ -595,18 +596,21 @@ int open_port(const char *portname, int wait)
r = tcsetattr(fd, TCSANOW, &tios);
if (r < 0) {
fprintf(stderr, "line %d: tcsetattr failed\n", __LINE__);
+ close(fd);
return -1;
}
r = tcflush(fd, TCIOFLUSH);
if (r < 0) {
fprintf(stderr, "line %d: tcflush failed\n", __LINE__);
+ close(fd);
return -1;
}
r = thor_handshake(fd);
if (r < 0) {
fprintf(stderr, "line %d: handshake failed\n", __LINE__);
+ close(fd);
return -1;
}
@@ -942,6 +946,7 @@ int process_download(const char *portname, const char *pitfile, char **tarfileli
printf("\x1b[0;33;1m%s :\x1b[0m\n", *tfl);
if (get_entry_size_in_tar(*tfl, &len) < 0) {
perror("Error");
+ close(fd);
return -1;
}
total += len;
@@ -953,6 +958,7 @@ int process_download(const char *portname, const char *pitfile, char **tarfileli
if (pit_length < 0) {
fprintf(stderr, "line %d: failed to get pit length\n"
, __LINE__);
+ close(fd);
return -1;
}
total += pit_length;
@@ -970,6 +976,7 @@ int process_download(const char *portname, const char *pitfile, char **tarfileli
*/
if (r) {
fprintf(stderr, "RQT_DL_INIT, status = %08x\n", r);
+ close(fd);
return -1;
}