Ignore:
Timestamp:
01/16/10 19:00:23 (11 years ago)
Author:
Admin
Message:

Add cs_strncpy as a replacement for strncpy. This function always terminates the string and works pretty much like strlcpy but without return value.

File:
1 edited

Legend:

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

    r1238 r1256  
    664664    char user[128];
    665665
    666     if (strcmp(getParam(params, "action"), "Save As") == 0) strncpy(user, getParam(params, "newuser"), sizeof(user)/sizeof(char) - 1);
    667     else strncpy(user, getParam(params, "user"), sizeof(user)/sizeof(char) - 1);
    668     user[sizeof(user)/sizeof(char) - 1] = '\0';
     666    if (strcmp(getParam(params, "action"), "Save As") == 0) cs_strncpy(user, getParam(params, "newuser"), sizeof(user)/sizeof(char));
     667    else cs_strncpy(user, getParam(params, "user"), sizeof(user)/sizeof(char));
    669668
    670669    int i;
     
    691690      }
    692691      memset(account, 0, sizeof(struct s_auth));
    693             strncpy((char *)account->usr, user, sizeof(account->usr)-1);
     692            cs_strncpy((char *)account->usr, user, sizeof(account->usr));
    694693      account->au=(-1);
    695694      account->monlvl=cfg->mon_level;
     
    10531052    int i;
    10541053
    1055     strncpy(label, strtolower(getParam(params, "service")), sizeof(label)/sizeof(char) - 1);
    1056     label[sizeof(label)/sizeof(char) - 1] = '\0';
     1054    cs_strncpy(label, strtolower(getParam(params, "service")), sizeof(label)/sizeof(char));
    10571055
    10581056    for (sidtab  = cfg->sidtab; sidtab != NULL && strcmp(label, sidtab->label) != 0; sidtab=sidtab->next);
     
    10771075      }
    10781076      memset(sidtab, 0, sizeof(struct s_sidtab));
    1079             strncpy((char *)sidtab->label, label, sizeof(sidtab->label)-1);
     1077            cs_strncpy((char *)sidtab->label, label, sizeof(sidtab->label));
    10801078
    10811079            tpl_addVar(vars, 1, "MESSAGE", "<b>New service has been added</b><BR>");
Note: See TracChangeset for help on using the changeset viewer.