diff options
author | Jiung <jiung.yu@samsung.com> | 2017-09-28 11:34:53 +0900 |
---|---|---|
committer | Jiung <jiung.yu@samsung.com> | 2017-09-28 11:35:00 +0900 |
commit | d7670fa89d64e74c6a3d8743c7df53d6177522da (patch) | |
tree | 966d04906a81ba1272ce0e419414c5a2d4139959 | |
parent | 3ff23b8470200ce6c0753422e61bf1cccdefdf55 (diff) | |
download | toybox-d7670fa89d64e74c6a3d8743c7df53d6177522da.tar.gz toybox-d7670fa89d64e74c6a3d8743c7df53d6177522da.tar.bz2 toybox-d7670fa89d64e74c6a3d8743c7df53d6177522da.zip |
Fix defect detected by static analyzersubmit/tizen/20170928.232941accepted/tizen/unified/20170929.081853
Change-Id: Ida9d618ce50bed3500414cd3752d7999c338468c
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
-rw-r--r-- | toys/samsung/nslookup.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/toys/samsung/nslookup.c b/toys/samsung/nslookup.c index b83ff97..bab44b9 100644 --- a/toys/samsung/nslookup.c +++ b/toys/samsung/nslookup.c @@ -100,10 +100,11 @@ static void resolve_addr(char *host, void *addr, char* port) if(ret <0 || ret > 65535 ) error_exit("bad port: %s", port); if (strncmp(host, "local:", 6) == 0) { - struct sockaddr *sockun = (struct sockaddr *)addr; - sockun->sa_family = AF_UNIX; - strncpy(((struct sockaddr_un *)sockun)->sun_path, host + 6, - sizeof(((struct sockaddr_un *)sockun)->sun_path)); + struct sockaddr_un *sockun = (struct sockaddr_un *)addr; + struct sockaddr *sock = (struct sockaddr *)addr; + sock->sa_family = AF_UNIX; + strncpy(sockun->sun_path, host + 6, sizeof(sockun->sun_path)); + sockun->sun_path[sizeof(sockun->sun_path) - 1] = '\0'; return ; } memset(&hint, 0, sizeof(hint)); |