--- xcoral.c +++ xcoral.c @@ -194,18 +194,18 @@ if (getenv("XCORAL_POSITION")!=NULL) display_position=True; - /* Chargement de .xcoralrc et SmacLib */ + /* Chargement de .desk/xcoralrc et SmacLib */ /* On verifie d'abord l'existence de SmacLib */ - (void) sprintf(tmp,"%s/xcoralrc.lf",XCORAL_LIB_DIR); + (void)snprintf(tmp, MAXPATHLEN,"%s/xcoralrc.lf",XCORAL_LIB_DIR); if (access(tmp,R_OK)==0){ /* SmacLib Ok */ bzero ( tmp, MAXPATHLEN ); xcoralrc = (char *) getenv ("XCORALRC"); if (!xcoralrc) { - (void) sprintf (tmp, "%s/.xcoralrc", getenv("HOME")); + (void)snprintf(tmp, MAXPATHLEN, "%s/.desk/xcoralrc", (char*)getenv("HOME")); } else - (void) strcpy ( tmp, xcoralrc ); + (void)strncpy(tmp, xcoralrc, MAXPATHLEN ); if (access(tmp,R_OK)!=0){ /* pas de xcoralrc defini, ca craint */ @@ -213,23 +213,24 @@ (void) sprintf (tmp, "cp -p %s/xcoralrc.lf %s/.xcoralrc\n", XCORAL_LIB_DIR, getenv ("HOME")); system(tmp); - (void) sprintf (tmp, "%s/.xcoralrc", getenv("HOME")); + (void)snprintf(tmp, MAXPATHLEN, "%s/.desk/xcoralrc", (char*)getenv("HOME")); } else { + char *ttt; /* On verifie que la version est correcte */ if ((fd = fopen(tmp, "r"))!=0){ - fgets(pp,8,fd); - if (strncmp(pp + 3, CURRENT_VERSION, 4) != 0){ - /* .xcoralrc ne correspond pas a la version courante. Copie */ - (void) sprintf(pp, "%s/.xcoralrc.old", getenv ("HOME")); + ttt = fgets(pp, 8, fd); + if (ttt && strncmp(pp + 3, CURRENT_VERSION, 4) != 0) { + /* .desk/xcoralrc ne correspond pas a la version courante. Copie */ + (void) sprintf(pp, "%s/.desk/xcoralrc.old", getenv("HOME")); rename (tmp,pp); /* On copie celui qui est dans SmacLib */ - (void) sprintf (tmp, "cp -p %s/xcoralrc.lf %s/.xcoralrc\n", + (void)snprintf(tmp, MAXPATHLEN, "cp -p %s/xcoralrc.lf %s/.desk/xcoralrc\n", XCORAL_LIB_DIR, getenv ("HOME")); system(tmp); - (void) sprintf (tmp, "%s/.xcoralrc", getenv ("HOME")); - (void) fprintf (stderr,"Your .xcoralrc file is obsolete so it has been moved as .xcoralrc.old\n"); - (void) fprintf (stderr,"A new .xcoralrc file has been created in your home directory\n"); + (void)snprintf(tmp, MAXPATHLEN, "%s/.desk/xcoralrc", getenv("HOME")); + (void)fprintf(stderr, "Your .desk/xcoralrc file is obsolete so it has been moved as .desk/xcoralrc.old\n"); + (void)fprintf(stderr, "A new .desk/xcoralrc file has been created in your home directory\n"); } } }