[haiku-commits] haiku: hrev51610 - in src: kits/network/libnetapi add-ons/kernel/network/stack kits/midi servers/app

  • From: waddlesplash@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 23 Nov 2017 19:54:02 +0100 (CET)

hrev51610 adds 7 changesets to branch 'master'
old head: 4d87bc24d46a6fa6096783af1ebd31ac0add19e5
new head: 14d690378fbdeaba2b940f31d07f95ef861921a3
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=14d690378fbd+%5E4d87bc24d46a

----------------------------------------------------------------------------

d73993ff202c: configure: Fix & enhance --use-clang.
  
  Now you set the arch along with the argument, and specify the binutils
  manually (and thus build without a complete crosstools environment.)

14fcbb52cd64: device_interfaces: Fix memory leak on success.
  
  The module list was closed properly at the end of the function body
  (failure case) but not inside the loop on the success case.
  
  CID 605738.

75fa008e2384: BProxySecureSocket: Fix obviously untested code.
  
   * Actually set status before testing it
   * sscanf (reads from passed buffer) not scanf (reads from stdin)
   * &httpStatus not httpStatus.
  
  Found by Coverity.

7131246873bb: BNetworkAddress: Close socket in ResolveForDestination.
  
  It was closed on all the failure cases but not on the success one.
  Found by Coverity.

d692d22c9d60: debugger/elf: Don't leak memory in failure case.
  
  CID 1423098.

a20f4f8a8511: MidiSettings: Don't leak settings in failure case.
  
  CID 1422944.

14d690378fbd: app_server/DelayedMessage: Delete scheduled on error.
  
  CID 1422581.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

7 files changed, 46 insertions(+), 18 deletions(-)
configure                                        | 42 +++++++++++++++-----
.../kernel/network/stack/device_interfaces.cpp   |  4 +-
src/kits/debugger/elf/ElfFile.cpp                |  1 +
src/kits/midi/MidiSettings.cpp                   |  4 +-
src/kits/network/libnetapi/NetworkAddress.cpp    |  3 +-
src/kits/network/libnetapi/ProxySecureSocket.cpp |  4 +-
src/servers/app/DelayedMessage.cpp               |  6 ++-

############################################################################

Commit:      d73993ff202c77741d8591feee6566f6e342c0fe
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d73993ff202c
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Nov 23 16:29:15 2017 UTC

configure: Fix & enhance --use-clang.

Now you set the arch along with the argument, and specify the binutils
manually (and thus build without a complete crosstools environment.)

----------------------------------------------------------------------------

diff --git a/configure b/configure
index b9228b7..7906ce0 100755
--- a/configure
+++ b/configure
@@ -84,8 +84,8 @@ options:
                               ones the secondary architectures.
   --update                    re-runs last configure invocation [must be given
                               as first option!]
-  --use-clang                 Build with host Clang instead of GCC cross
-                              compiler
+  --use-clang <arch>          Build with host Clang instead of GCC cross
+                              compiler, targeting <arch>
   --use-gcc-pipe              Build with GCC option -pipe. Speeds up the build
                               process, but uses more memory.
   --use-gcc-graphite          Build with GCC Graphite engine for loop
@@ -354,7 +354,13 @@ get_build_tool_path()
 {
        local var="HAIKU_$1"
        local cmd=$2
-       local path=${2%% *}
+
+       if [ ! -z "${!var}" ]; then
+               # this variable is already set (probably by user) so grab its 
contents
+               cmd=${!var}
+       fi
+
+       local path=${cmd%% *}
 
        if [ -f "$path" ]; then
                # get absolute path
@@ -364,7 +370,7 @@ get_build_tool_path()
                cd $oldPwd
        else
                which "$path" > /dev/null 2>&1 || {
-                       echo "Build tool \"$path\" not found." >&2
+                       echo "Build tool \"$path\" not found (maybe specify it 
in $var?)" >&2
                        exit 1
                }
        fi
@@ -599,7 +605,22 @@ while [ $# -gt 0 ] ; do
                        )
                        haikuTargetArchs="$haikuTargetArchs $targetArch"
                        ;;
-               --use-clang) useClang=1; shift 1;;
+               --use-clang)
+                       assertparam "$1" $#
+                       targetArch=$2
+                       useClang=1
+                       case "$targetArch" in
+                               x86)            targetMachine=i586-pc-haiku;;
+                               x86_64)         
targetMachine=x86_64-unknown-haiku;;
+                               *)
+                                       echo "Unsupported target architecture: 
$2" >&2
+                                       exit 1
+                                       ;;
+                       esac
+                       targetArchs="$targetArchs $targetArch"
+                       HAIKU_PACKAGING_ARCHS=
+                       shift 2
+                       ;;
                --use-gcc-pipe) HAIKU_USE_GCC_PIPE=1; shift 1;;
                --use-gcc-graphite)     useGccGraphiteDefault=1; shift 1;;
                --use-32bit)    HAIKU_HOST_USE_32BIT=1; shift 1;;
