[PATCH] Allocate memory for login and password and do not meddle with host pointer so we can correctly free it (#483818)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 loader/kickstart.c  |   10 ++++++++--
 loader/urlinstall.c |    5 ++---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/loader/kickstart.c b/loader/kickstart.c
index 3441611..da33605 100644
--- a/loader/kickstart.c
+++ b/loader/kickstart.c
@@ -303,8 +303,10 @@ int getKickstartFromBlockDevice(char *device, char *path) {
 
 void getHostPathandLogin(char * ksSource, char **host, char ** file, char ** login, char ** password, char * ip) {
     char *tmp;
+    char *hostsrc;
 
-    *host = strdup(ksSource);
+    hostsrc = strdup(ksSource);
+    *host = hostsrc;
     tmp = strchr(*host, '/');
 
     if (tmp) {
@@ -341,12 +343,16 @@ void getHostPathandLogin(char * ksSource, char **host, char ** file, char ** log
 
         tmp = strchr(*login, ':');
         if (tmp != NULL) {
-            *password = tmp + 1;
+            *password = strdup(tmp + 1);
             *tmp = '\0';
         } else {
             *password = malloc(sizeof(char *));
             **password = '\0';
         }
+
+	*host = strdup(*host);
+	*login = strdup(*login);
+	free(hostsrc);
     } else {
         *login = malloc(sizeof(char *));
         **login = '\0';
diff --git a/loader/urlinstall.c b/loader/urlinstall.c
index 2dfc627..392dbd1 100644
--- a/loader/urlinstall.c
+++ b/loader/urlinstall.c
@@ -314,9 +314,8 @@ int getFileFromUrl(char * url, char * dest,
     } else {
         *chptr = '\0';
         ui.address = strdup(host);
-        host = chptr;
-        *host = '/';
-        ui.prefix = strdup(host);
+        *chptr = '/';
+        ui.prefix = strdup(chptr);
     }
 
     if (password[0] != '\0')
-- 
1.6.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux