star/SOURCES/star-1.5-changewarnSegv.patch

81 lines
1.8 KiB
Diff
Raw Permalink Normal View History

2019-08-02 12:47:41 +00:00
--- star-1.5/star/checkerr.c.orig-segv 2006-10-31 18:06:25.000000000 +0100
+++ star-1.5/star/checkerr.c 2007-08-27 11:42:39.000000000 +0200
@@ -183,39 +183,45 @@ LOCAL struct eflags {
*/
LOCAL UInt32_t
errflags(eflag, doexit)
- char *eflag;
- BOOL doexit;
+ char *eflag;
+ BOOL doexit;
{
- register char *p = eflag;
- char *ef = _endword(eflag);
- register struct eflags *ep;
- register int slen;
- register UInt32_t nflags = 0;
-
- do {
- for (ep = eflags; ep->fname; ep++) {
- slen = strlen(ep->fname);
- if ((strncmp(ep->fname, p, slen) == 0) &&
- (p[slen] == '|' || p[slen] == ' ' ||
- p[slen] == '\0')) {
- nflags |= ep->fval;
- break;
- }
- }
- if (ep->fname == NULL) {
- if (doexit)
- comerrno(EX_BAD, "Bad flag '%s'\n", p);
- return (0);
- }
- p = strchr(p, '|');
- } while (p < ef && p && *p++ == '|');
-
- if ((nflags & ~(UInt32_t)(E_ABORT|E_WARN)) == 0) {
- if (doexit)
- comerrno(EX_BAD, "Bad error condition '%s'.\n", eflag);
- return (0);
- }
- return (nflags);
+ register struct eflags *ep;
+ register int slen;
+ register UInt32_t nflags = 0;
+ char *curflags;
+ char *curflag;
+
+ curflags = strdup (eflag);
+ *_endword(curflags) = '\0';
+ curflag = strtok (curflags, "|");
+
+ while (curflag != NULL) {
+ for (ep = eflags; ep->fname; ep++) {
+ slen = strlen (ep->fname);
+ if ((strncmp (ep->fname, curflag, slen)) == 0) {
+ nflags |= ep->fval;
+ goto next;
+ }
+ }
+
+ if (doexit)
+ comerrno (EX_BAD, "Bad flag '%s' \n", curflag);
+
+ free (curflags);
+ return (0);
+ next:
+ curflag = strtok (NULL, "|");
+ }
+
+ free (curflags);
+
+ if ((nflags & ~(UInt32_t)(E_ABORT|E_WARN)) == 0) {
+ if (doexit)
+ comerrno(EX_BAD, "Bad error condition '%s'.\n", eflag);
+ return (0);
+ }
+ return (nflags);
}
LOCAL ec_t *