@@ -774,15 +795,12 @@ else
 
                # prepare gcc settings and get the actual target architecture
                if [ $useClang = 1 ]; then
-                       target=${crossToolsPrefix##*/}
-                       target=${target%-}
-                       gcc="clang -target ${target} -no-integrated-as"
+                       gcc="clang -target ${targetMachine} -no-integrated-as"
+               elif [ -z "${crossToolsPrefix}" ]; then
+                       gcc=`get_variable HAIKU_CC_$targetArch`
                else
                        gcc="${crossToolsPrefix}gcc"
                fi
-               if [ -z "${crossToolsPrefix}" ]; then
-                       gcc=`get_variable HAIKU_CC_$targetArch`
-               fi
                standard_gcc_settings "$gcc"
                targetArch=$standard_gcc_settings_targetArch
 
@@ -930,3 +948,5 @@ HAIKU_OUTPUT_DIR    = ${outputDir} ;
 include [ FDirName \$(HAIKU_TOP) Jamfile ] ;
 
 EOF
+
+echo "Configured successfully!"

############################################################################

Commit:      14fcbb52cd64436c15da23525420f8e2ec469df5
URL:         http://cgit.haiku-os.org/haiku/commit/?id=14fcbb52cd64
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Nov 23 16:32:27 2017 UTC

device_interfaces: Fix memory leak on success.

The module list was closed properly at the end of the function body
(failure case) but not inside the loop on the success case.

CID 605738.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/network/stack/device_interfaces.cpp 
b/src/add-ons/kernel/network/stack/device_interfaces.cpp
index 27dc784..e873d24 100644
--- a/src/add-ons/kernel/network/stack/device_interfaces.cpp
+++ b/src/add-ons/kernel/network/stack/device_interfaces.cpp
@@ -463,8 +463,10 @@ get_device_interface(const char* name, bool create)
                        status_t status = module->init_device(name, &device);
                        if (status == B_OK) {
                                interface = allocate_device_interface(device, 
module);
-                               if (interface != NULL)
+                               if (interface != NULL) {
+                                       close_module_list(cookie);
                                        return interface;
+                               }
 
                                module->uninit_device(device);
                        }

############################################################################

Commit:      75fa008e23849701efd80be8af79e0252918b867
URL:         http://cgit.haiku-os.org/haiku/commit/?id=75fa008e2384
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Nov 23 16:44:44 2017 UTC

BProxySecureSocket: Fix obviously untested code.

 * Actually set status before testing it
 * sscanf (reads from passed buffer) not scanf (reads from stdin)
 * &httpStatus not httpStatus.

Found by Coverity.

----------------------------------------------------------------------------

diff --git a/src/kits/network/libnetapi/ProxySecureSocket.cpp 
b/src/kits/network/libnetapi/ProxySecureSocket.cpp
index 111dbc3..f1b2b49 100644
--- a/src/kits/network/libnetapi/ProxySecureSocket.cpp
+++ b/src/kits/network/libnetapi/ProxySecureSocket.cpp
@@ -47,7 +47,7 @@ BProxySecureSocket::Connect(const BNetworkAddress& peer, 
bigtime_t timeout)
        if (status != B_OK)
                return status;
 
-       BSocket::Connect(fProxyAddress, timeout);
+       status = BSocket::Connect(fProxyAddress, timeout);
        if (status != B_OK)
                return status;
 
@@ -63,7 +63,7 @@ BProxySecureSocket::Connect(const BNetworkAddress& peer, 
bigtime_t timeout)
 
        buffer[length] = '\0';
        int httpStatus = 0;
-       int matches = scanf(buffer, "HTTP/1.0 %d %*[^\r\n]\r\n\r\n", 
httpStatus);
+       int matches = sscanf(buffer, "HTTP/1.0 %d %*[^\r\n]\r\n\r\n", 
&httpStatus);
        if (matches != 2)
                return B_BAD_DATA;
 

############################################################################

Commit:      7131246873bb76348fd0190427795983e3a12e9b
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7131246873bb
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Nov 23 16:53:06 2017 UTC

BNetworkAddress: Close socket in ResolveForDestination.

It was closed on all the failure cases but not on the success one.
Found by Coverity.

----------------------------------------------------------------------------

diff --git a/src/kits/network/libnetapi/NetworkAddress.cpp 
b/src/kits/network/libnetapi/NetworkAddress.cpp
index 2bfbcd1..7eaf5a1 100644
--- a/src/kits/network/libnetapi/NetworkAddress.cpp
+++ b/src/kits/network/libnetapi/NetworkAddress.cpp
@@ -963,6 +963,7 @@ BNetworkAddress::ResolveForDestination(const 
BNetworkAddress& destination)
        memcpy(&fAddress, route->source, sizeof(sockaddr_storage));
        SetPort(port);
 
+       close(socket);
        return B_OK;
 }
 
