back-out 23d69b66 (bug #1386: GNU/Hurd) for 1.2 branch, define PATH_MAX as 4096 if not defined. SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Sun, 07 Oct 2018 12:32:15 +0300
branchSDL-1.2
changeset 8929dd046cb6cd7
parent 890 ae9b46ccd5ab
child 893 3d9130c0136d
back-out 23d69b66 (bug #1386: GNU/Hurd) for 1.2 branch, define PATH_MAX as 4096 if not defined.
music_cmd.c
music_cmd.h
     1.1 --- a/music_cmd.c	Sun Oct 07 11:47:50 2018 +0300
     1.2 +++ b/music_cmd.c	Sun Oct 07 12:32:15 2018 +0300
     1.3 @@ -53,8 +53,10 @@
     1.4  		Mix_SetError("Out of memory");
     1.5  		return(NULL);
     1.6  	}
     1.7 -	music->file = SDL_strdup(file);
     1.8 -	music->cmd = SDL_strdup(cmd);
     1.9 +	strncpy(music->file, file, (sizeof music->file)-1);
    1.10 +	music->file[(sizeof music->file)-1] = '\0';
    1.11 +	strncpy(music->cmd, cmd, (sizeof music->cmd)-1);
    1.12 +	music->cmd[(sizeof music->cmd)-1] = '\0';
    1.13  	music->pid = 0;
    1.14  
    1.15  	/* We're done */
    1.16 @@ -153,7 +155,7 @@
    1.17  
    1.18  	    /* Child process - executes here */
    1.19  	    case 0: {
    1.20 -		    char *command;
    1.21 +		    char command[PATH_MAX];
    1.22  		    char **argv;
    1.23  
    1.24  		    /* Unblock signals in case we're called from a thread */
    1.25 @@ -164,12 +166,11 @@
    1.26  		    }
    1.27  
    1.28  		    /* Execute the command */
    1.29 -		    command = SDL_strdup(music->cmd);
    1.30 +		    strcpy(command, music->cmd);
    1.31  		    argv = parse_args(command, music->file);
    1.32  		    if ( argv != NULL ) {
    1.33  			execvp(argv[0], argv);
    1.34  		    }
    1.35 -		    SDL_free(command);
    1.36  
    1.37  		    /* exec() failed */
    1.38  		    perror(argv[0]);
    1.39 @@ -218,8 +219,6 @@
    1.40  /* Close the given music stream */
    1.41  void MusicCMD_FreeSong(MusicCMD *music)
    1.42  {
    1.43 -	SDL_free(music->file);
    1.44 -	SDL_free(music->cmd);
    1.45  	SDL_free(music);
    1.46  }
    1.47  
     2.1 --- a/music_cmd.h	Sun Oct 07 11:47:50 2018 +0300
     2.2 +++ b/music_cmd.h	Sun Oct 07 12:32:15 2018 +0300
     2.3 @@ -29,9 +29,12 @@
     2.4  #if defined(__linux__) && defined(__arm__)
     2.5  # include <linux/limits.h>
     2.6  #endif
     2.7 +#ifndef PATH_MAX /* GNU/Hurd? */
     2.8 +# define PATH_MAX 4096
     2.9 +#endif
    2.10  typedef struct {
    2.11 -	char *file;
    2.12 -	char *cmd;
    2.13 +	char file[PATH_MAX];
    2.14 +	char cmd[PATH_MAX];
    2.15  	pid_t pid;
    2.16  } MusicCMD;
    2.17