diff --git a/html/ws/index.html b/html/api/index.html
similarity index 98%
rename from html/ws/index.html
rename to html/api/index.html
index bb470df6..53fee9f7 100644
--- a/html/ws/index.html
+++ b/html/api/index.html
@@ -2,7 +2,7 @@
-
-
- Videotutorials created by SWAD users (2010-2015)
+
+ OpenSWAD, Atomun (Telesur TV), 2017
+
+
+
+ Videotutorials created by SWAD users, 2010-2015
- Videotutorials about SWAD - UGR (2013)
+ Videotutorials about SWAD - UGR, 2013
- Videotutorials about SWADroid (2011-2016)
+ Videotutorials about SWADroid, 2011-2016
diff --git a/sha2/sha2.o b/sha2/sha2.o
index eb7eac09..de779df9 100644
Binary files a/sha2/sha2.o and b/sha2/sha2.o differ
diff --git a/sql/swad.sql b/sql/swad.sql
index 777d36c6..07530940 100644
--- a/sql/swad.sql
+++ b/sql/swad.sql
@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS IP_prefs (
INDEX(UsrCod),
INDEX(LastChange));
--
--- Table actions: Stores the text that describes each of the actions.
+-- Table actions: stores the text that describes each of the actions.
-- Each action has a numeric code associated to it that persists over time.
--
CREATE TABLE IF NOT EXISTS actions (
@@ -37,6 +37,15 @@ CREATE TABLE IF NOT EXISTS actions_MFU (
LastClick DATETIME NOT NULL,
UNIQUE INDEX(UsrCod,ActCod));
--
+-- Table ann_seen: stores users who have seen global announcements
+--
+CREATE TABLE IF NOT EXISTS admin (
+ UsrCod INT NOT NULL,
+ Scope ENUM('Sys','Ins','Ctr','Deg') NOT NULL,
+ Cod INT NOT NULL,
+ UNIQUE INDEX(UsrCod,Scope,Cod),
+ INDEX(Scope,Cod));
+--
-- Table agendas: stores users' agendas
--
CREATE TABLE IF NOT EXISTS agendas (
@@ -53,15 +62,6 @@ CREATE TABLE IF NOT EXISTS agendas (
--
-- Table ann_seen: stores users who have seen global announcements
--
-CREATE TABLE IF NOT EXISTS admin (
- UsrCod INT NOT NULL,
- Scope ENUM('Sys','Ins','Ctr','Deg') NOT NULL,
- Cod INT NOT NULL,
- UNIQUE INDEX(UsrCod,Scope,Cod),
- INDEX(Scope,Cod));
---
--- Table ann_seen: stores users who have seen global announcements
---
CREATE TABLE IF NOT EXISTS ann_seen (
AnnCod INT NOT NULL,
UsrCod INT NOT NULL,
@@ -171,7 +171,7 @@ CREATE TABLE IF NOT EXISTS centres (
INDEX(PlcCod),
INDEX(Status));
--
--- Table chat: stored number of users in each chat room (this table is not used now)
+-- Table chat: stores number of users in each chat room (this table is not used now)
--
CREATE TABLE IF NOT EXISTS chat (
RoomCode VARCHAR(16) NOT NULL,
@@ -567,23 +567,6 @@ CREATE TABLE IF NOT EXISTS forum_thread (
UNIQUE INDEX(FirstPstCod),
UNIQUE INDEX(LastPstCod));
--
--- Table surveys: stores the games
---
-CREATE TABLE IF NOT EXISTS games (
- GamCod INT NOT NULL AUTO_INCREMENT,
- Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',
- Cod INT NOT NULL DEFAULT -1,
- Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',
- NumNotif INT NOT NULL DEFAULT 0,
- Roles INT NOT NULL DEFAULT 0,
- UsrCod INT NOT NULL,
- StartTime DATETIME NOT NULL,
- EndTime DATETIME NOT NULL,
- Title VARCHAR(2047) NOT NULL,
- Txt TEXT NOT NULL,
- UNIQUE INDEX(GamCod),
- INDEX(Scope,Cod));
---
-- Table gam_answers: stores the answers to the games
--
CREATE TABLE IF NOT EXISTS gam_answers (
@@ -616,6 +599,23 @@ CREATE TABLE IF NOT EXISTS gam_users (
UsrCod INT NOT NULL,
UNIQUE INDEX(GamCod,UsrCod));
--
+-- Table games: stores the games
+--
+CREATE TABLE IF NOT EXISTS games (
+ GamCod INT NOT NULL AUTO_INCREMENT,
+ Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',
+ Cod INT NOT NULL DEFAULT -1,
+ Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',
+ NumNotif INT NOT NULL DEFAULT 0,
+ Roles INT NOT NULL DEFAULT 0,
+ UsrCod INT NOT NULL,
+ StartTime DATETIME NOT NULL,
+ EndTime DATETIME NOT NULL,
+ Title VARCHAR(2047) NOT NULL,
+ Txt TEXT NOT NULL,
+ UNIQUE INDEX(GamCod),
+ INDEX(Scope,Cod));
+--
-- Table hidden_params: stores some hidden parameters passed from a page to another using database instead of forms
--
CREATE TABLE IF NOT EXISTS hidden_params (
diff --git a/swad_account.c b/swad_account.c
index cd970746..2f572c18 100644
--- a/swad_account.c
+++ b/swad_account.c
@@ -714,7 +714,9 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1];
- char Query[2048];
+ char *QueryUsrData;
+ size_t CommentsLength;
+ char QueryUsrIDs[256 + ID_MAX_BYTES_USR_ID];
char PathRelUsr[PATH_MAX + 1];
unsigned NumID;
@@ -731,20 +733,39 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
/***** Insert new user in database *****/
/* Insert user's data */
Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB);
- sprintf (Query,"INSERT INTO usr_data"
- " (EncryptedUsrCod,Password,Surname1,Surname2,FirstName,Sex,"
- "Theme,IconSet,Language,FirstDayOfWeek,DateFormat,"
- "PhotoVisibility,ProfileVisibility,"
- "CtyCod,"
- "LocalAddress,LocalPhone,FamilyAddress,FamilyPhone,OriginPlace,Birthday,Comments,"
- "Menu,SideCols,NotifNtfEvents,EmailNtfEvents)"
- " VALUES"
- " ('%s','%s','%s','%s','%s','%s',"
- "'%s','%s','%s',%u,%u,"
- "'%s','%s',"
- "%ld,"
- "'%s','%s','%s','%s','%s',%s,'%s',"
- "%u,%u,-1,0)",
+ CommentsLength = strlen (UsrDat->Comments);
+ if ((QueryUsrData = malloc (2048 +
+ Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + // EncryptedUsrCod
+ Pwd_BYTES_ENCRYPTED_PASSWORD + // Password
+ Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME * 3 + // Surname1, Surname2, FirstName
+ Usr_MAX_BYTES_ADDRESS + // LocalAddress
+ Usr_MAX_BYTES_PHONE + // LocalPhone
+ Usr_MAX_BYTES_ADDRESS + // FamilyAddress
+ Usr_MAX_BYTES_PHONE + // FamilyPhone
+ Usr_MAX_BYTES_ADDRESS + // OriginPlace
+ Usr_BIRTHDAY_STR_DB_LENGTH + // BirthdayStrDB
+ CommentsLength)) == NULL) // Comments
+ Lay_ShowErrorAndExit ("Not enough memory to store query.");
+ sprintf (QueryUsrData,"INSERT INTO usr_data"
+ " (EncryptedUsrCod,Password,"
+ "Surname1,Surname2,FirstName,Sex,"
+ "Theme,IconSet,Language,FirstDayOfWeek,DateFormat,"
+ "PhotoVisibility,ProfileVisibility,"
+ "CtyCod,"
+ "LocalAddress,LocalPhone,"
+ "FamilyAddress,FamilyPhone,"
+ "OriginPlace,Birthday,Comments,"
+ "Menu,SideCols,NotifNtfEvents,EmailNtfEvents)"
+ " VALUES"
+ " ('%s','%s',"
+ "'%s','%s','%s','%s',"
+ "'%s','%s','%s',%u,%u,"
+ "'%s','%s',"
+ "%ld,"
+ "'%s','%s',"
+ "'%s','%s','%s',"
+ "%s,'%s',"
+ "%u,%u,-1,0)",
UsrDat->EncryptedUsrCod,
UsrDat->Password,
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
@@ -758,14 +779,15 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
Pri_VisibilityDB[UsrDat->ProfileVisibility],
UsrDat->CtyCod,
UsrDat->LocalAddress ,UsrDat->LocalPhone,
- UsrDat->FamilyAddress,UsrDat->FamilyPhone,
- UsrDat->OriginPlace,
+ UsrDat->FamilyAddress,UsrDat->FamilyPhone,UsrDat->OriginPlace,
BirthdayStrDB,
- UsrDat->Comments ? UsrDat->Comments :
- "",
+ CommentsLength ? UsrDat->Comments :
+ "",
(unsigned) Mnu_MENU_DEFAULT,
(unsigned) Cfg_DEFAULT_COLUMNS);
- UsrDat->UsrCod = DB_QueryINSERTandReturnCode (Query,"can not create user");
+ UsrDat->UsrCod = DB_QueryINSERTandReturnCode (QueryUsrData,
+ "can not create user");
+ free ((void *) QueryUsrData);
/* Insert user's IDs as confirmed */
for (NumID = 0;
@@ -773,7 +795,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
NumID++)
{
Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID);
- sprintf (Query,"INSERT INTO usr_IDs"
+ sprintf (QueryUsrIDs,"INSERT INTO usr_IDs"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
@@ -781,7 +803,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
UsrDat->IDs.List[NumID].ID,
UsrDat->IDs.List[NumID].Confirmed ? 'Y' :
'N');
- DB_QueryINSERT (Query,"can not store user's ID when creating user");
+ DB_QueryINSERT (QueryUsrIDs,"can not store user's ID when creating user");
}
/***** Create directory for the user, if not exists *****/
diff --git a/swad_announcement.c b/swad_announcement.c
index b004f064..47dcde11 100644
--- a/swad_announcement.c
+++ b/swad_announcement.c
@@ -107,7 +107,7 @@ void Ann_ShowAllAnnouncements (void)
" FROM announcements"
" WHERE (Roles&%u)<>0 "
" ORDER BY AnnCod DESC",
- (unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss); // All my roles in different courses
+ (unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss); // All my roles in different courses
}
else // No user logged
/* Select only active announcements for unknown users */
@@ -115,8 +115,8 @@ void Ann_ShowAllAnnouncements (void)
" FROM announcements"
" WHERE Status=%u AND (Roles&%u)<>0 "
" ORDER BY AnnCod DESC",
- (unsigned) Ann_ACTIVE_ANNOUNCEMENT,
- (unsigned) (1 << Rol_UNK));
+ (unsigned) Ann_ACTIVE_ANNOUNCEMENT,
+ (unsigned) (1 << Rol_UNK));
NumAnnouncements = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get announcements");
/***** Start box *****/
diff --git a/swad_assignment.c b/swad_assignment.c
index 1effd344..d4c34990 100644
--- a/swad_assignment.c
+++ b/swad_assignment.c
@@ -587,7 +587,8 @@ static void Asg_PutFormsToRemEditOneAsg (long AsgCod,bool Hidden)
/***** Put form to edit assignment *****/
Ico_PutContextualIconToEdit (ActEdiOneAsg,Asg_PutParams);
- // no break
+ /* falls through */
+ /* no break */
case Rol_STD:
case Rol_NET:
/***** Put form to print assignment *****/
diff --git a/swad_changelog.h b/swad_changelog.h
index ef39f5b5..91dec14a 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -317,20 +317,36 @@ Hola Antonio, he ampliado el evento y nos deja comentar. El problema es que el p
// TODO: Al buscar un profesor deberían salir también las asignaturas en las que es profesor no editor
// TODO: En el pefil público de un usuario deberían contabilizarse como profesor las asignaturas en las que sea profesor no editor
+/* TODO:
+
+@CarlosEObertoM En respuesta a @acanasvargas
+
+Buenos días Profesor Cañas, sé que no es nada fácil, pero pudiera hacer más versátil las hojas de calificaciones que en pocos pasos se pudiera configurar para dar promedios, parciales y definitivas. Perdone la solicitud. Soy usuario agradecido de OpenSwad.
+*/
// TODO: Eliminar todas las preguntas de test de un golpe
// TODO: URGENTE: Cuando se cree un descriptor nuevo TIENE QUE ESTAR INHABILITADO porque si no los alumnos pueden ver el examen (Miguel Damas)
// TODO: URGENTE: No se puede eliminar ni ocultar el enlace "Preparacion terreno_ hoyos._." de la asignatura PLANTACIÓN Y SIEMBRA (código 2165) de OpenSWAD.
+
+// TODO: Que la opción por defecto en "Permitir que los profesores vean este examen" la configuren los profesores en cada asignatura"
+// TODO: URGENTE: Bego del Pino, una columna en resultados de test que indique los descriptores de ese examen
+
+// TODO: Pedro Villar Castro:
+// Al asignar un TFG a alumnos, no escribir el DNI del alumno, sino escogerlo de una lista de entre los alumnos inscritos en la asignatura.
+
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 17.27.1 (2017-12-20)"
+#define Log_PLATFORM_VERSION "SWAD 18.0 (2018-10-04)"
#define CSS_FILE "swad17.25.4.css"
#define JS_FILE "swad17.17.1.js"
+// Size of photos:
+// find -iname '*.jpg' -exec du -cb {} + | grep total$ | cut -f1 | paste -sd+ - | bc
+// find -iname '*original.jpg' -exec du -cb {} + | grep total$ | cut -f1 | paste -sd+ - | bc
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/* Printing:
@@ -343,6 +359,8 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
/*
+ Version 18.0: Oct 04, 2018 New version of fotomaton, programmed by Daniel Calandria and Jesús Mesa.
+ Changes in code to avoid new warnings with GCC 7.3. (234736 lines)
Version 17.29: Apr 24, 2018 Code refactoring and bug fixing related to actions. (234579 lines)
Version 17.28: Jan 09, 2018 Added average of all test exams. (? lines)
Version 17.27.2: Dec 20, 2017 Changes displaying a game question. (234507 lines)
diff --git a/swad_config.h b/swad_config.h
index ee74f174..97907c56 100644
--- a/swad_config.h
+++ b/swad_config.h
@@ -432,7 +432,7 @@
/* Command to make image processing / face detection, programmed by Daniel J. Calandria-Hernández */
// %s must be substituted by temporary file with the image received:
-#define Cfg_COMMAND_FACE_DETECTION "./fotomaton options %s 540"
+#define Cfg_COMMAND_FACE_DETECTION "./fotomaton cascade.xml %s 540"
/* Commands to compute the average photo of a degree */
#define Cfg_COMMAND_DEGREE_PHOTO_MEDIAN "./foto_mediana"
diff --git a/swad_duplicate.c b/swad_duplicate.c
index 4af9b8d6..c1b53574 100644
--- a/swad_duplicate.c
+++ b/swad_duplicate.c
@@ -253,7 +253,7 @@ static void Dup_ListSimilarUsrs (void)
extern const char *Hlp_USERS_Duplicates_similar_users;
extern const char *Txt_Similar_users;
struct UsrData UsrDat;
- char Query[512];
+ char Query[512 + Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME * 3];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumUsrs;
diff --git a/swad_enrolment.c b/swad_enrolment.c
index 9d5f8ac3..96bae6ba 100644
--- a/swad_enrolment.c
+++ b/swad_enrolment.c
@@ -519,7 +519,8 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
{
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1];
- char Query[2048];
+ char *Query;
+ size_t CommentsLength;
/***** Check if user's code is initialized *****/
if (UsrDat->UsrCod <= 0)
@@ -530,6 +531,18 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
/***** Update user's common data *****/
Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB);
+ CommentsLength = strlen (UsrDat->Comments);
+ if ((Query = malloc (2048 +
+ Pwd_BYTES_ENCRYPTED_PASSWORD + // Password
+ Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME * 3 +// Surname1, Surname2, FirstName
+ Usr_MAX_BYTES_ADDRESS + // LocalAddress
+ Usr_MAX_BYTES_PHONE + // LocalPhone
+ Usr_MAX_BYTES_ADDRESS + // FamilyAddress
+ Usr_MAX_BYTES_PHONE + // FamilyPhone
+ Usr_MAX_BYTES_ADDRESS + // OriginPlace
+ Usr_BIRTHDAY_STR_DB_LENGTH + // BirthdayStrDB
+ CommentsLength)) == NULL) // Comments
+ Lay_ShowErrorAndExit ("Not enough memory to store query.");
sprintf (Query,"UPDATE usr_data"
" SET Password='%s',"
"Surname1='%s',Surname2='%s',FirstName='%s',Sex='%s',"
@@ -547,10 +560,11 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
UsrDat->FamilyAddress,UsrDat->FamilyPhone,
UsrDat->OriginPlace,
BirthdayStrDB,
- UsrDat->Comments ? UsrDat->Comments :
- "",
+ CommentsLength ? UsrDat->Comments :
+ "",
UsrDat->UsrCod);
DB_QueryUPDATE (Query,"can not update user's data");
+ free ((void *) Query);
}
/*****************************************************************************/
diff --git a/swad_file_browser.c b/swad_file_browser.c
index 7553e95e..c4ebd15b 100644
--- a/swad_file_browser.c
+++ b/swad_file_browser.c
@@ -2717,7 +2717,7 @@ void Brw_InitializeFileBrowser (void)
static void Brw_SetPathFileBrowser (void)
{
- char Path[PATH_MAX + 1];
+ char Path[PATH_MAX*2 + 128];
/***** Reset paths. An empty path means that
we don't have to create that directory *****/
@@ -2813,9 +2813,12 @@ static void Brw_SetPathFileBrowser (void)
Fil_CreateDirIfNotExists (Path);
/* Create path to this group */
- sprintf (Gbl.FileBrowser.Priv.PathAboveRootFolder,"%s/%s/%ld",
+ sprintf (Path,"%s/%s/%ld",
Gbl.CurrentCrs.PathPriv,Cfg_FOLDER_GRP,
Gbl.CurrentCrs.Grps.GrpCod);
+ Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ Path,
+ PATH_MAX);
break;
case Brw_ADMI_ASG_USR:
case Brw_ADMI_WRK_USR:
@@ -2832,11 +2835,14 @@ static void Brw_SetPathFileBrowser (void)
Fil_CreateDirIfNotExists (Path);
/* Create path to me */
- sprintf (Gbl.FileBrowser.Priv.PathAboveRootFolder,"%s/%s/%02u/%ld",
+ sprintf (Path,"%s/%s/%02u/%ld",
Gbl.CurrentCrs.PathPriv,Cfg_FOLDER_USR,
(unsigned) (Gbl.Usrs.Me.UsrDat.UsrCod % 100),
Gbl.Usrs.Me.UsrDat.UsrCod);
- break;
+ Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ Path,
+ PATH_MAX);
+ break;
case Brw_ADMI_ASG_CRS:
case Brw_ADMI_WRK_CRS:
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
@@ -2854,10 +2860,13 @@ static void Brw_SetPathFileBrowser (void)
Fil_CreateDirIfNotExists (Path);
/* Create path to user */
- sprintf (Gbl.FileBrowser.Priv.PathAboveRootFolder,"%s/%s/%02u/%ld",
+ sprintf (Path,"%s/%s/%02u/%ld",
Gbl.CurrentCrs.PathPriv,Cfg_FOLDER_USR,
(unsigned) (Gbl.Usrs.Other.UsrDat.UsrCod % 100),
Gbl.Usrs.Other.UsrDat.UsrCod);
+ Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ Path,
+ PATH_MAX);
}
break;
case Brw_ADMI_DOC_PRJ:
@@ -2875,10 +2884,13 @@ static void Brw_SetPathFileBrowser (void)
Fil_CreateDirIfNotExists (Path);
/* Create path to the current project */
- sprintf (Gbl.FileBrowser.Priv.PathAboveRootFolder,"%s/%s/%02u/%ld",
+ sprintf (Path,"%s/%s/%02u/%ld",
Gbl.CurrentCrs.PathPriv,Cfg_FOLDER_PRJ,
(unsigned) (Gbl.Prjs.PrjCod % 100),
Gbl.Prjs.PrjCod);
+ Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ Path,
+ PATH_MAX);
break;
case Brw_ADMI_BRF_USR:
Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
@@ -2893,9 +2905,12 @@ static void Brw_SetPathFileBrowser (void)
if (Gbl.FileBrowser.Priv.PathAboveRootFolder[0])
{
Fil_CreateDirIfNotExists (Gbl.FileBrowser.Priv.PathAboveRootFolder);
- sprintf (Gbl.FileBrowser.Priv.PathRootFolder,"%s/%s",
+ sprintf (Path,"%s/%s",
Gbl.FileBrowser.Priv.PathAboveRootFolder,
Brw_RootFolderInternalNames[Gbl.FileBrowser.Type]);
+ Str_Copy (Gbl.FileBrowser.Priv.PathRootFolder,
+ Path,
+ PATH_MAX);
Fil_CreateDirIfNotExists (Gbl.FileBrowser.Priv.PathRootFolder);
/***** If file browser is for assignments,
@@ -2920,7 +2935,7 @@ bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName)
unsigned NumUsrs;
unsigned NumUsr;
long UsrCod;
- char PathFolder[PATH_MAX + 1];
+ char PathFolder[PATH_MAX * 2 + 128];
bool FolderExists = false;
/***** Get all the users belonging to current course from database *****/
@@ -2967,8 +2982,9 @@ static void Brw_CreateFoldersAssignmentsIfNotExist (long ZoneUsrCod)
char Query[1024];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
- unsigned long NumRows,NumRow;
- char PathFolderAsg[PATH_MAX + 1];
+ unsigned long NumRows;
+ unsigned long NumRow;
+ char PathFolderAsg[PATH_MAX + 1 + PATH_MAX + 1];
/***** Get assignment folders from database *****/
sprintf (Query,"SELECT Folder FROM assignments"
@@ -2987,10 +3003,14 @@ static void Brw_CreateFoldersAssignmentsIfNotExist (long ZoneUsrCod)
{
/* Get next assignment with folder */
row = mysql_fetch_row (mysql_res);
-
- /* Create folder if not exists */
- sprintf (PathFolderAsg,"%s/%s",Gbl.FileBrowser.Priv.PathRootFolder,row[0]);
- Fil_CreateDirIfNotExists (PathFolderAsg);
+ if (row)
+ if (row[0]) // Not necessary, because folder name is checked in query to be not empty
+ {
+ /* Create folder if not exists */
+ sprintf (PathFolderAsg,"%s/%s",
+ Gbl.FileBrowser.Priv.PathRootFolder,row[0]);
+ Fil_CreateDirIfNotExists (PathFolderAsg);
+ }
}
/***** Free structure that stores the query result *****/
@@ -3016,8 +3036,8 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con
long UsrCod;
char OldPath[PATH_MAX + 1];
char NewPath[PATH_MAX + 1];
- char PathOldFolder[PATH_MAX + 1];
- char PathNewFolder[PATH_MAX + 1];
+ char PathOldFolder[PATH_MAX * 2 + 128];
+ char PathNewFolder[PATH_MAX * 2 + 128];
bool RenamingIsPossible = true;
unsigned NumUsrsError = 0;
unsigned NumUsrsSuccess = 0;
@@ -3135,7 +3155,7 @@ void Brw_RemoveFoldersAssignmentsIfExistForAllUsrs (const char *FolderName)
unsigned NumUsrs;
unsigned NumUsr;
long UsrCod;
- char PathFolder[PATH_MAX + 1];
+ char PathFolder[PATH_MAX * 2 + 128];
/***** Get all the users belonging to current course from database *****/
sprintf (Query,"SELECT UsrCod FROM crs_usr WHERE CrsCod=%ld",
@@ -4232,7 +4252,7 @@ static void Brw_WriteSubtitleOfFileBrowser (void)
extern const char *Txt_accessible_for_reading_and_writing_by_project_members;
extern const char *Txt_accessible_for_reading_and_writing_by_project_tutors_and_evaluators;
extern const char *Txt_nobody_else_can_access_this_content;
- char Subtitle[1024];
+ char Subtitle[1024 + Usr_MAX_BYTES_FULL_NAME];
/***** Form to change zone (course and group browsers) *****/
switch (Gbl.FileBrowser.Type)
@@ -6034,7 +6054,7 @@ static void Brw_PutIconsRemoveCopyPaste (unsigned Level,
static bool Brw_CheckIfCanPasteIn (unsigned Level)
{
- char PathDstWithFile[PATH_MAX + 1];
+ char PathDstWithFile[PATH_MAX + 1 + NAME_MAX + 1];
/***** If not in a folder... *****/
if (Gbl.FileBrowser.FileType != Brw_IS_FOLDER)
@@ -6058,9 +6078,12 @@ static bool Brw_CheckIfCanPasteIn (unsigned Level)
if (Gbl.FileBrowser.Clipboard.IsThisTree) // We are in the same tree of the clipboard ==> we can paste or not depending on the subtree
{
/***** Construct the name of the file or folder destination *****/
- sprintf (PathDstWithFile,"%s/%s",Gbl.FileBrowser.Priv.FullPathInTree,Gbl.FileBrowser.Clipboard.FileName);
+ sprintf (PathDstWithFile,"%s/%s",
+ Gbl.FileBrowser.Priv.FullPathInTree,
+ Gbl.FileBrowser.Clipboard.FileName);
- return !Str_Path1BeginsByPath2 (PathDstWithFile,Gbl.FileBrowser.Clipboard.Path);
+ return !Str_Path1BeginsByPath2 (PathDstWithFile,
+ Gbl.FileBrowser.Clipboard.Path);
}
return true; // I can paste
@@ -7040,7 +7063,7 @@ void Brw_RemFileFromTree (void)
{
extern const char *Txt_FILE_X_removed;
extern const char *Txt_You_can_not_remove_this_file_or_link;
- char Path[PATH_MAX + 1];
+ char Path[PATH_MAX + 1 + PATH_MAX + 1];
struct stat FileStatus;
char FileNameToShow[NAME_MAX + 1];
@@ -7049,7 +7072,9 @@ void Brw_RemFileFromTree (void)
if (Brw_CheckIfICanEditFileOrFolder (Gbl.FileBrowser.Level)) // Can I remove this file?
{
- sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree);
+ sprintf (Path,"%s/%s",
+ Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ Gbl.FileBrowser.Priv.FullPathInTree);
/***** Check if is a file/link or a folder *****/
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
@@ -7092,7 +7117,7 @@ void Brw_RemFolderFromTree (void)
{
extern const char *Txt_Folder_X_removed;
extern const char *Txt_You_can_not_remove_this_folder;
- char Path[PATH_MAX + 1];
+ char Path[PATH_MAX + 1 + PATH_MAX + 1];
struct stat FileStatus;
/***** Get parameters related to file browser *****/
@@ -7100,7 +7125,9 @@ void Brw_RemFolderFromTree (void)
if (Brw_CheckIfICanEditFileOrFolder (Gbl.FileBrowser.Level)) // Can I remove this folder?
{
- sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree);
+ sprintf (Path,"%s/%s",
+ Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ Gbl.FileBrowser.Priv.FullPathInTree);
/***** Check if it's a file or a folder *****/
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
@@ -7176,14 +7203,16 @@ static void Brw_PutParamsRemFolder (void)
void Brw_RemSubtreeInFileBrowser (void)
{
extern const char *Txt_Folder_X_and_all_its_contents_removed;
- char Path[PATH_MAX + 1];
+ char Path[PATH_MAX + 1 + PATH_MAX + 1];
/***** Get parameters related to file browser *****/
Brw_GetParAndInitFileBrowser ();
if (Brw_CheckIfICanEditFileOrFolder (Gbl.FileBrowser.Level)) // Can I remove this subtree?
{
- sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree);
+ sprintf (Path,"%s/%s",
+ Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ Gbl.FileBrowser.Priv.FullPathInTree);
/***** Remove the whole tree *****/
Fil_RemoveTree (Path);
@@ -7294,7 +7323,12 @@ static void Brw_WriteCurrentClipboard (void)
struct GroupData GrpDat;
struct Project Prj;
struct UsrData UsrDat;
- char TxtClipboardZone[1024];
+ char TxtClipboardZone[1024 +
+ Hie_MAX_BYTES_SHRT_NAME +
+ Grp_MAX_BYTES_GROUP_TYPE_NAME +
+ Grp_MAX_BYTES_GROUP_NAME +
+ Usr_MAX_BYTES_FULL_NAME +
+ Prj_MAX_BYTES_PROJECT_TITLE];
char FileNameToShow[NAME_MAX + 1];
const char *TxtFileType[Brw_NUM_FILE_TYPES] =
{
@@ -8276,7 +8310,7 @@ static void Brw_PasteClipboard (void)
struct Course Crs;
struct GroupData GrpDat;
long PrjCod;
- char PathOrg[PATH_MAX + 1];
+ char PathOrg[PATH_MAX + NAME_MAX + PATH_MAX + 128];
struct Brw_NumObjects Pasted;
long FirstFilCod = -1L; // First file code of the first file or link pasted. Important: initialize here to -1L
struct FileMetadata FileMetadata;
@@ -8491,8 +8525,8 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
char FileNameOrg[NAME_MAX + 1];
char FileNameToShow[NAME_MAX + 1];
char PathInFolderOrg[PATH_MAX + 1];
- char PathDstInTreeWithFile[PATH_MAX + 1];
- char PathDstWithFile[PATH_MAX + 1];
+ char PathDstInTreeWithFile[PATH_MAX + 1 + NAME_MAX + 1];
+ char PathDstWithFile[PATH_MAX + 1 + PATH_MAX + 1 + NAME_MAX + 1];
struct stat FileStatus;
struct dirent **FileList;
bool AdminMarks;
@@ -8532,7 +8566,9 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
sprintf (PathDstInTreeWithFile,"%s/%s",PathDstInTree,FileNameOrg);
/***** Construct the relative path of the destination file or folder *****/
- sprintf (PathDstWithFile,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,PathDstInTreeWithFile);
+ sprintf (PathDstWithFile,"%s/%s",
+ Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ PathDstInTreeWithFile);
/***** Update and check number of levels *****/
// The number of levels is counted starting on the root folder raíz, not included.
@@ -9009,8 +9045,8 @@ void Brw_RecFolderFileBrowser (void)
extern const char *Txt_Can_not_create_the_folder_X_because_there_is_already_a_folder_or_a_file_with_that_name;
extern const char *Txt_The_folder_X_has_been_created_inside_the_folder_Y;
extern const char *Txt_You_can_not_create_folders_here;
- char Path[PATH_MAX + 1];
- char PathCompleteInTreeIncludingFolder[PATH_MAX + 1];
+ char Path[PATH_MAX + 1 + PATH_MAX + 1];
+ char PathCompleteInTreeIncludingFolder[PATH_MAX + 1 + NAME_MAX + 1];
char FileNameToShow[NAME_MAX + 1];
/***** Get parameters related to file browser *****/
@@ -9022,7 +9058,9 @@ void Brw_RecFolderFileBrowser (void)
if (Str_ConvertFilFolLnkNameToValid (Gbl.FileBrowser.NewFilFolLnkName))
{
/* In Gbl.FileBrowser.NewFilFolLnkName is the name of the new folder */
- sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree);
+ sprintf (Path,"%s/%s",
+ Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ Gbl.FileBrowser.Priv.FullPathInTree);
if (strlen (Path) + 1 + strlen (Gbl.FileBrowser.NewFilFolLnkName) > PATH_MAX)
Lay_ShowErrorAndExit ("Path is too long.");
@@ -9053,7 +9091,9 @@ void Brw_RecFolderFileBrowser (void)
Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (Gbl.FileBrowser.Priv.FullPathInTree);
/* Add entry to the table of files/folders */
- sprintf (PathCompleteInTreeIncludingFolder,"%s/%s",Gbl.FileBrowser.Priv.FullPathInTree,Gbl.FileBrowser.NewFilFolLnkName);
+ sprintf (PathCompleteInTreeIncludingFolder,"%s/%s",
+ Gbl.FileBrowser.Priv.FullPathInTree,
+ Gbl.FileBrowser.NewFilFolLnkName);
Brw_AddPathToDB (Gbl.Usrs.Me.UsrDat.UsrCod,Brw_IS_FOLDER,
PathCompleteInTreeIncludingFolder,false,Brw_LICENSE_DEFAULT);
@@ -9106,10 +9146,10 @@ void Brw_RenFolderFileBrowser (void)
extern const char *Txt_The_folder_name_X_has_not_changed;
extern const char *Txt_The_folder_name_X_has_not_changed_because_there_is_already_a_folder_or_a_file_with_the_name_Y;
extern const char *Txt_You_can_not_rename_this_folder;
- char OldPathInTree[PATH_MAX + 1];
- char NewPathInTree[PATH_MAX + 1];
- char OldPath[PATH_MAX + 1];
- char NewPath[PATH_MAX + 1];
+ char OldPathInTree[PATH_MAX + 1 + NAME_MAX + 1];
+ char NewPathInTree[PATH_MAX + 1 + NAME_MAX + 1];
+ char OldPath[PATH_MAX + 1 + PATH_MAX + 1];
+ char NewPath[PATH_MAX + 1 + PATH_MAX + 1];
/***** Get parameters related to file browser *****/
Brw_GetParAndInitFileBrowser ();
@@ -9121,16 +9161,24 @@ void Brw_RenFolderFileBrowser (void)
if (strcmp (Gbl.FileBrowser.FilFolLnkName,Gbl.FileBrowser.NewFilFolLnkName)) // The name has changed
{
/* Gbl.FileBrowser.FilFolLnkName holds the new name of the folder */
- sprintf (OldPathInTree,"%s/%s",Gbl.FileBrowser.Priv.PathInTreeUntilFilFolLnk,Gbl.FileBrowser.FilFolLnkName);
- sprintf (OldPath,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,OldPathInTree);
+ sprintf (OldPathInTree,"%s/%s",
+ Gbl.FileBrowser.Priv.PathInTreeUntilFilFolLnk,
+ Gbl.FileBrowser.FilFolLnkName);
+ sprintf (OldPath,"%s/%s",
+ Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ OldPathInTree);
/* Gbl.FileBrowser.NewFilFolLnkName holds the new name of the folder */
if (strlen (Gbl.FileBrowser.Priv.PathAboveRootFolder) + 1 +
strlen (Gbl.FileBrowser.Priv.PathInTreeUntilFilFolLnk) + 1 +
strlen (Gbl.FileBrowser.NewFilFolLnkName) > PATH_MAX)
Lay_ShowErrorAndExit ("Path is too long.");
- sprintf (NewPathInTree,"%s/%s",Gbl.FileBrowser.Priv.PathInTreeUntilFilFolLnk,Gbl.FileBrowser.NewFilFolLnkName);
- sprintf (NewPath,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,NewPathInTree);
+ sprintf (NewPathInTree,"%s/%s",
+ Gbl.FileBrowser.Priv.PathInTreeUntilFilFolLnk,
+ Gbl.FileBrowser.NewFilFolLnkName);
+ sprintf (NewPath,"%s/%s",
+ Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ NewPathInTree);
/* We should check here that a folder with the same name does not exist.
but we leave this work to the system */
@@ -9261,9 +9309,9 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
struct Param *Param;
char SrcFileName[PATH_MAX + 1];
char PathUntilFileName[PATH_MAX + 1];
- char Path[PATH_MAX + 1];
+ char Path[PATH_MAX + 1 + PATH_MAX + 1];
char PathTmp[PATH_MAX + 1];
- char PathCompleteInTreeIncludingFile[PATH_MAX + 1];
+ char PathCompleteInTreeIncludingFile[PATH_MAX + 1 + NAME_MAX + 1];
char MIMEType[Brw_MAX_BYTES_MIME_TYPE + 1];
bool AdminMarks;
bool FileIsValid = true;
@@ -9355,7 +9403,9 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (Gbl.FileBrowser.Priv.FullPathInTree);
/* Add entry to the table of files/folders */
- sprintf (PathCompleteInTreeIncludingFile,"%s/%s",Gbl.FileBrowser.Priv.FullPathInTree,Gbl.FileBrowser.NewFilFolLnkName);
+ sprintf (PathCompleteInTreeIncludingFile,"%s/%s",
+ Gbl.FileBrowser.Priv.FullPathInTree,
+ Gbl.FileBrowser.NewFilFolLnkName);
FilCod = Brw_AddPathToDB (Gbl.Usrs.Me.UsrDat.UsrCod,Brw_IS_FILE,
PathCompleteInTreeIncludingFile,false,Brw_LICENSE_DEFAULT);
@@ -9438,9 +9488,9 @@ void Brw_RecLinkFileBrowser (void)
size_t LengthURL;
char URLUntilLastFilename[PATH_MAX + 1];
char FileName[NAME_MAX + 1];
- char Path[PATH_MAX + 1];
+ char Path[PATH_MAX + 1 + PATH_MAX + 1];
FILE *FileURL;
- char PathCompleteInTreeIncludingFile[PATH_MAX + 1];
+ char PathCompleteInTreeIncludingFile[PATH_MAX + 1 + NAME_MAX + 1];
long FilCod = -1L; // Code of new file in database
char FileNameToShow[NAME_MAX + 1];
struct FileMetadata FileMetadata;
@@ -9488,7 +9538,9 @@ void Brw_RecLinkFileBrowser (void)
if (Str_ConvertFilFolLnkNameToValid (FileName)) // Gbl.Alert.Txt contains feedback text
{
/* The name of the file with the link will be the FileName.url */
- sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree);
+ sprintf (Path,"%s/%s",
+ Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ Gbl.FileBrowser.Priv.FullPathInTree);
if (strlen (Path) + 1 + strlen (FileName) + strlen (".url") > PATH_MAX)
Lay_ShowErrorAndExit ("Path is too long.");
Str_Concat (Path,"/",
@@ -9535,7 +9587,9 @@ void Brw_RecLinkFileBrowser (void)
Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (Gbl.FileBrowser.Priv.FullPathInTree);
/* Add entry to the table of files/folders */
- sprintf (PathCompleteInTreeIncludingFile,"%s/%s.url",Gbl.FileBrowser.Priv.FullPathInTree,FileName);
+ sprintf (PathCompleteInTreeIncludingFile,"%s/%s.url",
+ Gbl.FileBrowser.Priv.FullPathInTree,
+ FileName);
FilCod = Brw_AddPathToDB (Gbl.Usrs.Me.UsrDat.UsrCod,Brw_IS_LINK,
PathCompleteInTreeIncludingFile,false,Brw_LICENSE_DEFAULT);
@@ -10548,7 +10602,7 @@ static void Brw_WriteSmallLinkToDownloadFile (const char *URL,Brw_FileType_t Fil
void Brw_GetLinkToDownloadFile (const char *PathInTree,const char *FileName,char *URL)
{
- char FullPathIncludingFile[PATH_MAX + 1];
+ char FullPathIncludingFile[PATH_MAX + 1 + PATH_MAX + 1 + NAME_MAX + 1];
FILE *FileURL;
char URLWithSpaces[PATH_MAX + 1];
@@ -11048,7 +11102,7 @@ void Brw_GetFileMetadataByCod (struct FileMetadata *FileMetadata)
bool Brw_GetFileTypeSizeAndDate (struct FileMetadata *FileMetadata)
{
- char Path[PATH_MAX + 1];
+ char Path[PATH_MAX + 1 + PATH_MAX + 1];
struct stat FileStatus;
sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,
diff --git a/swad_global.c b/swad_global.c
index 41fedeed..e7c960b2 100644
--- a/swad_global.c
+++ b/swad_global.c
@@ -137,12 +137,13 @@ void Gbl_InitializeGlobals (void)
Gbl.Prefs.IconSet = Ico_ICON_SET_DEFAULT; // Default icon set
sprintf (Gbl.Prefs.IconsURL,"%s/%s",
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON);
- sprintf (Gbl.Prefs.PathTheme,"%s/%s/%s",
- Gbl.Prefs.IconsURL,
- Cfg_ICON_FOLDER_THEMES,
+ sprintf (Gbl.Prefs.PathTheme,"%s/%s/%s/%s",
+ Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON,
+ Cfg_ICON_FOLDER_THEMES,
The_ThemeId[Gbl.Prefs.Theme]);
- sprintf (Gbl.Prefs.PathIconSet,"%s/%s/%s",
- Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_ICON_SETS,
+ sprintf (Gbl.Prefs.PathIconSet,"%s/%s/%s/%s",
+ Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON,
+ Cfg_ICON_FOLDER_ICON_SETS,
Ico_IconSetId[Gbl.Prefs.IconSet]);
Gbl.Session.NumSessions = 0;
diff --git a/swad_global.h b/swad_global.h
index 851b8cca..68f38d91 100644
--- a/swad_global.h
+++ b/swad_global.h
@@ -121,8 +121,8 @@ struct Globals
Act_CONT_DATA (if CONTENT_TYPE==multipart/form-data) */
struct
{
- char StrWithoutCRLF[Par_MAX_BYTES_BOUNDARY_WITH_CR_LF + 1];
- char StrWithCRLF [Par_MAX_BYTES_BOUNDARY_WITH_CR_LF + 1];
+ char StrWithoutCRLF[Par_MAX_BYTES_BOUNDARY_WITHOUT_CR_LF + 1];
+ char StrWithCRLF [Par_MAX_BYTES_BOUNDARY_WITH_CR_LF + 1];
size_t LengthWithoutCRLF;
size_t LengthWithCRLF;
} Boundary;
diff --git a/swad_group.c b/swad_group.c
index 901466a4..7273c02a 100644
--- a/swad_group.c
+++ b/swad_group.c
@@ -3808,7 +3808,7 @@ static bool Grp_CheckIfGroupNameExists (long GrpTypCod,const char *GrpName,long
static void Grp_CreateGroupType (void)
{
- char Query[1024];
+ char Query[1024 + Grp_MAX_BYTES_GROUP_TYPE_NAME];
/***** Create a new group type *****/
sprintf (Query,"INSERT INTO crs_grp_types"
diff --git a/swad_icon.c b/swad_icon.c
index bf0e3029..ec402512 100644
--- a/swad_icon.c
+++ b/swad_icon.c
@@ -125,8 +125,9 @@ void Ico_ChangeIconSet (void)
/***** Get param with icon set *****/
Gbl.Prefs.IconSet = Ico_GetParamIconSet ();
- sprintf (Gbl.Prefs.PathIconSet,"%s/%s/%s",
- Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_ICON_SETS,
+ sprintf (Gbl.Prefs.PathIconSet,"%s/%s/%s/%s",
+ Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON,
+ Cfg_ICON_FOLDER_ICON_SETS,
Ico_IconSetId[Gbl.Prefs.IconSet]);
/***** Store icon set in database *****/
diff --git a/swad_info.c b/swad_info.c
index a7cfea9e..c901988b 100644
--- a/swad_info.c
+++ b/swad_info.c
@@ -2278,9 +2278,9 @@ void Inf_ReceivePagInfo (void)
char SourceFileName[PATH_MAX + 1];
char PathRelDirHTML[PATH_MAX + 1];
char PathRelFileHTML[PATH_MAX + 1];
- char PathRelFileZIP[PATH_MAX + 1];
+ char PathRelFileZIP[PATH_MAX + 1 + NAME_MAX + 1];
char MIMEType[Brw_MAX_BYTES_MIME_TYPE + 1];
- char StrUnzip[100 + PATH_MAX * 2 + 1];
+ char StrUnzip[128 + PATH_MAX * 2 + 1];
bool WrongType = false;
bool FileIsOK = false;
diff --git a/swad_mail.c b/swad_mail.c
index c28635c8..507573f9 100644
--- a/swad_mail.c
+++ b/swad_mail.c
@@ -1641,7 +1641,10 @@ bool Mai_SendMailMsgToConfirmEmail (void)
extern const char *Txt_If_you_just_request_from_X_the_confirmation_of_your_email_Y_NO_HTML;
extern const char *Txt_Confirmation_of_your_email_NO_HTML;
extern const char *Txt_There_was_a_problem_sending_an_email_automatically;
- char Command[2048]; // Command to execute for sending an email
+ char Command[2048 +
+ Cfg_MAX_BYTES_SMTP_PASSWORD +
+ Cns_MAX_BYTES_EMAIL_ADDRESS +
+ PATH_MAX]; // Command to execute for sending an email
int ReturnCode;
/***** Create temporary file for mail content *****/
diff --git a/swad_mark.c b/swad_mark.c
index cd1e60af..549a475b 100644
--- a/swad_mark.c
+++ b/swad_mark.c
@@ -608,7 +608,8 @@ void Mrk_ShowMyMarks (void)
char FileNameUsrMarks[PATH_MAX + 1];
FILE *FileUsrMarks;
char PathMarksPriv[PATH_MAX + 1];
- char PathPrivate[PATH_MAX + 1];
+ char PathPrivate[PATH_MAX + 1 +
+ PATH_MAX + 1];
struct UsrData *UsrDat;
bool UsrIsOK = true;
@@ -618,7 +619,9 @@ void Mrk_ShowMyMarks (void)
/***** Get the path of the file of marks *****/
Brw_SetFullPathInTree (Gbl.FileBrowser.Priv.PathInTreeUntilFilFolLnk,
Gbl.FileBrowser.FilFolLnkName);
- sprintf (PathPrivate,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree);
+ sprintf (PathPrivate,"%s/%s",
+ Gbl.FileBrowser.Priv.PathAboveRootFolder,
+ Gbl.FileBrowser.Priv.FullPathInTree);
/***** Get number of rows of header or footer *****/
Mrk_GetNumRowsHeaderAndFooter (&Marks);
diff --git a/swad_notification.c b/swad_notification.c
index 69db65b0..069303cb 100644
--- a/swad_notification.c
+++ b/swad_notification.c
@@ -1597,7 +1597,10 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
long Cod;
struct Forum ForumSelected;
char ForumName[For_MAX_BYTES_FORUM_NAME + 1];
- char Command[2048]; // Command to execute for sending an email
+ char Command[2048 +
+ Cfg_MAX_BYTES_SMTP_PASSWORD +
+ Cns_MAX_BYTES_EMAIL_ADDRESS +
+ PATH_MAX]; // Command to execute for sending an email
int ReturnCode;
/***** Return 0 notifications and 0 mails when error *****/
diff --git a/swad_parameter.c b/swad_parameter.c
index cd962db4..26e10dc7 100644
--- a/swad_parameter.c
+++ b/swad_parameter.c
@@ -653,6 +653,9 @@ void Par_GetMainParameters (void)
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
long ActCod;
char Nickname[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
+ char Path[PATH_MAX + 1 +
+ NAME_MAX + 1 +
+ NAME_MAX + 2];
char LongStr[1 + 10 + 1];
/***** Reset codes of country, institution, centre, degree and course *****/
@@ -771,7 +774,8 @@ void Par_GetMainParameters (void)
case ActFrmLogInUsrAgd:
case ActLogInUsrAgd: // This action is necessary here when log in fails
Pwd_GetParamUsrPwdLogin ();
- // no break;
+ /* falls through */
+ /* no break */
case ActReqSndNewPwd:
case ActSndNewPwd:
Usr_GetParamUsrIdLogin ();
@@ -788,13 +792,17 @@ void Par_GetMainParameters (void)
Gbl.Prefs.Theme = The_THEME_DEFAULT;
/***** Set path of theme *****/
- sprintf (Gbl.Prefs.PathTheme,"%s/%s/%s",
+ sprintf (Path,"%s/%s/%s",
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_THEMES,The_ThemeId[Gbl.Prefs.Theme]);
+ Str_Copy (Gbl.Prefs.PathTheme,Path,
+ PATH_MAX);
/***** Set path of icon set *****/
- sprintf (Gbl.Prefs.PathIconSet,"%s/%s/%s",
+ sprintf (Path,"%s/%s/%s",
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_ICON_SETS,
Ico_IconSetId[Gbl.Prefs.IconSet]);
+ Str_Copy (Gbl.Prefs.PathIconSet,Path,
+ PATH_MAX);
}
/***** Get country if exists (from menu) *****/
diff --git a/swad_parameter.h b/swad_parameter.h
index 533ca4d9..16f613fe 100644
--- a/swad_parameter.h
+++ b/swad_parameter.h
@@ -34,7 +34,8 @@
/************************** Public types and constants ***********************/
/*****************************************************************************/
-#define Par_MAX_BYTES_BOUNDARY_WITH_CR_LF (128 - 1)
+#define Par_MAX_BYTES_BOUNDARY_WITHOUT_CR_LF (128 - 1)
+#define Par_MAX_BYTES_BOUNDARY_WITH_CR_LF (2 + Par_MAX_BYTES_BOUNDARY_WITHOUT_CR_LF)
struct StartLength
{
diff --git a/swad_password.c b/swad_password.c
index 9f020bf4..ea9c0de8 100644
--- a/swad_password.c
+++ b/swad_password.c
@@ -401,7 +401,10 @@ int Pwd_SendNewPasswordByEmail (char NewRandomPlainPassword[Pwd_MAX_BYTES_PLAIN_
{
extern const char *Txt_The_following_password_has_been_assigned_to_you_to_log_in_X_NO_HTML;
extern const char *Txt_New_password_NO_HTML[1 + Txt_NUM_LANGUAGES];
- char Command[2048]; // Command to execute for sending an email
+ char Command[2048 +
+ Cfg_MAX_BYTES_SMTP_PASSWORD +
+ Cns_MAX_BYTES_EMAIL_ADDRESS +
+ PATH_MAX]; // Command to execute for sending an email
int ReturnCode;
/***** Create temporary file for mail content *****/
diff --git a/swad_photo.c b/swad_photo.c
index 774671a1..f642c918 100644
--- a/swad_photo.c
+++ b/swad_photo.c
@@ -2381,7 +2381,7 @@ static void Pho_ShowDegreeAvgPhotoAndStat (struct Degree *Deg,
unsigned PhotoHeight;
char PathRelAvgPhoto[PATH_MAX + 1];
char PhotoURL[PATH_MAX + 1];
- char PhotoCaption[512];
+ char PhotoCaption[1024 + Hie_MAX_BYTES_SHRT_NAME];
bool ShowDegPhoto;
char IdCaption[Act_MAX_BYTES_ID];
diff --git a/swad_record.c b/swad_record.c
index 2fe1767c..264b8a7f 100644
--- a/swad_record.c
+++ b/swad_record.c
@@ -3008,6 +3008,7 @@ static void Rec_ShowRole (struct UsrData *UsrDat,
case Rol_NET: // Non-editing teacher in current course
case Rol_TCH: // Teacher in current course
DefaultRoleInForm = UsrDat->Roles.InCurrentCrs.Role;
+ break;
default: // User does not belong to current course
/* If there is a request of this user, default role is the requested role */
DefaultRoleInForm = Rol_GetRequestedRole (UsrDat->UsrCod);
diff --git a/swad_syllabus.c b/swad_syllabus.c
index cf05d9b5..094359b2 100644
--- a/swad_syllabus.c
+++ b/swad_syllabus.c
@@ -1404,7 +1404,11 @@ void Syl_ModifyItemSyllabus (void)
void Syl_BuildPathFileSyllabus (char *PathFile)
{
- sprintf (PathFile,"%s/%s",Gbl.Syllabus.PathDir,Cfg_SYLLABUS_FILENAME);
+ char Path[PATH_MAX + 1 + NAME_MAX + 1];
+
+ sprintf (Path,"%s/%s",Gbl.Syllabus.PathDir,Cfg_SYLLABUS_FILENAME);
+ Str_Copy (PathFile,Path,
+ PATH_MAX);
}
/*****************************************************************************/
diff --git a/swad_tab.c b/swad_tab.c
index e1f3050e..a4bf9cbe 100644
--- a/swad_tab.c
+++ b/swad_tab.c
@@ -358,16 +358,20 @@ void Tab_DisableIncompatibleTabs (void)
{
case TabSys:
Gbl.CurrentCty.Cty.CtyCod = -1L;
- // no break
+ /* falls through */
+ /* no break */
case TabCty:
Gbl.CurrentIns.Ins.InsCod = -1L;
- // no break
+ /* falls through */
+ /* no break */
case TabIns:
Gbl.CurrentCtr.Ctr.CtrCod = -1L;
- // no break
+ /* falls through */
+ /* no break */
case TabCtr:
Gbl.CurrentDeg.Deg.DegCod = -1L;
- // no break
+ /* falls through */
+ /* no break */
case TabDeg:
Gbl.CurrentCrs.Crs.CrsCod = -1L;
break;
diff --git a/swad_test.c b/swad_test.c
index f8345e65..0ee22209 100644
--- a/swad_test.c
+++ b/swad_test.c
@@ -5844,7 +5844,8 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
case Tst_ANS_MULTIPLE_CHOICE:
/* Get shuffle */
Gbl.Test.Shuffle = Par_GetParToBool ("Shuffle");
- // No break
+ /* falls through */
+ /* no break */
case Tst_ANS_TEXT:
/* Get the texts of the answers */
for (NumOpt = 0;
diff --git a/swad_theme.c b/swad_theme.c
index dc08f0dd..30c80d55 100644
--- a/swad_theme.c
+++ b/swad_theme.c
@@ -284,12 +284,19 @@ static void The_PutIconsTheme (void)
void The_ChangeTheme (void)
{
+ char Path[PATH_MAX + 1 +
+ NAME_MAX + 1 +
+ NAME_MAX + 1];
char Query[512];
/***** Get param theme *****/
Gbl.Prefs.Theme = The_GetParamTheme ();
- sprintf (Gbl.Prefs.PathTheme,"%s/%s/%s",
- Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_THEMES,The_ThemeId[Gbl.Prefs.Theme]);
+ sprintf (Path,"%s/%s/%s",
+ Gbl.Prefs.IconsURL,
+ Cfg_ICON_FOLDER_THEMES,
+ The_ThemeId[Gbl.Prefs.Theme]);
+ Str_Copy (Gbl.Prefs.PathTheme,Path,
+ PATH_MAX);
/***** Store theme in database *****/
if (Gbl.Usrs.Me.Logged)
diff --git a/swad_timetable.c b/swad_timetable.c
index ceb4777f..4e888c2c 100644
--- a/swad_timetable.c
+++ b/swad_timetable.c
@@ -1003,7 +1003,8 @@ static void TT_FillTimeTableFromDB (long UsrCod)
row[5],
Grp_MAX_BYTES_GROUP_NAME);
TT_TimeTable[Weekday][Interval].Columns[FirstFreeColumn].GrpCod = GrpCod;
- // no break;
+ /* falls through */
+ /* no break */
case TT_TUTORING_TIMETABLE:
Str_Copy (TT_TimeTable[Weekday][Interval].Columns[FirstFreeColumn].Place,
row[3],
diff --git a/swad_user.c b/swad_user.c
index 086587c7..b7552259 100644
--- a/swad_user.c
+++ b/swad_user.c
@@ -3157,6 +3157,9 @@ static void Usr_SetMyPrefsAndRoles (void)
{
extern const char *The_ThemeId[The_NUM_THEMES];
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
+ char Path[PATH_MAX + 1 +
+ NAME_MAX + 1 +
+ NAME_MAX + 1];
// In this point I am logged
@@ -3171,14 +3174,18 @@ static void Usr_SetMyPrefsAndRoles (void)
Gbl.Prefs.SideCols = Gbl.Usrs.Me.UsrDat.Prefs.SideCols;
Gbl.Prefs.Theme = Gbl.Usrs.Me.UsrDat.Prefs.Theme;
- sprintf (Gbl.Prefs.PathTheme,"%s/%s/%s",
+ sprintf (Path,"%s/%s/%s",
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_THEMES,
The_ThemeId[Gbl.Prefs.Theme]);
+ Str_Copy (Gbl.Prefs.PathTheme,Path,
+ PATH_MAX);
Gbl.Prefs.IconSet = Gbl.Usrs.Me.UsrDat.Prefs.IconSet;
- sprintf (Gbl.Prefs.PathIconSet,"%s/%s/%s",
+ sprintf (Path,"%s/%s/%s",
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_ICON_SETS,
Ico_IconSetId[Gbl.Prefs.IconSet]);
+ Str_Copy (Gbl.Prefs.PathIconSet,Path,
+ PATH_MAX);
/***** Construct the path to my directory *****/
Usr_ConstructPathUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Me.PathDir);
diff --git a/swad_zip.c b/swad_zip.c
index a21b4a17..09a7e936 100644
--- a/swad_zip.c
+++ b/swad_zip.c
@@ -157,8 +157,10 @@ void ZIP_CreateZIPAsgWrk (void)
extern const char *Txt_works_ZIP_FILE_NAME;
struct UsrData UsrDat;
const char *Ptr;
- char StrZip[100 + PATH_MAX * 2 + 1];
- char Path[PATH_MAX + 1];
+ char StrZip[128 + PATH_MAX];
+ char Path[PATH_MAX + 1 +
+ NAME_MAX + 1 +
+ NAME_MAX + 1];
int Result;
char FileNameZIP[NAME_MAX + 1];
char PathFileZIP[PATH_MAX + 1];
@@ -286,7 +288,7 @@ static void ZIP_CreateTmpDirForCompression (void)
static void ZIP_CreateDirCompressionUsr (struct UsrData *UsrDat)
{
char FullNameAndUsrID[NAME_MAX + 1];
- char PathFolderUsrInsideCrs[PATH_MAX + 1];
+ char PathFolderUsrInsideCrs[128 + PATH_MAX + NAME_MAX];
char LinkTmpUsr[PATH_MAX + 1];
char Link[PATH_MAX + 1];
unsigned NumTry;
@@ -403,9 +405,12 @@ static void ZIP_CompressFolderIntoZIP (void)
extern const char *Txt_The_folder_is_empty;
extern const char *Txt_The_contents_of_the_folder_are_too_big;
unsigned long long UncompressedSize;
- char StrZip[100 + PATH_MAX * 2 + 1];
- char Path[PATH_MAX + 1];
- char PathCompression[PATH_MAX + 1];
+ char StrZip[128 + PATH_MAX];
+ char Path[PATH_MAX + 1 +
+ PATH_MAX + 1];
+ char PathCompression[PATH_MAX + 1 +
+ NAME_MAX + 1 +
+ NAME_MAX + 1];
int Result;
char FileNameZIP[NAME_MAX + 1];
char PathFileZIP[PATH_MAX + 1];
|