Changeset 1040


Ignore:
Timestamp:
01/02/10 23:23:32 (12 years ago)
Author:
alno
Message:

WebIf:

  • fix - it's not longer possible to add a user with empty name THX@ Admin
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/monitor-improvement/oscam-http.c

    r1039 r1040  
    450450void send_oscam_user_config_edit(struct templatevars *vars, FILE *f, struct uriparams *params){
    451451    struct s_auth *account, *ptr;
    452     char *user;
    453 
    454     if (strcmp(getParam(params, "action"), "Save As") == 0) user = getParam(params, "newuser");
    455     else user = getParam(params, "user");
     452    char user[128];
     453
     454    if (strcmp(getParam(params, "action"), "Save As") == 0) strncpy(user, getParam(params, "newuser"), sizeof(user)/sizeof(char) - 1);
     455    else strncpy(user, getParam(params, "user"), sizeof(user)/sizeof(char) - 1);
     456    user[sizeof(user)/sizeof(char) - 1] = '\0';
    456457
    457458    int i, j;
     
    461462    // Create a new user if it doesn't yet
    462463    if (account == NULL){
     464        i = 1;
     465        while(strlen(user) < 1){
     466            snprintf(user, sizeof(user)/sizeof(char) - 1, "NEWUSER%d", i);
     467            for (account = cfg->account; account != NULL && strcmp(user, account->usr) != 0; account = account->next);
     468            if(account != NULL) user[0] = '\0';
     469            ++i;
     470        }
    463471      if (!(account=malloc(sizeof(struct s_auth)))){
    464472        cs_log("Error allocating memory (errno=%d)", errno);
Note: See TracChangeset for help on using the changeset viewer.