]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
More coverity.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 5 Feb 2015 06:50:51 +0000 (06:50 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 5 Feb 2015 06:50:51 +0000 (06:50 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12148 d7cf8633-e32d-0410-b094-e92efae38249

fs.c
lhnet.c

diff --git a/fs.c b/fs.c
index 994155aa290fe5ad69bb3b05e7531ae28995b64d..67d65713f498da5fb495fd50cbc74e17004dfe18 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -797,7 +797,11 @@ static qboolean PK3_GetTrueFileOffset (packfile_t *pfile, pack_t *pack)
                return true;
 
        // Load the local file description
-       lseek (pack->handle, pfile->offset, SEEK_SET);
+       if (lseek (pack->handle, pfile->offset, SEEK_SET) == -1)
+       {
+               Con_Printf ("Can't seek in package %s\n", pack->filename);
+               return false;
+       }
        count = read (pack->handle, buffer, ZIP_LOCAL_CHUNK_BASE_SIZE);
        if (count != ZIP_LOCAL_CHUNK_BASE_SIZE || BuffBigLong (buffer) != ZIP_DATA_HEADER)
        {
diff --git a/lhnet.c b/lhnet.c
index 229825711dad97a57819daa6750fc8c127636473..e2ded868e5508f268a6d8f49bc9b9267084f66f4 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -978,7 +978,13 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
                                                                namelen = sizeof(localaddress->addr.in6);
                                                                bindresult = bind(lhnetsocket->inetsocket, &localaddress->addr.sock, namelen);
                                                                if (bindresult != -1)
-                                                                       getsockname(lhnetsocket->inetsocket, &localaddress->addr.sock, &namelen);
+                                                               {
+                                                                       if (getsockname(lhnetsocket->inetsocket, &localaddress->addr.sock, &namelen))
+                                                                       {
+                                                                               // If getsockname failed, we can assume the bound socket is useless.
+                                                                               bindresult = -1;
+                                                                       }
+                                                               }
                                                        }
                                                        else
 #endif
@@ -986,7 +992,13 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
                                                                namelen = sizeof(localaddress->addr.in);
                                                                bindresult = bind(lhnetsocket->inetsocket, &localaddress->addr.sock, namelen);
                                                                if (bindresult != -1)
-                                                                       getsockname(lhnetsocket->inetsocket, &localaddress->addr.sock, &namelen);
+                                                               {
+                                                                       if (getsockname(lhnetsocket->inetsocket, &localaddress->addr.sock, &namelen))
+                                                                       {
+                                                                               // If getsockname failed, we can assume the bound socket is useless.
+                                                                               bindresult = -1;
+                                                                       }
+                                                               }
                                                        }
                                                        if (bindresult != -1)
                                                        {
@@ -997,7 +1009,10 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
                                                                {
                                                                        // enable DSCP for ToS support
                                                                        int tos = lhnet_default_dscp << 2;
-                                                                       setsockopt(lhnetsocket->inetsocket, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof(tos));
+                                                                       if (setsockopt(lhnetsocket->inetsocket, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof(tos)))
+                                                                       {
+                                                                               // Error in setsockopt - fine, we'll simply set no TOS then.
+                                                                       }
                                                                }
 #endif
                                                                lhnetsocket->next = &lhnet_socketlist;