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:12:47 +0000 (16:12 +0500)
Per coverity CID#1332216, CID#1332218, CID#1373253, CID#1373254 and CID#1373255

watchdog/wd_packet.c

index 623094e69e08b8a88fe3150db4bc55e55f09c852..46a61831eb90a1fe36ecc010704c85118bfe0613 100644 (file)
@@ -1197,8 +1197,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;