Changeset 428 for trunk/src/sh_static.c


Ignore:
Timestamp:
Mar 12, 2013, 9:42:07 PM (12 years ago)
Author:
katerina
Message:

Fix for ticket #335 (warn if buffer for group reading is too small).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_static.c

    r252 r428  
    7676
    7777#define PWD_BUFFER_SIZE 256
    78 #define GRP_BUFFER_SIZE 256
     78#define GRP_BUFFER_SIZE 3584
     79#define GRP_BUFFER_SIZE_MALLOC 32768
    7980
    8081/**********************************************************************/
     
    467468        char **m;
    468469        struct group group;
    469         char buff[PWD_BUFFER_SIZE];
     470
     471        char * buff = malloc(GRP_BUFFER_SIZE_MALLOC);
    470472
    471473        rv = -1;
     
    481483                num_groups = 1;
    482484
    483                 while (!__pgsreader(__parsegrent, &group, buff, sizeof(buff), grf)) {
     485                while (!__pgsreader(__parsegrent, &group, buff, GRP_BUFFER_SIZE_MALLOC, grf)) {
    484486                        assert(group.gr_mem); /* Must have at least a NULL terminator. */
    485487                        if (group.gr_gid != gid) {
     
    511513         * warnings from various malloc debuggers. */
    512514        free(group_list);
     515        free(buff);
    513516        return rv;
    514517}
     
    699702                                line_buff[line_len] = 0;
    700703                        } else if (line_len + 2 == buflen) { /* line too long */
     704                                rv = ERANGE;
     705                                break;
     706                                /*
    701707                                ++skip;
    702708                                continue;
     709                                */
    703710                        }
    704711
Note: See TracChangeset for help on using the changeset viewer.