Changeset 7dcefa7 in libguac


Ignore:
Timestamp:
08/23/12 14:50:06 (9 months ago)
Author:
zhangmaike
Branches:
master, debian, rpm, unstable
Children:
f6cc43c
Parents:
9de0d0d
git-author:
Michael Jumper <zhangmaike@…> (08/23/12 14:50:06)
git-committer:
Michael Jumper <zhangmaike@…> (08/23/12 14:50:06)
Message:

Define library prefix/suffix with macros, explicitly define and enforce limit on protocol name length, and overall library name length.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/client.h

    r1aaa0a3 r7dcefa7  
    5151 */ 
    5252 
     53/** 
     54 * String prefix which begins the library filename of all client plugins. 
     55 */ 
     56#define GUAC_PROTOCOL_LIBRARY_PREFIX "libguac-client-" 
     57 
     58/** 
     59 * String suffix which ends the library filename of all client plugins. 
     60 */ 
     61#define GUAC_PROTOCOL_LIBRARY_SUFFIX ".so" 
     62 
     63/** 
     64 * The maximum number of characters (COUNTING NULL TERMINATOR) to allow 
     65 * for protocol names within the library filename of client plugins. 
     66 */ 
     67#define GUAC_PROTOCOL_NAME_LIMIT 256 
     68 
     69/** 
     70 * The maximum number of characters (INCLUDING NULL TERMINATOR) that a 
     71 * character array containing the concatenation of the library prefix, 
     72 * protocol name, and suffix can contain, assuming the protocol name is 
     73 * limited to GUAC_PROTOCOL_NAME_LIMIT characters. 
     74 */ 
     75#define GUAC_PROTOCOL_LIBRARY_LIMIT (                                  \ 
     76                                                                       \ 
     77      sizeof(GUAC_PROTOCOL_LIBRARY_PREFIX) - 1 /* "libguac-client-" */ \ 
     78    +        GUAC_PROTOCOL_NAME_LIMIT      - 1 /* [up to 256 chars] */ \ 
     79    + sizeof(GUAC_PROTOCOL_LIBRARY_SUFFIX) - 1 /* ".so"             */ \ 
     80    + 1                                        /* NULL terminator   */ \ 
     81                                                                       \ 
     82) 
     83 
     84 
    5385typedef struct guac_client guac_client; 
    5486typedef struct guac_client_plugin guac_client_plugin; 
  • src/client.c

    rfd1164e r7dcefa7  
    165165 
    166166    /* Pluggable client */ 
    167     char protocol_lib[256] = "libguac-client-"; 
    168      
     167    char protocol_lib[GUAC_PROTOCOL_LIBRARY_LIMIT] = 
     168        GUAC_PROTOCOL_LIBRARY_PREFIX; 
     169  
    169170    union { 
    170171        guac_client_init_handler* client_init; 
     
    173174 
    174175    /* Add protocol and .so suffix to protocol_lib */ 
    175     strcat(protocol_lib, protocol); 
    176     strcat(protocol_lib, ".so"); 
     176    strncat(protocol_lib, protocol, GUAC_PROTOCOL_NAME_LIMIT-1); 
     177    strcat(protocol_lib, GUAC_PROTOCOL_LIBRARY_SUFFIX); 
    177178 
    178179    /* Load client plugin */ 
Note: See TracChangeset for help on using the changeset viewer.