1.1 --- a/plover/comps.c Fri Jun 01 15:26:27 2018 +0100
1.2 +++ b/plover/comps.c Fri Jun 01 17:19:01 2018 +0100
1.3 @@ -390,6 +390,7 @@
1.4 void *contents;
1.5 size_t length;
1.6 struct comps *comps;
1.7 + g_return_val_if_fail(plover__uri_validate(uri),NULL);
1.8 plover__uri_handler_init();
1.9 contents=razor_uri_get_contents(uri,&length,FALSE,&tmp_error);
1.10 if (!contents)
2.1 --- a/plover/import-yum.c Fri Jun 01 15:26:27 2018 +0100
2.2 +++ b/plover/import-yum.c Fri Jun 01 17:19:01 2018 +0100
2.3 @@ -347,6 +347,7 @@
2.4 struct razor_package *pkg;
2.5 PloverPackageSet *set;
2.6 PloverRepository *repository;
2.7 + g_return_val_if_fail(plover__uri_validate(base_uri),NULL);
2.8 plover__uri_handler_init();
2.9 ctx.importer=razor_importer_create();
2.10 ctx.state=YUM_STATE_BEGIN;
2.11 @@ -461,6 +462,7 @@
2.12 PloverRepository *repository;
2.13 PloverPackageSet *set;
2.14 struct razor_set *razor;
2.15 + g_return_val_if_fail(plover__uri_validate(base_uri),NULL);
2.16 repository=plover_repository_new_from_yum_uri(base_uri,error);
2.17 if (!repository)
2.18 return NULL;
3.1 --- a/plover/inputstream.c Fri Jun 01 15:26:27 2018 +0100
3.2 +++ b/plover/inputstream.c Fri Jun 01 17:19:01 2018 +0100
3.3 @@ -139,7 +139,7 @@
3.4 struct razor_error *tmp_error=NULL;
3.5 GInputStream *stream;
3.6 PloverRazorInputStreamPrivate *priv;
3.7 - g_return_if_fail(uri!=NULL);
3.8 + g_return_val_if_fail(plover__uri_validate(uri),NULL);
3.9 buf=razor_uri_get_contents(uri,&len,FALSE,&tmp_error);
3.10 if (!buf)
3.11 {
4.1 --- a/plover/packageset.c Fri Jun 01 15:26:27 2018 +0100
4.2 +++ b/plover/packageset.c Fri Jun 01 17:19:01 2018 +0100
4.3 @@ -128,6 +128,7 @@
4.4 PloverPackageSetPrivate *priv;
4.5 struct razor_error *error=NULL;
4.6 g_return_val_if_fail(PLOVER_IS_PACKAGE_SET(set),FALSE);
4.7 + g_return_val_if_fail(plover__uri_validate(root_uri),FALSE);
4.8 if (exclusive)
4.9 {
4.10 root=razor_root_open(root_uri,NULL);
5.1 --- a/plover/plover.h Fri Jun 01 15:26:27 2018 +0100
5.2 +++ b/plover/plover.h Fri Jun 01 17:19:01 2018 +0100
5.3 @@ -120,6 +120,8 @@
5.4 char *plover_vector_format_for_display(struct plover_vector *vector);
5.5 void plover_vector_free(struct plover_vector *vector);
5.6
5.7 +gboolean plover__uri_validate(const char *uri);
5.8 +
5.9 G_END_DECLS
5.10
5.11 #endif /* __PLOVER_H__ */
6.1 --- a/plover/razor.c Fri Jun 01 15:26:27 2018 +0100
6.2 +++ b/plover/razor.c Fri Jun 01 17:19:01 2018 +0100
6.3 @@ -67,6 +67,7 @@
6.4 int r,count;
6.5 GError *tmp_error=NULL;
6.6 PloverPackage *package;
6.7 + g_return_val_if_fail(plover__uri_validate(root_uri),-1);
6.8 plover__uri_handler_init();
6.9 if (!*root_uri)
6.10 root_uri="file:/";
6.11 @@ -176,6 +177,7 @@
6.12 {
6.13 gboolean retval;
6.14 PloverTransaction *transaction;
6.15 + g_return_val_if_fail(plover__uri_validate(base_uri),FALSE);
6.16 transaction=plover_transaction_new_install_uri(base_uri,prefix,pkgs,error);
6.17 if (!transaction)
6.18 return FALSE;
6.19 @@ -203,6 +205,7 @@
6.20 {
6.21 gboolean retval;
6.22 PloverTransaction *transaction;
6.23 + g_return_val_if_fail(plover__uri_validate(base_uri),FALSE);
6.24 transaction=plover_transaction_new_update_uri(base_uri,prefix,pkgs,error);
6.25 if (!transaction)
6.26 return FALSE;
6.27 @@ -418,6 +421,7 @@
6.28 static struct razor_set *(*next)(const char *uri,enum razor_set_flags flags,
6.29 struct razor_error **error);
6.30 struct razor_set *set;
6.31 + g_return_val_if_fail(plover__uri_validate(uri),NULL);
6.32 if (!next)
6.33 next=dlsym(RTLD_NEXT,"razor_set_open");
6.34 set=(*next)(uri,flags,error);
6.35 @@ -486,6 +490,7 @@
6.36 static struct razor_set *(*next)(const char *root_uri,
6.37 struct razor_error **error);
6.38 struct razor_set *set;
6.39 + g_return_val_if_fail(plover__uri_validate(root_uri),NULL);
6.40 if (!next)
6.41 next=dlsym(RTLD_NEXT,"razor_root_open_read_only");
6.42 set=(*next)(root_uri,error);
7.1 --- a/plover/transaction.c Fri Jun 01 15:26:27 2018 +0100
7.2 +++ b/plover/transaction.c Fri Jun 01 17:19:01 2018 +0100
7.3 @@ -487,6 +487,7 @@
7.4 PloverRepository *upstream;
7.5 g_return_val_if_fail(PLOVER_IS_TRANSACTION(transaction),FALSE);
7.6 g_return_val_if_fail(transaction->upstream == NULL,FALSE);
7.7 + g_return_val_if_fail(plover__uri_validate(base_uri),FALSE);
7.8 upstream=plover_repository_new_from_yum_uri(base_uri,error);
7.9 if (!upstream)
7.10 return FALSE;
7.11 @@ -584,6 +585,7 @@
7.12 const char *prefix,char **pkgs,GError **error)
7.13 {
7.14 PloverTransaction *transaction;
7.15 + g_return_val_if_fail(plover__uri_validate(base_uri),NULL);
7.16 transaction=plover_transaction_new();
7.17 plover_transaction_set_prefix(transaction,prefix);
7.18 if (!plover_transaction_set_upstream_from_yum_uri(transaction,base_uri,error))
7.19 @@ -617,6 +619,7 @@
7.20 const char *prefix,char **pkgs,GError **error)
7.21 {
7.22 PloverTransaction *transaction;
7.23 + g_return_val_if_fail(plover__uri_validate(base_uri),NULL);
7.24 transaction=plover_transaction_new();
7.25 plover_transaction_set_prefix(transaction,prefix);
7.26 if (!plover_transaction_set_upstream_from_yum_uri(transaction,base_uri,
8.1 --- a/plover/util.c Fri Jun 01 15:26:27 2018 +0100
8.2 +++ b/plover/util.c Fri Jun 01 17:19:01 2018 +0100
8.3 @@ -356,3 +356,11 @@
8.4 }
8.5 g_error_free(src);
8.6 }
8.7 +
8.8 +gboolean plover__uri_validate(const char *uri)
8.9 +{
8.10 + char *s;
8.11 + s=razor_path_relative_to_uri(uri,".",NULL);
8.12 + free(s);
8.13 + return !!s;
8.14 +}