discover/pxe: Fix prefix autodetection when bootfile is in the root dir
[petitboot] / discover / user-event.c
index 1e366ee387c6cad138998c2686d6ae0ef0832a51..cf7f20c599bbefdac3c004834dc75966500a7a4b 100644 (file)
@@ -290,8 +290,9 @@ struct pb_url *user_event_parse_conf_url(struct discover_context *ctx,
                /* strip filename from the bootfile path, leaving only a
                 * directory */
                p = strrchr(basedir, '/');
-               if (p)
-                       *p = '\0';
+               if (!p)
+                       p = basedir;
+               *p = '\0';
 
                if (strlen(basedir))
                        url_str = talloc_asprintf_append(url_str, "%s/",