diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2018-09-27 11:43:02 +0200 |
---|---|---|
committer | Dimitri Staessens <dimitri.staessens@ugent.be> | 2018-09-28 11:02:44 +0200 |
commit | 937f2b345aa76272a1c80828e7666ab87611c0d1 (patch) | |
tree | 7075a29558228d12b385ffaa488fe96b93e2584c /src/lib/irm.c | |
parent | 656d1ffc2abdec309cd892b54b310da30fa08095 (diff) | |
download | ouroboros-937f2b345aa76272a1c80828e7666ab87611c0d1.tar.gz ouroboros-937f2b345aa76272a1c80828e7666ab87611c0d1.zip |
lib: Check return values init functions
This will check the return values of init functions so that the code
is more robust. It also removes a duplicate init in the timerwheel,
checks for buffer overflows in the RIB and checks string lengths.
Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be>
Diffstat (limited to 'src/lib/irm.c')
-rw-r--r-- | src/lib/irm.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/irm.c b/src/lib/irm.c index bd34669f..d88475c4 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -319,10 +319,10 @@ static int check_prog(const char * prog) static int check_prog_path(char ** prog) { - char * path = getenv("PATH"); - char * path_end = path + strlen(path) + 1; + char * path; + char * path_end; char * pstart; - char * pstop = path; + char * pstop; char * tmp; char * tstop; char * tstart; @@ -331,9 +331,15 @@ static int check_prog_path(char ** prog) assert(prog); - if (*prog == NULL || path == NULL) + if (*prog == NULL) return -EINVAL; + path = getenv("PATH"); + if (path == NULL) + return -ENOENT; + + pstop = path; + path_end = path + strlen(path) + 1; if (!strlen(path) || strchr(*prog, '/') != NULL) { if ((ret = check_prog(*prog)) < 0) return ret; |