From 0f1291b433f8154857e9fc70cbfdf71546d465b0 Mon Sep 17 00:00:00 2001 From: "jaehoon.you" Date: Tue, 8 Jan 2013 20:37:24 +0900 Subject: [Prevent] fix Tizen 36515,36516,37705 - STRING_OVERFLOW, RESOURCE_LEAK Change-Id: I184458fd8419d4e32a9a493f2258dbbdd2637980 Signed-off-by: jaehoon.you --- lthor.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3