Get rid of build warnings
authorMarcin Lis <m.lis@samsung.com>
Thu, 18 Jul 2013 08:35:32 +0000 (10:35 +0200)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 6 Feb 2014 16:13:21 +0000 (17:13 +0100)
[Issue#] SSDWSSP-397
[Bug] Several warnings was appearing during package build
[Cause] These warnings mainly concern implicit functions declarations
and comparisons between variables of different types
[Solution] Adding function declarations, header file inclusions,
explicit cast operators.
Also 'Werror' flag is added to CMakeLists.txt .

[Verification] Successful compilation & all security tests successfully
completed on target device

Change-Id: I2387b829835319354097384497abd9f1eaec9636

CMakeLists.txt
src/communication/security-server-comm.c
src/include/security-server-comm.h
src/server/security-server-cookie.c
src/server/security-server-main.c
src/server/security-server-password.c

index 19e86ca..4084751 100644 (file)
@@ -51,6 +51,7 @@ ADD_DEFINITIONS("-fPIC")
 
 
 # Set compiler warning flags
+ADD_DEFINITIONS("-Werror")                      # Make all warnings into errors.
 ADD_DEFINITIONS("-Wall")                        # Generate all warnings
 ADD_DEFINITIONS("-Wextra")                      # Generate even more extra warnings
 
index 9ccda0d..048641e 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "security-server-common.h"
 #include "security-server-comm.h"
+#include "smack-check.h"
 
 void printhex(const unsigned char *data, int size)
 {
@@ -586,7 +587,7 @@ int send_object_name(int sockfd, char *obj)
     }
 
     ret = TEMP_FAILURE_RETRY(write(sockfd, msg, sizeof(hdr) + strlen(obj)));
-    if (ret < sizeof(hdr) + strlen(obj))
+    if (ret < (int)(sizeof(hdr) + strlen(obj)))
     {
         /* Error on writing */
         SEC_SVR_ERR("Error on write: %d", ret);
@@ -640,7 +641,7 @@ int send_gid(int sockfd, int gid)
 
     /* Send it */
     ret = TEMP_FAILURE_RETRY(write(sockfd, msg, sizeof(hdr) + sizeof(gid)));
-    if (ret < sizeof(hdr) + sizeof(gid))
+    if (ret < (int)(sizeof(hdr) + sizeof(gid)))
     {
         /* Error on writing */
         SEC_SVR_ERR("Error on write(): %d", ret);
@@ -694,7 +695,7 @@ int send_pid(int sockfd, int pid)
 
     /* Send it */
     ret = TEMP_FAILURE_RETRY(write(sockfd, msg, sizeof(hdr) + sizeof(pid)));
-    if (ret < sizeof(hdr) + sizeof(pid))
+    if (ret < (int)(sizeof(hdr) + sizeof(pid)))
     {
         /* Error on writing */
         SEC_SVR_ERR("Error on write(): %d", ret);
@@ -866,7 +867,7 @@ int send_cookie_request(int sock_fd)
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, &hdr, sizeof(hdr)));
-    if (retval < sizeof(hdr))
+    if (retval < (int)sizeof(hdr))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1042,7 +1043,7 @@ int send_privilege_check_request(int sock_fd, const char *cookie, int gid)
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, buf, sizeof(buf)));
-    if (retval < sizeof(buf))
+    if (retval < (int)sizeof(buf))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1153,7 +1154,7 @@ int send_smack_request(int sock_fd, const char *cookie)
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, buf, sizeof(buf)));
-    if (retval < sizeof(buf))
+    if (retval < (int)sizeof(buf))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1299,7 +1300,7 @@ int send_pid_request(int sock_fd, const char *cookie)
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, buf, sizeof(buf)));
-    if (retval < sizeof(buf))
+    if (retval < (int)sizeof(buf))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1343,7 +1344,7 @@ int send_valid_pwd_request(int sock_fd)
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, &hdr, sizeof(hdr)));
-    if (retval < sizeof(hdr))
+    if (retval < (int)sizeof(hdr))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1440,7 +1441,7 @@ int send_set_pwd_request(int sock_fd,
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, buf, total_length));
-    if (retval < sizeof(buf))
+    if (retval < (int)sizeof(buf))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1505,7 +1506,7 @@ int send_set_pwd_validity_request(int sock_fd, const unsigned int valid_period_i
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, buf, total_length));
-    if (retval < sizeof(buf))
+    if (retval < (int)sizeof(buf))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1570,7 +1571,7 @@ int send_set_pwd_max_challenge_request(int sock_fd, const unsigned int max_chall
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, buf, total_length));
-    if (retval < sizeof(buf))
+    if (retval < (int)sizeof(buf))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1655,7 +1656,7 @@ int send_reset_pwd_request(int sock_fd,
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, buf, total_length));
-    if (retval < sizeof(buf))
+    if (retval < (int)sizeof(buf))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1727,7 +1728,7 @@ int send_chk_pwd_request(int sock_fd, const char *challenge)
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, buf, total_length));
-    if (retval < sizeof(buf))
+    if (retval < (int)sizeof(buf))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1788,7 +1789,7 @@ int send_set_pwd_history_request(int sock_fd, int num)
 
     /* Send to server */
     retval = TEMP_FAILURE_RETRY(write(sock_fd, buf, ptr));
