Changeset 563

Show
Ignore:
Timestamp:
07/11/08 23:20:50 (5 months ago)
Author:
athomas
Message:

Fix for security vulnerability reported by Nico Golde.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • op/trunk/main.c

    r260 r563  
    798798        if (getenv("DISPLAY") != NULL && (cp = FindOpt(cmd, "xauth")) != NULL) { 
    799799        struct passwd *currentpw; 
    800         char tmpxauth[MAXSTRLEN], xauth[MAXSTRLEN], cxauth[MAXSTRLEN], *display; 
     800        char tmpxauth[MAXSTRLEN], *xauth, *cxauth, *display; 
    801801        int status; 
    802802        uid_t uid; 
     
    814814                if ((display = strchr(getenv("DISPLAY"), ':')) == NULL) 
    815815                        fatal(1, "Could not extract X server from $DISPLAY '%s'", getenv("DISPLAY")); 
     816                xauth = (char*)malloc(strlen(pw->pw_dir) + strlen("/.Xauthority") + 1); 
    816817                strcpy(xauth, pw->pw_dir); 
    817818                strcat(xauth, "/.Xauthority"); 
     
    821822                /* Now that we know the target user, we can copy the xauth cookies */ 
    822823                if (getenv("XAUTHORITY") != NULL) { 
    823                         strcpy(cxauth, getenv("XAUTHORITY")); 
     824                        cxauth = strdup(getenv("XAUTHORITY")); 
    824825                } else { 
     826                        cxauth = (char*)malloc(strlen(currentpw->pw_dir) + 
     827                                                                   strlen("/.Xauthority") + 1); 
    825828                        strcpy(cxauth, currentpw->pw_dir); 
    826829                        strcat(cxauth, "/.Xauthority"); 
     
    12091212                                                                tmp = str_replace(cmd->args[i], 
    12101213                                                                        np - cmd->args[i] - 1, cp - np + 1, argv[val]); 
    1211                                                                 cp = tmp + (cp - cmd->args[i]) + 1
     1214                                                                cp = tmp + (cp - cmd->args[i]) + (strlen(tmp) - strlen(cmd->args[i]));
    12121215                                                                np = cp; 
    12131216                                                                cmd->args[i] = tmp;