Fix coverity reported issues of buffer overrun.
authorMuhammad Usama <m.usama@gmail.com>
Tue, 4 Apr 2017 11:11:15 +0000 (16:11 +0500)
committerMuhammad Usama <m.usama@gmail.com>
Tue, 4 Apr 2017 11:11:15 +0000 (16:11 +0500)
Per coverity CID#1332216, CID#1332218, CID#1373253, CID#1373254 and CID#1373255

src/watchdog/wd_packet.c

index 9d4513cd6175c97cc94e09fc4b6fb2e69a860c02..f0d21156a3478de4833b45572604152b028eb13e 100644 (file)
@@ -1251,8 +1251,9 @@ wd_calc_hash(const char *str, int len, char *buf)
        /* calculate hash using md5 encrypt */
        if (! pool_md5_encrypt(pass, username, strlen(username), tmp_buf + MD5_PASSWD_LEN + 1))
                goto wd_calc_hash_error;
-       buf[(MD5_PASSWD_LEN+1)*2-1] = '\0';
-       
+
+       tmp_buf[sizeof(tmp_buf)-1] = '\0';
+
        if (! pool_md5_encrypt(tmp_buf+MD5_PASSWD_LEN+1, str, len, tmp_buf))
                goto wd_calc_hash_error;