-    if (retval < sizeof(buf))
+    if (retval < (int)sizeof(buf))
     {
         /* Write error */
         SEC_SVR_ERR("Error on write(): %d", retval);
@@ -1821,7 +1822,7 @@ int recv_hdr(int client_sockfd, basic_header *basic_hdr)
 
     /* Receive request header first */
     retval = TEMP_FAILURE_RETRY(read(client_sockfd, basic_hdr, sizeof(basic_header)));
-    if (retval < sizeof(basic_header))
+    if (retval < (int)sizeof(basic_header))
     {
         SEC_SVR_ERR("read failed. closing socket %d", retval);
         return SECURITY_SERVER_ERROR_RECV_FAILED;
@@ -1845,7 +1846,7 @@ int recv_check_privilege_request(int sockfd, unsigned char *requested_cookie, in
     }
 
     retval = TEMP_FAILURE_RETRY(read(sockfd, requested_privilege, sizeof(int)));
-    if (retval < sizeof(int))
+    if (retval < (int)sizeof(int))
     {
         SEC_SVR_ERR("privilege size is too small: %d", retval);
         return SECURITY_SERVER_ERROR_RECV_FAILED;
@@ -1870,14 +1871,14 @@ int recv_check_privilege_new_request(int sockfd,
     }
 
     retval = TEMP_FAILURE_RETRY(read(sockfd, &olen, sizeof(int)));
-    if (retval < sizeof(int) || olen < 0 || olen > MAX_OBJECT_LABEL_LEN)
+    if (retval < (int)sizeof(int) || olen < 0 || olen > MAX_OBJECT_LABEL_LEN)
     {
         SEC_SVR_ERR("error reading object_label len: %d", retval);
         return SECURITY_SERVER_ERROR_RECV_FAILED;
     }
 
     retval = TEMP_FAILURE_RETRY(read(sockfd, &alen, sizeof(int)));
-    if (retval < sizeof(int) || alen < 0 || alen > MAX_MODE_STR_LEN)
+    if (retval < (int)sizeof(int) || alen < 0 || alen > MAX_MODE_STR_LEN)
     {
         SEC_SVR_ERR("error reading access_rights len: %d", retval);
         return SECURITY_SERVER_ERROR_RECV_FAILED;
@@ -2004,7 +2005,7 @@ int recv_generic_response(int sockfd, response_header *hdr)
 
     /* Receive response */
     retval = TEMP_FAILURE_RETRY(read(sockfd, hdr, sizeof(response_header)));
-    if (retval < sizeof(response_header))
+    if (retval < (int)sizeof(response_header))
     {
         /* Error on socket */
         SEC_SVR_ERR("Client: Receive failed %d", retval);
@@ -2033,7 +2034,7 @@ int recv_get_gid_response(int sockfd, response_header *hdr, int *gid)
         return return_code_to_error_code(hdr->return_code);
 
     retval = TEMP_FAILURE_RETRY(read(sockfd, gid, sizeof(int)));
-    if (retval < sizeof(int))
+    if (retval < (int)sizeof(int))
     {
         /* Error on socket */
         SEC_SVR_ERR("Receive failed %d", retval);
@@ -2062,7 +2063,7 @@ int recv_get_object_name(int sockfd, response_header *hdr, char *object, int max
 
     /* Read response */
     retval = TEMP_FAILURE_RETRY(read(sockfd, hdr, sizeof(response_header)));
-    if (retval < sizeof(response_header))
+    if (retval < (int)sizeof(response_header))
     {
         /* Error on socket */
         SEC_SVR_ERR("cannot recv respons: %d", retval);
@@ -2169,7 +2170,7 @@ int recv_smack_response(int sockfd, response_header *hdr, char *label)
         return return_code_to_error_code(hdr->return_code);
 
     retval = TEMP_FAILURE_RETRY(read(sockfd, label, SMACK_LABEL_LEN + 1));
-    if (retval < sizeof(int))
+    if (retval < (int)sizeof(int))
     {
         /* Error on socket */
         SEC_SVR_ERR("Client: Receive failed %d", retval);
@@ -2200,7 +2201,7 @@ int recv_pid_response(int sockfd, response_header *hdr, int *pid)
         return return_code_to_error_code(hdr->return_code);
 
     retval = TEMP_FAILURE_RETRY(read(sockfd, pid, sizeof(int)));
-    if (retval < sizeof(int))
+    if (retval < (int)sizeof(int))
     {
         /* Error on socket */
         SEC_SVR_ERR("Client: Receive failed %d", retval);
@@ -2238,21 +2239,21 @@ int recv_pwd_response(int sockfd, response_header *hdr,
     }
 
     retval = TEMP_FAILURE_RETRY(read(sockfd, current_attempts, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if (retval < (int)sizeof(unsigned int))
     {
         /* Error on socket */
         SEC_SVR_ERR("Client: Receive failed %d", retval);
         return SECURITY_SERVER_ERROR_RECV_FAILED;
     }
     retval = TEMP_FAILURE_RETRY(read(sockfd, max_attempts, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if (retval < (int)sizeof(unsigned int))
     {
         /* Error on socket */
         SEC_SVR_ERR("Client: Receive failed %d", retval);
         return SECURITY_SERVER_ERROR_RECV_FAILED;
     }
     retval = TEMP_FAILURE_RETRY(read(sockfd, valid_secs, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if (retval < (int)sizeof(unsigned int))
     {
         /* Error on socket */
         SEC_SVR_ERR("Client: Receive failed %d", retval);
@@ -2424,7 +2425,7 @@ int get_client_gid_list(int sockfd, int **privileges)
     //now we have "Groups:" line in fileLine[]
     ret = 0;
     strtok(fileLine, delim);
-    while (token = strtok(NULL, delim))
+    while ((token = strtok(NULL, delim)))
     {
         //add found GID
         if (*privileges == NULL)
index 785f57f..efc142f 100644 (file)
@@ -155,4 +155,11 @@ int send_reset_pwd_request(int sock_fd,
 int send_set_pwd_history_request(int sock_fd, int num);
 int get_socket_from_systemd(int *sockfd);
 
+int send_pwd_response(const int sockfd,
+                      const unsigned char msg_id,
+                      const unsigned char return_code,
+                      const unsigned int current_attempts,
+                      const unsigned int max_attempts,
+                      const unsigned int expire_time);
+
 #endif
index 3b31880..e73b22b 100644 (file)
 
 #include <security-server-cookie.h>
 #include <security-server-comm.h>
+#include <security-server-util.h>
 #include <smack-check.h>
 
+#include <privilege-control.h>
+
 /* Delete useless cookie item *
  * then connect prev and next */
 void free_cookie_item(cookie_list *cookie)
@@ -121,7 +124,7 @@ cookie_list *garbage_collection(cookie_list *cookie)
 cookie_list *search_existing_cookie(int pid, const cookie_list *c_list)
 {
     cookie_list *current = (cookie_list*)c_list, *cookie = NULL;
-    char *exe = NULL, *debug_cmdline = NULL;
+    char *exe = NULL;
 
     /* Search from the list */
     while (current != NULL)
index 9f78994..81797a6 100644 (file)
@@ -112,6 +112,7 @@ void print_cookie(cookie_list *list)
 #endif
 
 
+#if 0
 /* Object name is actually name of a Group ID *
  * This function opens /etc/group file and search group ID and
  * returns the string */
@@ -152,7 +153,11 @@ int search_object_name(int gid, char *obj, int obj_size)
             }
             linebuf = tempstr;
             bzero(linebuf + bufsize, 128);
-            fgets(linebuf + bufsize, 128, fp);
+            if((fgets(linebuf + bufsize, 128, fp) == NULL) && !feof(fp))
+            {
+                ret = SECURITY_SERVER_ERROR_FILE_OPERATION;
+                goto error;
+            }
             bufsize += 128;
         }
 
@@ -211,6 +216,7 @@ error:
         fclose(fp);
     return ret;
 }
+#endif
 
 /*
  * Searches for group ID by given group name
index fe13d94..a13e6aa 100644 (file)
@@ -26,6 +26,7 @@
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <time.h>
 #include <sys/time.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -156,7 +157,7 @@ int load_password(unsigned char *cur_pwd, unsigned int *max_attempt, unsigned in
         }
 
         retval = TEMP_FAILURE_RETRY(read(fd, max_attempt, sizeof(unsigned int)));
-        if (retval < sizeof(unsigned int))
+        if (retval < (int)sizeof(unsigned int))
         {
             SECURE_SLOGD("%s", "Server: Current password corrupted. resetting to previous one. 1");
             close(fd);
@@ -166,7 +167,7 @@ int load_password(unsigned char *cur_pwd, unsigned int *max_attempt, unsigned in
         }
 
         retval = TEMP_FAILURE_RETRY(read(fd, expire_time, sizeof(unsigned int)));
-        if (retval < sizeof(unsigned int))
+        if (retval < (int)sizeof(unsigned int))
         {
             SECURE_SLOGD("%s", "Server: Current password corrupted. resetting to previous one. 2");
             close(fd);
@@ -179,7 +180,7 @@ int load_password(unsigned char *cur_pwd, unsigned int *max_attempt, unsigned in
         /* Check expiration time. */
         if (*expire_time == 0) /* No valid period */
             *expire_time = 0xffffffff;
-        else if (*expire_time <= time(NULL)) /* expired */
+        else if (*expire_time <= (unsigned int)time(NULL)) /* expired */
             *expire_time = 0;
         else        /* valid yet */
             *expire_time -= time(NULL);
@@ -221,7 +222,7 @@ int get_current_attempt(int increase)
             attempt = increase;
             retval = TEMP_FAILURE_RETRY(write(fd, &attempt, sizeof(int)));
             close(fd);
-            if (retval < sizeof(int))
+            if (retval < (int)sizeof(int))
             {
                 SEC_SVR_ERR("%s", "Server ERROR: Cannot write attempt");
                 return SECURITY_SERVER_ERROR_FILE_OPERATION;
@@ -233,7 +234,7 @@ int get_current_attempt(int increase)
     }
     retval = TEMP_FAILURE_RETRY(read(fd, &attempt, sizeof(int)));
     close(fd);
-    if (retval < sizeof(int))
+    if (retval < (int)sizeof(int))
     {
         SEC_SVR_ERR("%s", "Server ERROR: Cannot read attempt");
         return SECURITY_SERVER_ERROR_FILE_OPERATION;
@@ -258,7 +259,7 @@ int get_current_attempt(int increase)
         attempt += increase;
         retval = TEMP_FAILURE_RETRY(write(fd, &attempt, sizeof(int)));
         close(fd);
-        if (retval < sizeof(int))
+        if (retval < (int)sizeof(int))
         {
             SEC_SVR_ERR("%s", "Server ERROR: Cannot write attempt");
             return SECURITY_SERVER_ERROR_FILE_OPERATION;
@@ -292,7 +293,7 @@ int reset_attempt(void)
     }
     retval = TEMP_FAILURE_RETRY(write(fd, &attempt, sizeof(int)));
     close(fd);
-    if (retval < sizeof(int))
+    if (retval < (int)sizeof(int))
     {
         SEC_SVR_ERR("%s", "Server ERROR: Cannot write attempt");
         return SECURITY_SERVER_ERROR_FILE_OPERATION;
@@ -306,13 +307,19 @@ int check_password(const unsigned char *cur_pwd, const unsigned char *requested_
                    const unsigned int max_attempts, const unsigned int expire_time,
                    int *current_attempt)
 {
+/* The following variable is needed only when SECURITY_SERVER_DEBUG_DLOG flag is set     */
+/* If its definition is not surrounded by preprocessor conditionals then it will         */
+/* cause compilation warning "unused variable". Please see the SECURE_SLOGD redefinition */
+/* in "security_server_common.h" header */
+#if SECURITY_SERVER_DEBUG_DLOG
     unsigned int current_time = time(NULL);
+#endif
 
     if (max_attempts != 0)
     {
         *current_attempt = get_current_attempt(1);
 
-        if (*current_attempt > max_attempts)
+        if ((unsigned int)*current_attempt > max_attempts)
         {
             SEC_SVR_DBG("Server: Max attempt exceeded: %d, %d", *current_attempt, max_attempts);
             return SECURITY_SERVER_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED;
@@ -376,7 +383,7 @@ int set_history(int num)
     }
     retval = TEMP_FAILURE_RETRY(write(fd, &num, sizeof(int)));
     close(fd);
-    if (retval < sizeof(int))
+    if (retval < (int)sizeof(int))
     {
         SEC_SVR_ERR("%s", "Server ERROR: Cannot write history");
         return SECURITY_SERVER_ERROR_FILE_OPERATION;
@@ -410,7 +417,7 @@ int get_history_num(void)
     }
     retval = TEMP_FAILURE_RETRY(read(fd, &history, sizeof(history)));
     close(fd);
-    if (retval < sizeof(history))
+    if (retval < (int)sizeof(history))
     {
         SEC_SVR_DBG("%s", "History file corrupted. Creating new one");
         unlink(path);
@@ -548,14 +555,14 @@ int set_password(const unsigned char *requested_new_pwd, const unsigned int atte
         return SECURITY_SERVER_ERROR_FILE_OPERATION;
     }
     retval = TEMP_FAILURE_RETRY(write(fd, &attempts, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if (retval < (int)sizeof(unsigned int))
     {
         SECURE_SLOGE("%s", "Cannot write password");
         close(fd);
         return SECURITY_SERVER_ERROR_FILE_OPERATION;
     }
     retval = TEMP_FAILURE_RETRY(write(fd, &expire_time, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if (retval < (int)sizeof(unsigned int))
     {
         SECURE_SLOGE("%s", "Cannot write password");
         close(fd);
@@ -720,7 +727,7 @@ int process_set_pwd_request(int sockfd)
 
     /* Receive size of pwds */
     retval = TEMP_FAILURE_RETRY(read(sockfd, &cur_pwd_len, sizeof(char)));
-    if (retval < sizeof(char) || cur_pwd_len > SECURITY_SERVER_MAX_PASSWORD_LEN)
+    if (retval < (int)sizeof(char) || cur_pwd_len > SECURITY_SERVER_MAX_PASSWORD_LEN)
     {
         SECURE_SLOGE("Server Error: current password length recieve failed: %d, %d", retval, cur_pwd_len);
         retval = send_generic_response(sockfd,
@@ -733,7 +740,7 @@ int process_set_pwd_request(int sockfd)
         goto error;
     }
     retval = TEMP_FAILURE_RETRY(read(sockfd, &new_pwd_len, sizeof(char)));
-    if (retval < sizeof(char) || new_pwd_len > SECURITY_SERVER_MAX_PASSWORD_LEN || new_pwd_len < 0)
+    if (retval < (int)sizeof(char) || new_pwd_len > SECURITY_SERVER_MAX_PASSWORD_LEN)
     {
         SECURE_SLOGE("Server Error: new password length recieve failed: %d, %d", retval, new_pwd_len);
         retval = send_generic_response(sockfd,
@@ -764,7 +771,7 @@ int process_set_pwd_request(int sockfd)
             }
             goto error;
         }
-        requested_cur_pwd[cur_pwd_len] = 0;
+        requested_cur_pwd[(int)cur_pwd_len] = 0;
     }
     else /* Check first password set attempt but password is already set */
     {
@@ -796,11 +803,11 @@ int process_set_pwd_request(int sockfd)
         }
         goto error;
     }
-    requested_new_pwd[new_pwd_len] = 0;
+    requested_new_pwd[(int)new_pwd_len] = 0;
 
     /* Receive max attempt */
     retval = TEMP_FAILURE_RETRY(read(sockfd, &received_attempts, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if (retval < (int)sizeof(unsigned int))
     {
         SEC_SVR_ERR("Sever Error:  Max attempt receive failed: %d", retval);
         retval = send_generic_response(sockfd,
@@ -815,7 +822,7 @@ int process_set_pwd_request(int sockfd)
 
     /* Receive valid period  */
     retval = TEMP_FAILURE_RETRY(read(sockfd, &valid_days, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if (retval < (int)sizeof(unsigned int))
     {
         SEC_SVR_ERR("Sever Error:  Max attempt receive failed: %d", retval);
         retval = send_generic_response(sockfd,
@@ -999,7 +1006,7 @@ int process_reset_pwd_request(int sockfd)
 
     /* Receive size of pwd */
     retval = TEMP_FAILURE_RETRY(read(sockfd, &new_pwd_len, sizeof(char)));
-    if (retval < sizeof(char) || new_pwd_len < 0 || new_pwd_len > SECURITY_SERVER_MAX_PASSWORD_LEN)
+    if (retval < (int)sizeof(char) || new_pwd_len > SECURITY_SERVER_MAX_PASSWORD_LEN)
     {
         SECURE_SLOGE("Server Error: new password length recieve failed: %d, %d", retval, new_pwd_len);
         retval = send_generic_response(sockfd,
@@ -1026,11 +1033,11 @@ int process_reset_pwd_request(int sockfd)
         }
         goto error;
     }
-    requested_new_pwd[new_pwd_len] = 0;
+    requested_new_pwd[(int)new_pwd_len] = 0;
 
     /* Receive max attempt */
     retval = TEMP_FAILURE_RETRY(read(sockfd, &received_attempts, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if (retval < (int)sizeof(unsigned int))
     {
         SEC_SVR_ERR("Sever Error:  Max attempt receive failed: %d", retval);
         retval = send_generic_response(sockfd,
@@ -1045,7 +1052,7 @@ int process_reset_pwd_request(int sockfd)
 
     /* Receive valid period  */
     retval = TEMP_FAILURE_RETRY(read(sockfd, &valid_days, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if (retval < (int)sizeof(unsigned int))
     {
         SEC_SVR_ERR("Sever Error:  Max attempt receive failed: %d", retval);
         retval = send_generic_response(sockfd,
@@ -1146,7 +1153,7 @@ int process_chk_pwd_request(int sockfd)
 
     /* Receive size of challenge */
     retval = TEMP_FAILURE_RETRY(read(sockfd, &challenge_len, sizeof(char)));
-    if (retval < sizeof(char) || challenge_len > SECURITY_SERVER_MAX_PASSWORD_LEN)
+    if (retval < (int)sizeof(char) || challenge_len > SECURITY_SERVER_MAX_PASSWORD_LEN)
     {
         SEC_SVR_ERR("Server ERROR: challenge length recieve failed: %d", retval);
         retval = send_generic_response(sockfd,
@@ -1174,7 +1181,7 @@ int process_chk_pwd_request(int sockfd)
             }
             goto error;
         }
-        requested_challenge[challenge_len] = 0;
+        requested_challenge[(int)challenge_len] = 0;
     }
     else
     {
@@ -1304,7 +1311,7 @@ int process_set_pwd_history_request(int sockfd)
 
     /* Receive size of pwds */
     retval = TEMP_FAILURE_RETRY(read(sockfd, &history_num, sizeof(char)));
-    if (retval < sizeof(char) || history_num > SECURITY_SERVER_MAX_PASSWORD_HISTORY || history_num < 0)
+    if (retval < (int)sizeof(char) || history_num > SECURITY_SERVER_MAX_PASSWORD_HISTORY)
     {
         SEC_SVR_ERR("Server Error: History number recieve failed: %d, %d", retval, history_num);
         retval = send_generic_response(sockfd,
@@ -1352,7 +1359,7 @@ int process_set_pwd_max_challenge_request(int sockfd)
     // this value (max challenge) for current password
 
     retval = TEMP_FAILURE_RETRY(read(sockfd, &max_challenge, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if(retval < (int)sizeof(unsigned int))
     {
         SEC_SVR_ERR("Server Error: recieve failed: %d", retval);
         retval = send_generic_response(sockfd,
@@ -1432,7 +1439,7 @@ int process_set_pwd_validity_request(int sockfd)
     // this value (validity) for current password
 
     retval = TEMP_FAILURE_RETRY(read(sockfd, &validity, sizeof(unsigned int)));
-    if (retval < sizeof(unsigned int))
+    if(retval < (int)sizeof(unsigned int))
     {
         SEC_SVR_ERR("Server Error: recieve failed: %d", retval);
         retval = send_generic_response(sockfd,