s3: Fix Coverity ID 682: NEGATIVE_RETURNS
authorVolker Lendecke <vl@samba.org>
Sun, 27 Mar 2011 17:41:34 +0000 (19:41 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 27 Mar 2011 20:22:10 +0000 (22:22 +0200)
libcli/auth/smbencrypt.c

index 3274f113c200574daaaa7e0388d62cd273413fe6..abd8ad92a3c39d6a2f17805525aea90b80fb0d9f 100644 (file)
@@ -529,7 +529,7 @@ bool SMBNTLMv2encrypt(TALLOC_CTX *mem_ctx,
 bool encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flags)
 {
        uint8_t new_pw[512];
-       size_t new_pw_len;
+       ssize_t new_pw_len;
 
        /* the incoming buffer can be any alignment. */
        string_flags |= STR_NOALIGN;
@@ -537,6 +537,9 @@ bool encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flag
        new_pw_len = push_string(new_pw,
                                 password,
                                 sizeof(new_pw), string_flags);
+       if (new_pw_len == -1) {
+               return false;
+       }
 
        memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len);