fix #14 : Local buffer overflow
authorEdouard Tisserant
Sat, 09 Jul 2016 16:08:14 +0200
changeset 81491f317ce921f
parent 813 2f069faaf513
child 816 1a0742407043
fix #14 : Local buffer overflow
src/platform_unix.c
     1.1 --- a/src/platform_unix.c	Sat Jul 09 15:24:01 2016 +0200
     1.2 +++ b/src/platform_unix.c	Sat Jul 09 16:08:14 2016 +0200
     1.3 @@ -65,7 +65,7 @@
     1.4          char *tw_env;
     1.5          if(tw_env = getenv("TRUSTWORDS")){
     1.6              char *p = stpncpy(buffer, tw_env, MAX_PATH);
     1.7 -            size_t len = MAX_PATH - (p - buffer) - 2;
     1.8 +            ssize_t len = MAX_PATH - (p - buffer) - 2;
     1.9  
    1.10              if (len < strlen(SYSTEM_DB_FILENAME)) {
    1.11                  assert(0);
    1.12 @@ -93,7 +93,7 @@
    1.13          char *home_env;
    1.14          if((home_env = getenv("HOME"))){
    1.15              char *p = stpncpy(buffer, home_env, MAX_PATH);
    1.16 -            size_t len = MAX_PATH - (p - buffer) - 2;
    1.17 +            ssize_t len = MAX_PATH - (p - buffer) - 2;
    1.18  
    1.19              if (len < strlen(LOCAL_DB_FILENAME)) {
    1.20                  assert(0);
    1.21 @@ -123,7 +123,7 @@
    1.22  
    1.23      if (!done) {
    1.24          char *p;
    1.25 -        size_t len;
    1.26 +        ssize_t len;
    1.27          char *gpg_home_env = getenv("GNUPGHOME");
    1.28          char *home_env = getenv("HOME");
    1.29  
    1.30 @@ -200,7 +200,7 @@
    1.31          char *p;
    1.32          p = stpncpy(agent_path, dirname, MAX_PATH);
    1.33          
    1.34 -        size_t len = MAX_PATH - (p - agent_path) - 2;
    1.35 +        ssize_t len = MAX_PATH - (p - agent_path) - 2;
    1.36  
    1.37          if (len < strlen(gpg_agent_conf_name))
    1.38          {