Added check for failed memory allocation. Set binary to output to the master
authorDavid Llewellyn-Jones <david@flypig.co.uk>
Mon, 24 Mar 2014 22:50:59 +0000 (22:50 +0000)
committerDavid Llewellyn-Jones <david@flypig.co.uk>
Mon, 24 Mar 2014 22:50:59 +0000 (22:50 +0000)
OpenVPNUI project.

main.c
ovpnpermit.pro
ovpnpermit.pro.user

diff --git a/main.c b/main.c
index 0a133b2..cce28db 100644 (file)
--- a/main.c
+++ b/main.c
@@ -13,23 +13,29 @@ int main (int argc, char *argv[]) {
     char ** newargv = malloc (sizeof(char*) * (argc + 1));
     int arg;
 
-    // Transfer the arguments passed in to a new argument array
-    for (arg = 0; arg < argc; arg++) {
-        newargv[arg] = argv[arg];
-    }
-    // Ensure the argument list is NULL terminated (for execvp)
-    newargv[argc] = NULL;
-    // Ensure the first argument matches the command
-    newargv[0] = command;
+    if (newargv != NULL) {
+        // Transfer the arguments passed in to a new argument array
+        for (arg = 0; arg < argc; arg++) {
+            newargv[arg] = argv[arg];
+        }
+        // Ensure the argument list is NULL terminated (for execvp)
+        newargv[argc] = NULL;
+        // Ensure the first argument matches the command
+        newargv[0] = command;
 
-    // Execute the external command
-    //setuid (0);
-    execvp (command, newargv);
+        // Execute the external command
+        //setuid (0);
+        execvp (command, newargv);
 
-    // This part of the code shouldn't be reached
-    printf ("Error executing openvpn\n");
+        // This part of the code shouldn't be reached unless there was a problem
+        fprintf (stderr, "Error executing openvpn\n");
 
-    free (newargv);
+        free (newargv);
+    }
+    else {
+        // There was a problem with thee malloc call
+        fprintf (stderr, "Error allocating memory for command argument list\n");
+    }
     return 0;
 }
 
index 34f0471..bef83d2 100644 (file)
@@ -5,3 +5,9 @@ CONFIG -= qt
 
 SOURCES += main.c
 
+CONFIG(debug, debug|release) {
+    DESTDIR = ..\openvpnui\bin
+}
+else {
+    DESTDIR = ..\openvpnui\bin
+}
index 64ec0c7..3d476c9 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 2.8.1, 2014-03-19T23:39:54. -->
+<!-- Written by QtCreator 2.8.1, 2014-03-24T11:19:30. -->
 <qtcreator>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -53,9 +53,9 @@
   <valuemap type="QVariantMap">
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MerSDK-SailfishOS-armv7hl</value>
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">MerSDK-SailfishOS-armv7hl</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{d509da11-0d11-4fad-8b14-f7a950fad5bf}</value>
-   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
-   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">2</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{d2cef3cf-98e6-437c-a097-b7f269d12d9c}</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">1</value>
    <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
     <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
-    <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/flypig/Documents/Development/SailfishOS/ovpnui/build-ovpnpermit-MerSDK_SailfishOS_armv7hl-Debug</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/flypig/Documents/Development/SailfishOS/build-ovpnpermit-MerSDK_SailfishOS_armv7hl-Debug</value>
     <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
    </valuemap>
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
     <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
-    <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/flypig/Documents/Development/SailfishOS/ovpnui/build-ovpnpermit-MerSDK_SailfishOS_armv7hl-Release</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/flypig/Documents/Development/SailfishOS/build-ovpnpermit-MerSDK_SailfishOS_armv7hl-Release</value>
     <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
    </valuemap>
    <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
     </valuelist>
     <value type="int" key="PE.EnvironmentAspect.Base">1</value>
     <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">ovpnpermit (on Mer Device)</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">ovpnpermit (on Remote Device)</value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MerRunConfiguration:/home/flypig/Documents/Development/SailfishOS/ovpnui/ovpnpermit/ovpnpermit.pro</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MerRunConfiguration:/home/flypig/Documents/Development/SailfishOS/ovpnpermit/ovpnpermit.pro</value>
     <value type="QString" key="Qt4ProjectManager.MaemoRunConfiguration.Arguments"></value>
     <value type="QString" key="Qt4ProjectManager.MaemoRunConfiguration.ProFile">ovpnpermit.pro</value>
     <value type="QString" key="RemoteLinux.RunConfig.AlternateRemoteExecutable"></value>
  </data>
  <data>
   <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
-  <value type="QByteArray">{551e7bc8-ec93-459f-bb3a-08a2bffda2a5}</value>
+  <value type="QByteArray">{345860fb-8510-4b40-bec6-87a56aacf929}</value>
  </data>
  <data>
   <variable>ProjectExplorer.Project.Updater.FileVersion</variable>