From: bogglez <bo...@us...> - 2017-03-09 18:33:54
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via e1425c7a621053c0af826599bfb90e85e0d78af9 (commit) from 96cfa4a954205e87519f502222f0ae95192c5521 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e1425c7a621053c0af826599bfb90e85e0d78af9 Author: bogglez <bo...@pr...> Date: Thu Mar 9 19:26:35 2017 +0100 genromfs: check readlink return value ----------------------------------------------------------------------- Summary of changes: utils/genromfs/genromfs.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/utils/genromfs/genromfs.c b/utils/genromfs/genromfs.c index 5cfda66..702c9d3 100644 --- a/utils/genromfs/genromfs.c +++ b/utils/genromfs/genromfs.c @@ -320,7 +320,7 @@ void dumpri(struct romfh *ri, struct filenode *n, FILE *f) { #endif } -void dumpnode(struct filenode *node, FILE *f) { +int dumpnode(struct filenode *node, FILE *f) { struct romfh ri; struct filenode *p; @@ -362,7 +362,9 @@ void dumpnode(struct filenode *node, FILE *f) { ri.nextfh |= htonl(ROMFH_LNK); dumpri(&ri, node, f); memset(bigbuf, 0, sizeof(bigbuf)); - readlink(node->realname, bigbuf, node->size); + if(readlink(node->realname, bigbuf, node->size) < 0) { + return 1; + } dumpdataa(bigbuf, node->size, f); } else if(S_ISREG(node->modes)) { @@ -424,12 +426,16 @@ void dumpnode(struct filenode *node, FILE *f) { p = node->dirlist.head; while(p->next) { - dumpnode(p, f); + if(dumpnode(p, f)) { + return 1; + } p = p->next; } + + return 0; } -void dumpall(struct filenode *node, int lastoff, FILE *f) { +int dumpall(struct filenode *node, int lastoff, FILE *f) { struct romfh ri; struct filenode *p; @@ -441,13 +447,17 @@ void dumpall(struct filenode *node, int lastoff, FILE *f) { p = node->dirlist.head; while(p->next) { - dumpnode(p, f); + if(dumpnode(p, f)) { + return 1; + } p = p->next; } /* Align the whole bunch to ROMBSIZE boundary */ if(lastoff & 1023) dumpzero(1024 - (lastoff & 1023), f); + + return 0; } /* Node manipulating functions */ @@ -634,7 +644,9 @@ int processdir(int level, const char *base, const char *dirname, struct stat *sb /* this is a link to follow at build time */ n->name = n->name + 1; /* strip off the leading @ */ memset(bigbuf, 0, sizeof(bigbuf)); - readlink(n->realname, bigbuf, sizeof(bigbuf)); + if(readlink(n->realname, bigbuf, sizeof(bigbuf))) { + return -1; + } n->realname = strdup(bigbuf); if(lstat(n->realname, sb)) { @@ -735,6 +747,9 @@ int processdir(int level, const char *base, const char *dirname, struct stat *sb curroffset = processdir(level + 1, n->realname, dp->d_name, sb, n, root, curroffset); } + + if(curroffset < 0) + return -1; } } @@ -876,11 +891,18 @@ int main(int argc, char *argv[]) { root = newnode(dir, volname, 0); root->parent = root; lastoff = processdir(1, dir, dir, &sb, root, root, spaceneeded(root)); + if(lastoff < 0) { + fprintf(stderr, "Error while processing directory.\n"); + return 1; + } if(verbose) shownode(0, root, stderr); - dumpall(root, lastoff, f); + if(dumpall(root, lastoff, f)) { + fprintf(stderr, "Error while dumping!\n"); + return 1; + } - exit(0); + return ret; } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |