tCheck path before loading package - pm - barely a pack manager
HTML git clone git://z3bra.org/pm
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 4cddf9af68b6e22c51621a9c04159a266f23adc5
DIR parent 1e9efd313217ed16e878585b1b9bb927e3dd9f79
HTML Author: z3bra <willyatmailoodotorg>
Date: Wed, 30 Dec 2015 12:11:16 +0100
Check path before loading package
Diffstat:
M pm.c | 8 ++++++++
1 file changed, 8 insertions(+), 0 deletions(-)
---
DIR diff --git a/pm.c b/pm.c
t@@ -277,10 +277,18 @@ unpack(char *root, char *in)
struct pkg *
pack_load_file(char *path)
{
+ int fd;
struct pkg *pack = malloc(sizeof(struct pkg));
char tmp[PATH_MAX];
char *p;
+ if ((fd = open(path, O_RDONLY)) < 0) {
+ perror("open");
+ free(pack);
+ return NULL;
+ }
+ close(fd);
+
pack->path = strdup(path);
snprintf(tmp, PATH_MAX, "%s", base_name(path));