Skip to content

Commit

Permalink
various bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KeithDHedger committed Jul 28, 2023
1 parent f5e4e2a commit 54bba91
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 76 deletions.
6 changes: 5 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@

***************************************
BUGS:
Please send them direct to me at:[email protected] posting them on xfce-look etc gets too messy!
Please send them direct to me at:[email protected].
***************************************

Changelog:
0.3.9
Removed redundant xfdesktop --reload.
Buffer overflow fixes.
Minor changes to xconf settings.
0.3.8
Added new release.
Removed release with broken links.
Expand Down
82 changes: 40 additions & 42 deletions Xfce-Theme-Manager/src/callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void changeViewWhat(GtkWidget* widget,gpointer data)
rerunAndUpdate(false,true);
}

void buildCustomDB(const char* chan,const char* prop,dataType type,const char* key)
void buildCustomDB(const char* chan,const char* prop,dataType type,const char* key,FILE *fd)
{
char* strdata=NULL;
int intdata;
Expand All @@ -186,18 +186,18 @@ void buildCustomDB(const char* chan,const char* prop,dataType type,const char* k
{
case INT:
getValue(chan,prop,type,&intdata);
sprintf(filedata,"%s%s=%i\n",filedata,key,intdata);
fprintf(fd,"%s=%i\n",key,intdata);
break;

case STRING:
getValue(chan,prop,type,&strdata);
sprintf(filedata,"%s%s=%s\n",filedata,key,strdata);
fprintf(fd,"%s=%s\n",key,strdata);
g_free(strdata);
break;

case FLOAT:
getValue(chan,prop,type,&floatdata);
sprintf(filedata,"%s%s=%f\n",filedata,key,floatdata);
fprintf(fd,"%s=%f\n",key,floatdata);
break;

case COLOURARRAY:
Expand All @@ -219,9 +219,9 @@ void response(GtkDialog *dialog,gint response_id,gpointer user_data)
asprintf(&filename,"%s",gtk_entry_get_text((GtkEntry*)entryBox));
if (filename!=NULL && strlen(filename)>0)
{
sprintf(generalBuffer,"%s/%s.db",customFolder,filename);
sprintf(filedata,"%s/%s.db",customFolder,filename);
remove(generalBuffer);
sprintf(generalBuffer,"%s/%s.png",customFolder,filename);
sprintf(filedata,"%s/%s.png",customFolder,filename);
remove(generalBuffer);
freeAndNull(&filename);
rerunAndUpdate(true,true);
Expand Down Expand Up @@ -302,42 +302,42 @@ void customTheme(GtkWidget* window,gpointer data)
fd=fopen(dbname,"w");
if(fd!=NULL)
{
sprintf(filedata,"[Data]\nName=%s\nThumbnail=%s\n",filename,thumbfile);
buildCustomDB(XSETTINGS,CONTROLTHEMEPROP,STRING,"GtkTheme");
buildCustomDB(XSETTINGS,ICONTHEMEPROP,STRING,"IconTheme");
buildCustomDB(XSETTINGS,CURSORSPROP,STRING,"CursorTheme");
buildCustomDB(XFWM,WMBORDERSPROP,STRING,"Xfwm4Theme");
fprintf(fd,"[Data]\nName=%s\nThumbnail=%s\n",filename,thumbfile);
buildCustomDB(XSETTINGS,CONTROLTHEMEPROP,STRING,"GtkTheme",fd);
buildCustomDB(XSETTINGS,ICONTHEMEPROP,STRING,"IconTheme",fd);
buildCustomDB(XSETTINGS,CURSORSPROP,STRING,"CursorTheme",fd);
buildCustomDB(XFWM,WMBORDERSPROP,STRING,"Xfwm4Theme",fd);

buildCustomDB(XFWM,BUTTONLAYOUTPROP,STRING,"TitleButtonLayout");
buildCustomDB(XFWM,TITLEALIGNPROP,STRING,"TitlePosition");
buildCustomDB(XFWM,WMFONTPROP,STRING,"WMFont");
buildCustomDB(XSETTINGS,APPFONTPROP,STRING,"AppFont");
buildCustomDB(XFWM,BUTTONLAYOUTPROP,STRING,"TitleButtonLayout",fd);
buildCustomDB(XFWM,TITLEALIGNPROP,STRING,"TitlePosition",fd);
buildCustomDB(XFWM,WMFONTPROP,STRING,"WMFont",fd);
buildCustomDB(XSETTINGS,APPFONTPROP,STRING,"AppFont",fd);

buildCustomDB(XSETTINGS,CURSORSIZEPROP,INT,"CursorSize");
buildCustomDB(XSETTINGS,CURSORSIZEPROP,INT,"CursorSize",fd);

//backdrop stuff
for(int j=0; j<numberOfMonitors; j++)
{
sprintf(filedata,"%s[Monitor-%i]\n",filedata,j);
sprintf(filedata,"%sBackgroundImage=%s\n",filedata,monitorData[j]->imagePath);
sprintf(filedata,"%sBackdropStyle=%i\n",filedata,monitorData[j]->style);
sprintf(filedata,"%sBackdropBright=%i\n",filedata,monitorData[j]->brightness);
sprintf(filedata,"%sBackdropSatu=%f\n",filedata,monitorData[j]->satu);
fprintf(fd,"[Monitor-%i]\n",j);
fprintf(fd,"BackgroundImage=%s\n",monitorData[j]->imagePath);
fprintf(fd,"BackdropStyle=%i\n",monitorData[j]->style);
fprintf(fd,"BackdropBright=%i\n",monitorData[j]->brightness);
fprintf(fd,"BackdropSatu=%f\n",monitorData[j]->satu);
}

//panel stuff
for(int j=0; j<numOfPanels; j++)
{
sprintf(filedata,"%s[Panel-%i]\n",filedata,panels[j]->panelNumber);
sprintf(filedata,"%sPanelImage=%s\n",filedata,panels[j]->imagePath);
sprintf(filedata,"%sPanelStyle=%i\n",filedata,panels[j]->style);
sprintf(filedata,"%sPanelSize=%i\n",filedata,panels[j]->size);
sprintf(filedata,"%sPanelAlpha=%i\n",filedata,panels[j]->alpha);
sprintf(filedata,"%sPanelRed=%i\n",filedata,panels[j]->red);
sprintf(filedata,"%sPanelGreen=%i\n",filedata,panels[j]->green);
sprintf(filedata,"%sPanelBlue=%i\n",filedata,panels[j]->blue);

fprintf(fd,"[Panel-%i]\n",panels[j]->panelNumber);
fprintf(fd,"PanelImage=%s\n",panels[j]->imagePath);
fprintf(fd,"PanelStyle=%i\n",panels[j]->style);
fprintf(fd,"PanelSize=%i\n",panels[j]->size);
fprintf(fd,"PanelAlpha=%i\n",panels[j]->alpha);
fprintf(fd,"PanelRed=%i\n",panels[j]->red);
fprintf(fd,"PanelGreen=%i\n",panels[j]->green);
fprintf(fd,"PanelBlue=%i\n",panels[j]->blue);
}
fprintf(fd,"%s\n",filedata);
fclose(fd);

controlWidth=400;
Expand Down Expand Up @@ -455,29 +455,29 @@ int extractAndInstall(char* filename,int ziptype)

while(true)
{
sprintf(generalBuffer,"%s \"%s\" */gtkrc",commandtest,filename);
sprintf(filedata,"%s \"%s\" */gtkrc",commandtest,filename);
g_spawn_command_line_sync((char*)generalBuffer,&stdout,&stderr,&spawnret,NULL);
if (spawnret==0)
{
stdout[strlen(stdout)-1]=0;
if(strlen(stdout)>1)
{
sprintf(generalBuffer,"%s \"%s\"",commandextracttheme,filename);
sprintf(filedata,"%s \"%s\"",commandextracttheme,filename);
retval=system(generalBuffer);
freeAndNull(&stdout);
break;
}
freeAndNull(&stdout);
}

sprintf(generalBuffer,"%s \"%s\" */themerc",commandtest,filename);
sprintf(filedata,"%s \"%s\" */themerc",commandtest,filename);
g_spawn_command_line_sync((char*)generalBuffer,&stdout,&stderr,&spawnret,NULL);
if (spawnret==0)
{
stdout[strlen(stdout)-1]=0;
if(strlen(stdout)>1)
{
sprintf(generalBuffer,"%s \"%s\"",commandextracttheme,filename);
sprintf(filedata,"%s \"%s\"",commandextracttheme,filename);
retval=system(generalBuffer);
freeAndNull(&stdout);
freeAndNull(&stderr);
Expand All @@ -487,14 +487,14 @@ int extractAndInstall(char* filename,int ziptype)
freeAndNull(&stderr);
}

sprintf(generalBuffer,"%s \"%s\" */index.theme",commandtest,filename);
sprintf(filedata,"%s \"%s\" */index.theme",commandtest,filename);
g_spawn_command_line_sync((char*)generalBuffer,&stdout,&stderr,&spawnret,NULL);
if (spawnret==0)
{
stdout[strlen(stdout)-1]=0;
if(strlen(stdout)>1)
{
sprintf(generalBuffer,"%s \"%s\"",commandextracticon,filename);
sprintf(filedata,"%s \"%s\"",commandextracticon,filename);
retval=system(generalBuffer);
freeAndNull(&stdout);
freeAndNull(&stderr);
Expand Down Expand Up @@ -529,13 +529,13 @@ void dropUri(GtkWidget *widget,GdkDragContext *context,gint x,gint y,GtkSelectio

//make sure folders are there
//themes
sprintf(generalBuffer,"mkdir -p %s/.themes",homeFolder);
sprintf(filedata,"mkdir -p %s/.themes",homeFolder);
system(generalBuffer);
//icons etc
sprintf(generalBuffer,"mkdir -p %s/.icons",homeFolder);
sprintf(filedata,"mkdir -p %s/.icons",homeFolder);
system(generalBuffer);
//pics
sprintf(generalBuffer,"mkdir -p %s/.local/share/xfce4/backdrops",homeFolder);
sprintf(filedata,"mkdir -p %s/.local/share/xfce4/backdrops",homeFolder);
system(generalBuffer);

//themes
Expand Down Expand Up @@ -646,7 +646,7 @@ void removeTheme(const char* name)
if(gtk_dialog_run (GTK_DIALOG(dialog))==GTK_RESPONSE_YES)
{
namelen=strlen(name);
sprintf(generalBuffer,"%s",name);
sprintf(filedata,"%s",name);
remove(name);
generalBuffer[namelen-2]='p';
generalBuffer[namelen-1]='n';
Expand Down Expand Up @@ -907,8 +907,6 @@ void doMeta(char* metaFilename)

if(keydata!=NULL)
g_key_file_free(keyfile);

system("xfdesktop --reload");
}

void setPieceNewNew(const char* filePath,long doWhat)
Expand Down
4 changes: 3 additions & 1 deletion Xfce-Theme-Manager/src/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ int doCliThemePart(char* name,long what)
papername=getThemeNameFromDB(generalBuffer);
if(papername!=NULL)
{
sprintf((char*)&generalBuffer[0],"%s%i/image-path",MONITORPROP,cliMonitor);
sprintf((char*)&generalBuffer[0],"%s%s/workspace0/last-image",MONITORPROP,monitorData[cliMonitor]->name);
setValue(XFCEDESKTOP,(char*)&generalBuffer[0],STRING,papername);
sprintf((char*)&generalBuffer[0],"%s%i/workspace0/last-image",MONITORPROP,cliMonitor);
setValue(XFCEDESKTOP,(char*)&generalBuffer[0],STRING,papername);
return(0);
}
Expand Down
14 changes: 7 additions & 7 deletions Xfce-Theme-Manager/src/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,17 @@ gpointer rebuildDB(gpointer data)
{
if (g_file_test(dbFolder,G_FILE_TEST_IS_DIR))
{
sprintf(generalBuffer,"rm -r %s",metaFolder);
snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",metaFolder);
system(generalBuffer);
sprintf(generalBuffer,"rm -r %s",framesFolder);
snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",framesFolder);
system(generalBuffer);
sprintf(generalBuffer,"rm -r %s",controlsFolder);
snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",controlsFolder);
system(generalBuffer);
sprintf(generalBuffer,"rm -r %s",iconsFolder);
snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",iconsFolder);
system(generalBuffer);
sprintf(generalBuffer,"rm -r %s",cursorsFolder);
snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",cursorsFolder);
system(generalBuffer);
sprintf(generalBuffer,"rm -r %s",wallpapersFolder);
snprintf(generalBuffer,GENBUFFERSIZE,"rm -r %s",wallpapersFolder);
system(generalBuffer);
}
}
Expand Down Expand Up @@ -556,7 +556,7 @@ gpointer rebuildDB(gpointer data)
entry=g_dir_read_name(folder);
while(entry!=NULL)
{
sprintf(generalBuffer,"%s/%s",papersArray[i],entry);
snprintf(generalBuffer,GENBUFFERSIZE,"%s/%s",papersArray[i],entry);
if(g_file_test(generalBuffer,G_FILE_TEST_IS_DIR)==false)
{
asprintf(&dbfile,"%s/%i.%s.db",wallpapersFolder,i,entry);
Expand Down
4 changes: 2 additions & 2 deletions Xfce-Theme-Manager/src/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ int controlHeight=64;
int controlWidth=256;
GdkPixbuf* controlsPixbuf;

GtkNotebook* notebook;
GtkNotebook* notebook;

char generalBuffer[4096];
char generalBuffer[GENBUFFERSIZE];

GdkPixbuf* missingImage;
GdkPixbuf* blankImage;
Expand Down
8 changes: 5 additions & 3 deletions Xfce-Theme-Manager/src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
#define _translate(x) langStr[langID][x]
#define _translateHelp(x) helpStr[langID][x]

#define GENBUFFERSIZE 8192

enum {ENGLISH=0,SPANISH,GERMAN,POLISH,FRENCH,PORTUGUESE,NONE};

enum dataType {INT,BOOLEAN,STRING,FLOAT,COLOURARRAY};
Expand All @@ -109,7 +111,7 @@ extern char* currentButtonLayout;
extern char* currentTitlePos;
extern char* currentWMFont;
extern char* currentAppFont;
extern int currentCursSize;
extern int currentCursSize;
extern char* currentMetaTheme;

extern char* originalGtkTheme;
Expand All @@ -120,7 +122,7 @@ extern char* originalWallpaper;
extern char* originalMetaTheme;

extern char* homeThemesHash;
extern bool initing;
extern bool initing;

struct boxStruct
{
Expand Down Expand Up @@ -233,7 +235,7 @@ extern int controlWidth;
extern GdkPixbuf* controlsPixbuf;
extern GtkNotebook* notebook;

extern char generalBuffer[4096];
extern char generalBuffer[GENBUFFERSIZE];

extern GdkPixbuf* missingImage;
extern GdkPixbuf* blankImage;
Expand Down
Loading

0 comments on commit 54bba91

Please sign in to comment.