@@ -1293,7 +1294,7 @@ BNetworkAddress::_ParseLinkAddress(const char* address)
 
                address += 3;
        }
-       
+
        fHostName = address;
 
        SetToLinkLevel(linkAddress, length);

############################################################################

Commit:      d692d22c9d604cdc1b902331a4a44958e0ab182b
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d692d22c9d60
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Nov 23 17:09:17 2017 UTC

debugger/elf: Don't leak memory in failure case.

CID 1423098.

----------------------------------------------------------------------------

diff --git a/src/kits/debugger/elf/ElfFile.cpp 
b/src/kits/debugger/elf/ElfFile.cpp
index 9cbe381..9b2e413 100644
--- a/src/kits/debugger/elf/ElfFile.cpp
+++ b/src/kits/debugger/elf/ElfFile.cpp
@@ -335,6 +335,7 @@ ElfFile::CreateSymbolLookupSource(uint64 fileOffset, uint64 
fileLength,
        SymbolLookupSource* source = new(std::nothrow) SymbolLookupSource(fFD);
        if (source == NULL
                        || !source->AddSegment(fileOffset, fileLength, 
memoryAddress)) {
+               delete source;
                return NULL;
        }
 

############################################################################

Commit:      a20f4f8a8511cd1bdba8ef53c95564b242ac30a1
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a20f4f8a8511
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Nov 23 17:12:54 2017 UTC

MidiSettings: Don't leak settings in failure case.

CID 1422944.

----------------------------------------------------------------------------

diff --git a/src/kits/midi/MidiSettings.cpp b/src/kits/midi/MidiSettings.cpp
index bc62f90..508ef63 100644
--- a/src/kits/midi/MidiSettings.cpp
+++ b/src/kits/midi/MidiSettings.cpp
@@ -37,8 +37,10 @@ read_midi_settings(struct midi_settings* settings)
 
        const char* soundfont = get_driver_parameter(handle, "soundfont", NULL,
                NULL);
-       if (soundfont == NULL)
+       if (soundfont == NULL) {
+               unload_driver_settings(handle);
                return B_ERROR;
+       }
        strlcpy(settings->soundfont_file, soundfont,
                sizeof(settings->soundfont_file));
 

############################################################################

Revision:    hrev51610
Commit:      14d690378fbdeaba2b940f31d07f95ef861921a3
URL:         http://cgit.haiku-os.org/haiku/commit/?id=14d690378fbd
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Nov 23 17:49:26 2017 UTC

app_server/DelayedMessage: Delete scheduled on error.

CID 1422581.

----------------------------------------------------------------------------

diff --git a/src/servers/app/DelayedMessage.cpp 
b/src/servers/app/DelayedMessage.cpp
index dd8139d..634fda6 100644
--- a/src/servers/app/DelayedMessage.cpp
+++ b/src/servers/app/DelayedMessage.cpp
@@ -569,7 +569,7 @@ ScheduledMessage::SendMessage()
        for (int32 index = 0; index < fData->Targets().CountItems(); ++index) {
                port_id port = *(fData->Targets().ItemAt(index));
                status_t error = SendMessageToPort(port);
-               
+
                if (error == B_OK) {
                        ++sent;
                        continue;
@@ -706,8 +706,10 @@ DelayedMessageSender::ScheduleMessage(DelayedMessage& 
message)
        if (scheduled == NULL)
                return B_NO_MEMORY;
 
-       if (!scheduled->IsValid())
+       if (!scheduled->IsValid()) {
+               delete scheduled;
                return B_BAD_DATA;
+       }
 
        if (fMessages.AddItem(scheduled)) {
                fMessages.SortItems(&CompareMessages);


Other related posts:

  • » [haiku-commits] haiku: hrev51610 - in src: kits/network/libnetapi add-ons/kernel/network/stack kits/midi servers/app - waddlesplash