static int parse_expression_list(char *str) { int start=0, i=-1, j=-1; char str2[2]; if (!str) return -1; do { i++; switch(str[i]) { case 0: while ((str[start] == ' ') || (str[start] == '\t')) start++; if (str[start] == '"') start++; j = i-1; while ((0 < j) && ((str[j] == ' ') || (str[j] == '\t'))) j--; if ((0 < j) && (str[j] == '"')) j--; if (start<=j) { if (j-start+1>=2) { return -1; } r_strncpy(str2, str+start, j-start+1); str2[j-start+1] = 0; } else { return -1; } start = i+1; } } while (str[i] != 0); return 0; }
static void nslookupComplain(const char *sysloginfo, const char *net_queryname, const char *complaint, const char *net_dname, const struct databuf *a_rr, const struct databuf *nsdp) { char queryname[INSZ+1], dname[INSZ+1]; const char *a, *ns; const char *a_type; int print_a; strncpy(queryname, net_queryname, sizeof queryname); queryname[(sizeof queryname) - 1] = EOS; strncpy(dname, net_dname, sizeof dname); dname[(sizeof dname) - 1] = EOS; if (sysloginfo && queryname && !haveComplained(queryname, complaint)) { char buf[BUFSZ]; a = ns = (char *)NULL; print_a = (a_rr->d_type == T_A); a_type = p_type(a_rr->d_type); /* OK */ r_strncpy (buf, sysloginfo, BUFSZ); } }
long rex_compiler_setblanks(rexcompiler_t *co, const char *str, unsigned int size) { if (size + 1 > sizeof(co->blankchars)) return -1; r_memset(co->blankchars, 0, sizeof(co->blankchars)); r_strncpy(co->blankchars, str, sizeof(co->blankchars) - 1); return 0; }
static int parse_expression_list(char *str) { int start=0, i=-1, j=-1, apost=0; char str2[EXPRESSION_LENGTH]; if (!str) return -1; do { /* i only changes here --> it's the "current character" */ i++; switch(str[i]) { case '"': apost = !apost; break; /* Comman and NULL are both word terminators, stop parsing if your word terminator is a NULL. */ case ',': if (apost) break; case EOS: /* word found */ /* Skip initial whitespace from start of the word being processed */ while ((str[start] == ' ') || (str[start] == '\t')) start++; /* Skip quote marks */ if (str[start] == '"') start++; /* Set j to point to the end of the current word */ j = i-1; /* Skip over quotes and whitespace at the END of the word */ while ((0 < j) && ((str[j] == ' ') || (str[j] == '\t'))) j--; if ((0 < j) && (str[j] == '"')) j--; /* If word not empty.... */ if (start<=j) { /* valid word */ if (j-start+1>=EXPRESSION_LENGTH) { return -1; } /* OK */ //assert (j-start+1 < EXPRESSION_LENGTH); r_strncpy(str2, str+start, j-start+1); /* OK */ str2[j-start+1] = EOS; } else { /* parsing error */ return -1; } /* for the next word */ start = i+1; } } while (str[i] != EOS); return 0; }
rexcompiler_t *rex_compiler_create() { rexcompiler_t *co; co = (rexcompiler_t *)r_malloc(sizeof(*co)); r_memset(co, 0, sizeof(*co)); r_strncpy(co->blankchars, " \t", sizeof(co->blankchars) - 1); co->stack = r_array_create(sizeof(rexfragment_t*)); co->temptrans = r_array_create(sizeof(rex_transition_t)); return co; }
int main () { struct sockaddr_un serv_adr; char filename [FILENAME_SZ]; /* server filename */ filename[FILENAME_SZ-1] = EOS; /* initialize the server address structure */ /* OK */ r_strncpy (serv_adr.sun_path, filename, SUN_PATH_SZ-1); return 0; }
static int parse_expression_list(char *str) { int start=0, i=-1, j=-1; char str2[EXPRESSION_LENGTH]; if (!str) return -1; do { /* i only changes here --> it's the "current character" */ i++; switch(str[i]) { case EOS: /* word found */ /* Skip initial whitespace from start of the word being processed */ while ((str[start] == ' ') || (str[start] == '\t')) start++; /* Skip quote marks */ if (str[start] == '"') start++; /* Set j to point to the end of the current word */ j = i-1; /* Skip over quotes and whitespace at the END of the word */ while ((0 < j) && ((str[j] == ' ') || (str[j] == '\t'))) j--; if ((0 < j) && (str[j] == '"')) j--; /* If word not empty.... */ if (start<=j) { /* valid word */ /* BAD */ r_strncpy(str2, str+start, j-start+1); __VERIFIER_assert(j - start + 1 < 2); str2[j-start+1] = EOS; } else { /* parsing error */ return -1; } /* for the next word */ start = i+1; } } while (str[i] != EOS); return 0; }
void ftpls (char *line) { int j; /* Stop at either: * (1) first char before EOS which isn't in "-rwxdls", or, * (2) first EOS */ for(j = 0; line[j] != EOS; ++j) if (!strchr("-", line[j])) break; if(j == J && line[j] == ' ') { /* long list */ char user[USERSZ]; /* OK */ r_strncpy (user, line + j, USERSZ); } }
char * realpath(const char *pathname, char *result, char* chroot_path) { char curpath[MAXPATHLEN]; if (result == NULL) return(NULL); if(pathname == NULL){ *result = EOS; return(NULL); } /* OK */ r_strncpy(curpath, pathname, MAXPATHLEN); return result; }
long rpa_compiler_addblob(rpa_compiler_t *co, long ruleid, long ruleuid, unsigned long flags, const char *name, unsigned long namesize) { char blob[RPA_RULEBLOB_SIZE]; char *ptr; rpa_ruledata_t *pblob = (rpa_ruledata_t *)blob; if (namesize >= RPA_RULENAME_MAXSIZE) return -1; r_memset(pblob, 0, RPA_RULEBLOB_SIZE); ptr = blob + sizeof(rpa_ruledata_t); pblob->name = (unsigned long)(ptr - blob); pblob->ruleid = ruleid; pblob->ruleuid = ruleuid; pblob->flags = flags; pblob->namesize = namesize; r_strncpy(ptr, name, namesize); ptr += namesize; pblob->size = (long)(ptr - blob + 1); return rvm_codegen_adddata_s(co->cg, NULL, pblob, pblob->size); }
static int parse_expression_list(char *str) { int start=0, i=-1, j=-1, apost=0; char str2[EXPRESSION_LENGTH]; if (!str) return -1; do { /* i only changes here --> it's the "current character" */ i++; switch(str[i]) { /* Comman and NULL are both word terminators, stop parsing if your word terminator is a NULL. */ case ',': case EOS: /* word found */ /* Set j to point to the end of the current word */ j = i-1; /* Skip over quotes and whitespace at the END of the word */ while ((0 < j) && ((str[j] == ' '))) j--; /* If word not empty.... */ if (start<=j) { /* valid word */ /* BAD */ r_strncpy(str2, str+start, j-start+1); str2[j-start+1] = EOS; } else { /* parsing error */ return -1; } /* for the next word */ start = i+1; } } while (str[i] != EOS); return 0; }
static int parse_expression_list(char *str) { int start=0, i=-1, j=-1; char str2[EXPRESSION_LENGTH]; if (!str) return -1; do { /* i only changes here --> it's the "current character" */ i++; switch(str[i]) { case EOS: /* word found */ /* Skip initial whitespace from start of the word being processed */ while ((str[start] == ' ')) start++; /* Set j to point to the end of the current word */ j = i-1; /* If word not empty.... */ if (start<=j) { /* valid word */ if (j-start+1>=EXPRESSION_LENGTH) { return -1; } /* OK */ r_strncpy(str2, str+start, j-start+1); str2[j-start+1] = EOS; } else { /* parsing error */ return -1; } /* for the next word */ start = i+1; } } while (str[i] != EOS); return 0; }
int main (void) { // these were parameters char login[LOGIN + 1]; char gecos[GECOS + 1]; char buf[BUF + 1]; char c; int i, j; int p, l; login[(int) (sizeof login - 1)] = EOS; gecos[(int) (sizeof gecos - 1)] = EOS; i = 0; if (gecos[i] == '*') i++; /* find length of final string */ l = 0; p = i; c = gecos[p]; while (c != EOS && c != ',' && c != ';' && c != '%') { if (c == '&') l += strlen(login); else l++; p++; c = gecos[p]; } /* bail out early if we'd overflow buf[] */ if (l > BUF) return 0; c = gecos[i]; j = 0; while (c != EOS && c != ',' && c != ';' && c != '%') { if (c == '&') { /* OK */ (void) r_strncpy (buf + j, login, sizeof (buf) - j); buf[sizeof(buf)-1] = EOS; while (buf[j] != EOS) j++; } else { /* OK */ buf[j] = c; j++; } i++; c = gecos[i]; } buf[j] = EOS; return 0; }