From e327103aa905c37399b21318ab2a1e5148b2a48d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 13 Jan 2017 01:51:23 +0100 Subject: [PATCH] Version 16.112 --- css/swad16.111.5.css | 2 +- js/swad16.101.js | 2 +- swad_ID.c | 2 +- swad_ID.h | 2 +- swad_MFU.c | 2 +- swad_MFU.h | 2 +- swad_QR.c | 2 +- swad_QR.h | 2 +- swad_RSS.c | 2 +- swad_RSS.h | 2 +- swad_account.c | 14 ++- swad_account.h | 2 +- swad_action.c | 2 +- swad_action.h | 2 +- swad_agenda.c | 11 +- swad_agenda.h | 6 +- swad_announcement.c | 2 +- swad_announcement.h | 2 +- swad_assignment.c | 40 ++++--- swad_assignment.h | 7 +- swad_attendance.c | 72 +++--------- swad_attendance.h | 8 +- swad_banner.c | 40 ++++--- swad_banner.h | 10 +- swad_calendar.c | 2 +- swad_calendar.h | 2 +- swad_centre.c | 41 +++++-- swad_centre.h | 8 +- swad_changelog.h | 5 +- swad_chat.c | 202 +++++++++++++++++++++++++------- swad_chat.h | 2 +- swad_config.c | 2 +- swad_config.h | 2 +- swad_connected.c | 39 +++++-- swad_connected.h | 2 +- swad_constant.h | 22 ++-- swad_country.c | 65 +++++++---- swad_country.h | 9 +- swad_course.c | 60 ++++++---- swad_course.h | 7 +- swad_cryptography.c | 2 +- swad_cryptography.h | 2 +- swad_database.c | 2 +- swad_database.h | 2 +- swad_date.c | 9 +- swad_date.h | 5 +- swad_degree.c | 21 ++-- swad_degree.h | 18 +-- swad_degree_type.c | 8 +- swad_degree_type.h | 8 +- swad_department.c | 37 +++--- swad_department.h | 10 +- swad_duplicate.c | 2 +- swad_duplicate.h | 2 +- swad_enrollment.c | 12 +- swad_enrollment.h | 6 +- swad_exam.c | 13 ++- swad_exam.h | 7 +- swad_file.c | 2 +- swad_file.h | 2 +- swad_file_browser.c | 207 +++++++++++++++++++++------------ swad_file_browser.h | 4 +- swad_follow.c | 2 +- swad_follow.h | 2 +- swad_forum.c | 2 +- swad_forum.h | 2 +- swad_global.c | 2 +- swad_global.h | 44 +++---- swad_group.c | 24 ++-- swad_group.h | 14 +-- swad_help.c | 2 +- swad_help.h | 2 +- swad_hierarchy.c | 2 +- swad_hierarchy.h | 2 +- swad_holiday.c | 2 +- swad_holiday.h | 2 +- swad_icon.c | 2 +- swad_icon.h | 2 +- swad_image.c | 2 +- swad_image.h | 2 +- swad_indicator.c | 2 +- swad_indicator.h | 2 +- swad_info.c | 2 +- swad_info.h | 2 +- swad_institution.c | 2 +- swad_institution.h | 2 +- swad_layout.c | 2 +- swad_layout.h | 6 +- swad_link.c | 2 +- swad_link.h | 2 +- swad_logo.c | 2 +- swad_logo.h | 2 +- swad_mail.c | 2 +- swad_mail.h | 2 +- swad_main.c | 2 +- swad_mark.c | 2 +- swad_mark.h | 2 +- swad_menu.c | 2 +- swad_menu.h | 2 +- swad_message.c | 4 +- swad_message.h | 2 +- swad_network.c | 2 +- swad_network.h | 2 +- swad_nickname.c | 2 +- swad_nickname.h | 2 +- swad_notice.c | 2 +- swad_notice.h | 2 +- swad_notification.c | 13 +-- swad_notification.h | 4 +- swad_pagination.c | 2 +- swad_pagination.h | 2 +- swad_parameter.c | 2 +- swad_parameter.h | 2 +- swad_password.c | 2 +- swad_password.h | 2 +- swad_photo.c | 8 +- swad_photo.h | 2 +- swad_place.c | 2 +- swad_place.h | 2 +- swad_plugin.c | 2 +- swad_plugin.h | 2 +- swad_preference.c | 2 +- swad_preference.h | 2 +- swad_privacy.c | 2 +- swad_privacy.h | 2 +- swad_privacy_visibility_type.h | 2 +- swad_profile.c | 2 +- swad_profile.h | 2 +- swad_record.c | 4 +- swad_record.h | 2 +- swad_report.c | 2 +- swad_report.h | 2 +- swad_role.c | 2 +- swad_role.h | 2 +- swad_role_type.h | 2 +- swad_scope.c | 2 +- swad_scope.h | 2 +- swad_search.c | 2 +- swad_search.h | 2 +- swad_session.c | 2 +- swad_session.h | 2 +- swad_setup.c | 2 +- swad_setup.h | 2 +- swad_social.c | 10 +- swad_social.h | 2 +- swad_statistic.c | 2 +- swad_statistic.h | 2 +- swad_string.c | 20 ++-- swad_string.h | 2 +- swad_survey.c | 6 +- swad_survey.h | 2 +- swad_syllabus.c | 2 +- swad_syllabus.h | 2 +- swad_tab.c | 2 +- swad_tab.h | 2 +- swad_test.c | 2 +- swad_test.h | 2 +- swad_test_import.c | 2 +- swad_test_import.h | 2 +- swad_text.c | 2 +- swad_text.h | 2 +- swad_theme.c | 2 +- swad_theme.h | 2 +- swad_timetable.c | 2 +- swad_timetable.h | 2 +- swad_user.c | 12 +- swad_user.h | 28 +++-- swad_web_service.c | 81 ++++++------- swad_web_service.h | 2 +- swad_xml.c | 2 +- swad_xml.h | 2 +- swad_zip.c | 4 +- swad_zip.h | 2 +- 173 files changed, 918 insertions(+), 643 deletions(-) diff --git a/css/swad16.111.5.css b/css/swad16.111.5.css index 20e6a699..a87919b5 100644 --- a/css/swad16.111.5.css +++ b/css/swad16.111.5.css @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/js/swad16.101.js b/js/swad16.101.js index 0bf920cb..14df9170 100644 --- a/js/swad16.101.js +++ b/js/swad16.101.js @@ -4,7 +4,7 @@ SWAD (Shared Workspace At a Distance), is a web platform developed at the University of Granada (Spain), and used to support university teaching. - Copyright (C) 1999-2016 Antonio Caņas-Vargas + Copyright (C) 1999-2017 Antonio Caņas-Vargas University of Granada (SPAIN) (acanas@ugr.es) This program is free software: you can redistribute it and/or modify diff --git a/swad_ID.c b/swad_ID.c index 64800cf6..64ac3ac9 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_ID.h b/swad_ID.h index 89ceca19..2eeafc1b 100644 --- a/swad_ID.h +++ b/swad_ID.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_MFU.c b/swad_MFU.c index 106db997..927de4b5 100644 --- a/swad_MFU.c +++ b/swad_MFU.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_MFU.h b/swad_MFU.h index 58791bd3..d33ee082 100644 --- a/swad_MFU.h +++ b/swad_MFU.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_QR.c b/swad_QR.c index 01733308..8b769a53 100644 --- a/swad_QR.c +++ b/swad_QR.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_QR.h b/swad_QR.h index e2b050fe..62a93704 100644 --- a/swad_QR.h +++ b/swad_QR.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_RSS.c b/swad_RSS.c index 3ca9201f..d60554b1 100644 --- a/swad_RSS.c +++ b/swad_RSS.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_RSS.h b/swad_RSS.h index d16ec978..98a98156 100644 --- a/swad_RSS.h +++ b/swad_RSS.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_account.c b/swad_account.c index 81831ecf..f3a5319e 100644 --- a/swad_account.c +++ b/swad_account.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as @@ -559,7 +559,9 @@ bool Acc_CreateMyNewAccountAndLogIn (void) Gbl.Usrs.Me.UsrDat.IDs.List = NULL; /***** Set password to the password typed by the user *****/ - strcpy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword); + strncpy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword, + Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64); + Gbl.Usrs.Me.UsrDat.Password[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64] = '\0'; /***** User does not exist in the platform, so create him/her! *****/ Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat, @@ -567,13 +569,17 @@ bool Acc_CreateMyNewAccountAndLogIn (void) /***** Save nickname *****/ Nck_UpdateMyNick (NewNicknameWithoutArroba); - strcpy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba); + strncpy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba, + Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA); + Gbl.Usrs.Me.UsrDat.Nickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA] = '\0'; /***** Save email *****/ if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail)) { /* Email updated sucessfully */ - strcpy (Gbl.Usrs.Me.UsrDat.Email,NewEmail); + strncpy (Gbl.Usrs.Me.UsrDat.Email,NewEmail,Usr_MAX_BYTES_USR_EMAIL); + Gbl.Usrs.Me.UsrDat.Email[Usr_MAX_BYTES_USR_EMAIL] = '\0'; + Gbl.Usrs.Me.UsrDat.EmailConfirmed = false; } diff --git a/swad_account.h b/swad_account.h index a512230e..7b0dcb88 100644 --- a/swad_account.h +++ b/swad_account.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_action.c b/swad_action.c index 557b2136..09ef7682 100644 --- a/swad_action.c +++ b/swad_action.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_action.h b/swad_action.h index d302ff59..0c436f55 100644 --- a/swad_action.h +++ b/swad_action.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_agenda.c b/swad_agenda.c index 462680c7..de24423a 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as @@ -947,10 +947,12 @@ static void Agd_GetDataOfEventByCod (struct AgendaEvent *AgdEvent) Dat_PRESENT)); /* Get the event (row[7]) */ - strcpy (AgdEvent->Event,row[7]); + strncpy (AgdEvent->Event,row[7],Agd_MAX_LENGTH_EVENT); + AgdEvent->Event[Agd_MAX_LENGTH_EVENT] = '\0'; /* Get the event (row[8]) */ - strcpy (AgdEvent->Location,row[8]); + strncpy (AgdEvent->Location,row[8],Agd_MAX_LENGTH_LOCATION); + AgdEvent->Location[Agd_MAX_LENGTH_LOCATION] = '\0'; } else { @@ -1007,7 +1009,8 @@ static void Agd_GetEventTxtFromDB (struct AgendaEvent *AgdEvent,char *Txt) { /* Get info text */ row = mysql_fetch_row (mysql_res); - strcpy (Txt,row[0]); + strncpy (Txt,row[0],Cns_MAX_BYTES_TEXT); + Txt[Cns_MAX_BYTES_TEXT] = '\0'; } else Txt[0] = '\0'; diff --git a/swad_agenda.h b/swad_agenda.h index 34e5234d..f0f049b0 100644 --- a/swad_agenda.h +++ b/swad_agenda.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -34,8 +34,8 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Agd_MAX_LENGTH_LOCATION 255 -#define Agd_MAX_LENGTH_EVENT 255 +#define Agd_MAX_LENGTH_LOCATION (256-1) +#define Agd_MAX_LENGTH_EVENT (256-1) #define Agd_NUM_DATES 2 typedef enum diff --git a/swad_announcement.c b/swad_announcement.c index e03fad75..a6e3fdcf 100644 --- a/swad_announcement.c +++ b/swad_announcement.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_announcement.h b/swad_announcement.h index 1d411286..214b8efd 100644 --- a/swad_announcement.h +++ b/swad_announcement.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_assignment.c b/swad_assignment.c index 6c0dbb2b..1e2192ea 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -79,7 +79,7 @@ static void Asg_PutFormsToRemEditOneAsg (long AsgCod,bool Hidden); static void Asg_PutParams (void); static void Asg_GetDataOfAssignment (struct Assignment *Asg,const char *Query); static void Asg_ResetAssignment (struct Assignment *Asg); -static void Asg_GetAssignmentTxtFromDB (long AsgCod,char *Txt); +static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); static void Asg_PutParamAsgCod (long AsgCod); static bool Asg_CheckIfSimilarAssignmentExists (const char *Field,const char *Value,long AsgCod); static void Asg_ShowLstGrpsToEditAssignment (long AsgCod); @@ -434,8 +434,8 @@ static void Asg_WriteAsgAuthor (struct Assignment *Asg) { bool ShowPhoto = false; char PhotoURL[PATH_MAX+1]; - char FirstName[Usr_MAX_BYTES_NAME+1]; - char Surnames[2*(Usr_MAX_BYTES_NAME+1)]; + char FirstName[Usr_MAX_BYTES_NAME + 1]; + char Surnames[Usr_MAX_BYTES_SURNAMES + 1]; struct UsrData UsrDat; /***** Initialize structure with user's data *****/ @@ -452,8 +452,12 @@ static void Asg_WriteAsgAuthor (struct Assignment *Asg) "PHOTO15x20",Pho_ZOOM,false); /***** Write name *****/ - strcpy (FirstName,UsrDat.FirstName); - strcpy (Surnames,UsrDat.Surname1); + strncpy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME); + UsrDat.FirstName[Usr_MAX_BYTES_NAME] = '\0'; + + strncpy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES); + Surnames[Usr_MAX_BYTES_SURNAMES] = '\0'; + if (UsrDat.Surname2[0]) { strcat (Surnames," "); @@ -776,10 +780,13 @@ static void Asg_GetDataOfAssignment (struct Assignment *Asg,const char *Query) Asg->Open = (row[5][0] == '1'); /* Get the title of the assignment (row[6]) */ - strcpy (Asg->Title,row[6]); + strncpy (Asg->Title,row[6],Asg_MAX_LENGTH_ASSIGNMENT_TITLE); + Asg->Title[Asg_MAX_LENGTH_ASSIGNMENT_TITLE] = '\0'; /* Get the folder for the assignment files (row[7]) */ - strcpy (Asg->Folder,row[7]); + strncpy (Asg->Folder,row[7],Asg_MAX_LENGTH_FOLDER); + Asg->Folder[Asg_MAX_LENGTH_FOLDER] = '\0'; + Asg->SendWork = (Asg->Folder[0] != '\0'); /* Can I do this assignment? */ @@ -830,7 +837,7 @@ void Asg_FreeListAssignments (void) /******************** Get assignment text from database **********************/ /*****************************************************************************/ -static void Asg_GetAssignmentTxtFromDB (long AsgCod,char *Txt) +static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT + 1]) { char Query[512]; MYSQL_RES *mysql_res; @@ -848,7 +855,8 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char *Txt) { /* Get info text */ row = mysql_fetch_row (mysql_res); - strcpy (Txt,row[0]); + strncpy (Txt,row[0],Cns_MAX_BYTES_TEXT); + Txt[Cns_MAX_BYTES_TEXT] = '\0'; } else Txt[0] = '\0'; @@ -865,7 +873,7 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char *Txt) /*****************************************************************************/ // This function may be called inside a web service -void Asg_GetNotifAssignment (char *SummaryStr,char **ContentStr, +void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, long AsgCod,unsigned MaxChars,bool GetContent) { char Query[512]; @@ -887,16 +895,20 @@ void Asg_GetNotifAssignment (char *SummaryStr,char **ContentStr, row = mysql_fetch_row (mysql_res); /***** Get summary *****/ - strcpy (SummaryStr,row[0]); + strncpy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT); + SummaryStr[Cns_MAX_BYTES_TEXT] = '\0'; + if (MaxChars) Str_LimitLengthHTMLStr (SummaryStr,MaxChars); /***** Get content *****/ if (GetContent) { - if ((*ContentStr = (char *) malloc (512+Cns_MAX_BYTES_TEXT)) == NULL) + if ((*ContentStr = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Lay_ShowErrorAndExit ("Error allocating memory for notification content."); - strcpy (*ContentStr,row[1]); + + strncpy (*ContentStr,row[1],Cns_MAX_BYTES_TEXT); + (*ContentStr)[Cns_MAX_BYTES_TEXT] = '\0'; } } mysql_free_result (mysql_res); diff --git a/swad_assignment.h b/swad_assignment.h index 7ce63601..cd60bf41 100644 --- a/swad_assignment.h +++ b/swad_assignment.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -34,7 +34,7 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Asg_MAX_LENGTH_ASSIGNMENT_TITLE 255 +#define Asg_MAX_LENGTH_ASSIGNMENT_TITLE (256-1) #define Asg_MAX_LENGTH_FOLDER 32 @@ -75,7 +75,8 @@ void Asg_GetDataOfAssignmentByCod (struct Assignment *Asg); void Asg_GetDataOfAssignmentByFolder (struct Assignment *Asg); void Asg_FreeListAssignments (void); -void Asg_GetNotifAssignment (char *SummaryStr,char **ContentStr,long AsgCod,unsigned MaxChars,bool GetContent); +void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, + long AsgCod,unsigned MaxChars,bool GetContent); long Asg_GetParamAsgCod (void); void Asg_ReqRemAssignment (void); diff --git a/swad_attendance.c b/swad_attendance.c index 7248eb4c..3b15dcfc 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -89,7 +89,7 @@ static void Att_PutParams (void); static void Att_GetListAttEvents (Att_OrderTime_t Order); static void Att_GetDataOfAttEventByCodAndCheckCrs (struct AttendanceEvent *Att); static void Att_ResetAttendanceEvent (struct AttendanceEvent *Att); -static void Att_GetAttEventTxtFromDB (long AttCod,char *Txt); +static void Att_GetAttEventTxtFromDB (long AttCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); static bool Att_CheckIfSimilarAttEventExists (const char *Field,const char *Value,long AttCod); static void Att_ShowLstGrpsToEditAttEvent (long AttCod); static void Att_RemoveAllTheGrpsAssociatedToAnAttEvent (long AttCod); @@ -474,8 +474,8 @@ static void Att_WriteAttEventAuthor (struct AttendanceEvent *Att) { bool ShowPhoto = false; char PhotoURL[PATH_MAX+1]; - char FirstName[Usr_MAX_BYTES_NAME+1]; - char Surnames[2*(Usr_MAX_BYTES_NAME+1)]; + char FirstName[Usr_MAX_BYTES_NAME + 1]; + char Surnames[Usr_MAX_BYTES_SURNAMES + 1]; struct UsrData UsrDat; /***** Initialize structure with user's data *****/ @@ -492,8 +492,12 @@ static void Att_WriteAttEventAuthor (struct AttendanceEvent *Att) "PHOTO15x20",Pho_ZOOM,false); /***** Write name *****/ - strcpy (FirstName,UsrDat.FirstName); - strcpy (Surnames,UsrDat.Surname1); + strncpy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME); + FirstName[Usr_MAX_BYTES_NAME] = '\0'; + + strncpy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES); + Surnames[Usr_MAX_BYTES_SURNAMES] = '\0'; + if (UsrDat.Surname2[0]) { strcat (Surnames," "); @@ -785,7 +789,8 @@ bool Att_GetDataOfAttEventByCod (struct AttendanceEvent *Att) Att->CommentTchVisible = (row[7][0] == 'Y'); /* Get the title of the attendance event (row[8]) */ - strcpy (Att->Title,row[8]); + strncpy (Att->Title,row[8],Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE); + Att->Title[Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE] = '\0'; } /***** Free structure that stores the query result *****/ @@ -836,7 +841,7 @@ void Att_FreeListAttEvents (void) /***************** Get attendance event text from database *******************/ /*****************************************************************************/ -static void Att_GetAttEventTxtFromDB (long AttCod,char *Txt) +static void Att_GetAttEventTxtFromDB (long AttCod,char Txt[Cns_MAX_BYTES_TEXT + 1]) { char Query[256]; MYSQL_RES *mysql_res; @@ -852,9 +857,12 @@ static void Att_GetAttEventTxtFromDB (long AttCod,char *Txt) /***** The result of the query must have one row or none *****/ if (NumRows == 1) { - /* Get info text */ + /* Get row */ row = mysql_fetch_row (mysql_res); - strcpy (Txt,row[0]); + + /* Get info text */ + strncpy (Txt,row[0],Cns_MAX_BYTES_TEXT); + Txt[Cns_MAX_BYTES_TEXT] = '\0'; } else Txt[0] = '\0'; @@ -866,48 +874,6 @@ static void Att_GetAttEventTxtFromDB (long AttCod,char *Txt) Lay_ShowErrorAndExit ("Error when getting attendance event text."); } -/*****************************************************************************/ -/************** Get summary and content of an attendance event ***************/ -/*****************************************************************************/ -// This function may be called inside a web service, so don't report error - -void Att_GetNotifAttEvent (char *SummaryStr,char **ContentStr,long AttCod,unsigned MaxChars,bool GetContent) - { - char Query[512]; - MYSQL_RES *mysql_res; - MYSQL_ROW row; - - SummaryStr[0] = '\0'; // Return nothing on error - - /***** Build query *****/ - sprintf (Query,"SELECT Title,Txt FROM att_events WHERE AttCod='%ld'", - AttCod); - if (!mysql_query (&Gbl.mysql,Query)) - if ((mysql_res = mysql_store_result (&Gbl.mysql)) != NULL) - { - /***** Result should have a unique row *****/ - if (mysql_num_rows (mysql_res) == 1) - { - /***** Get row *****/ - row = mysql_fetch_row (mysql_res); - - /***** Get summary *****/ - strcpy (SummaryStr,row[0]); - if (MaxChars) - Str_LimitLengthHTMLStr (SummaryStr,MaxChars); - - /***** Get content *****/ - if (GetContent) - { - if ((*ContentStr = (char *) malloc (512+Cns_MAX_BYTES_TEXT)) == NULL) - Lay_ShowErrorAndExit ("Error allocating memory for notification content."); - strcpy (*ContentStr,row[1]); - } - } - mysql_free_result (mysql_res); - } - } - /*****************************************************************************/ /************** Write parameter with code of attendance event ****************/ /*****************************************************************************/ @@ -1113,7 +1079,7 @@ void Att_RequestCreatOrEditAttEvent (void) extern const char *Txt_Save; struct AttendanceEvent Att; bool ItsANewAttEvent; - char Txt[Cns_MAX_BYTES_TEXT+1]; + char Txt[Cns_MAX_BYTES_TEXT + 1]; /***** Get parameters *****/ Att_GetParamAttOrderType (); diff --git a/swad_attendance.h b/swad_attendance.h index 48c98d2f..1d9e956d 100644 --- a/swad_attendance.h +++ b/swad_attendance.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -34,7 +34,7 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE 255 +#define Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE (256-1) #define Att_NUM_DATES 2 typedef enum @@ -51,7 +51,7 @@ struct AttendanceEvent long UsrCod; time_t TimeUTC[Att_NUM_DATES]; bool Open; - char Title[Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE+1]; + char Title[Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE + 1]; bool CommentTchVisible; unsigned NumStdsTotal; // Number total of students who have assisted to the event unsigned NumStdsFromList; // Number of students (taken from a list) who has assisted to the event @@ -76,8 +76,6 @@ void Att_RequestCreatOrEditAttEvent (void); bool Att_GetDataOfAttEventByCod (struct AttendanceEvent *Att); void Att_FreeListAttEvents (void); -void Att_GetNotifAttEvent (char *SummaryStr,char **ContentStr,long AsgCod,unsigned MaxChars,bool GetContent); - void Att_PutParamAttCod (long AttCod); long Att_GetParamAttCod (void); diff --git a/swad_banner.c b/swad_banner.c index bfc81d57..df917aa4 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -204,16 +204,20 @@ static void Ban_GetListBanners (const char *Query) Ban->Hidden = (row[1][0] == 'Y'); /* Get the short name of the banner (row[2]) */ - strcpy (Ban->ShrtName,row[2]); + strncpy (Ban->ShrtName,row[2],Ban_MAX_LENGTH_SHRT_NAME); + Ban->ShrtName[Ban_MAX_LENGTH_SHRT_NAME] = '\0'; /* Get the full name of the banner (row[3]) */ - strcpy (Ban->FullName,row[3]); + strncpy (Ban->FullName,row[3],Ban_MAX_LENGTH_FULL_NAME); + Ban->FullName[Ban_MAX_LENGTH_FULL_NAME] = '\0'; /* Get the image of the banner (row[4]) */ - strcpy (Ban->Img,row[4]); + strncpy (Ban->Img,row[4],Ban_MAX_LENGTH_IMAGE); + Ban->Img[Ban_MAX_LENGTH_IMAGE] = '\0'; /* Get the URL of the banner (row[5]) */ - strcpy (Ban->WWW,row[5]); + strncpy (Ban->WWW,row[5],Cns_MAX_LENGTH_WWW); + Ban->WWW[Cns_MAX_LENGTH_WWW] = '\0'; } } else @@ -257,16 +261,20 @@ void Ban_GetDataOfBannerByCod (struct Banner *Ban) Ban->Hidden = (row[0][0] == 'Y'); /* Get the short name of the banner (row[1]) */ - strcpy (Ban->ShrtName,row[1]); + strncpy (Ban->ShrtName,row[1],Ban_MAX_LENGTH_SHRT_NAME); + Ban->ShrtName[Ban_MAX_LENGTH_SHRT_NAME] = '\0'; /* Get the full name of the banner (row[2]) */ - strcpy (Ban->FullName,row[2]); + strncpy (Ban->FullName,row[2],Ban_MAX_LENGTH_FULL_NAME); + Ban->FullName[Ban_MAX_LENGTH_FULL_NAME] = '\0'; /* Get the image of the banner (row[3]) */ - strcpy (Ban->Img,row[3]); + strncpy (Ban->Img,row[3],Ban_MAX_LENGTH_IMAGE); + Ban->Img[Ban_MAX_LENGTH_IMAGE] = '\0'; /* Get the URL of the banner (row[4]) */ - strcpy (Ban->WWW,row[4]); + strncpy (Ban->WWW,row[4],Cns_MAX_LENGTH_WWW); + Ban->WWW[Cns_MAX_LENGTH_WWW] = '\0'; } /***** Free structure that stores the query result *****/ @@ -616,7 +624,9 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName) } /***** Show the form again *****/ - strcpy (CurrentBanName,NewBanName); + strncpy (CurrentBanName,NewBanName,MaxLength); + CurrentBanName[MaxLength] = '\0'; + Ban_EditBanners (); } @@ -673,7 +683,9 @@ void Ban_ChangeBannerImg (void) Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_image_empty); /***** Show the form again *****/ - strcpy (Ban->Img,NewImg); + strncpy (Ban->Img,NewImg,Ban_MAX_LENGTH_IMAGE); + Ban->Img[Ban_MAX_LENGTH_IMAGE] = '\0'; + Ban_EditBanners (); } @@ -687,7 +699,7 @@ void Ban_ChangeBannerWWW (void) extern const char *Txt_You_can_not_leave_the_web_address_empty; struct Banner *Ban; char Query[256+Cns_MAX_LENGTH_WWW]; - char NewWWW[Cns_MAX_LENGTH_WWW+1]; + char NewWWW[Cns_MAX_LENGTH_WWW + 1]; Ban = &Gbl.Banners.EditingBan; @@ -716,7 +728,9 @@ void Ban_ChangeBannerWWW (void) Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty); /***** Show the form again *****/ - strcpy (Ban->WWW,NewWWW); + strncpy (Ban->WWW,NewWWW,Cns_MAX_LENGTH_WWW); + Ban->WWW[Cns_MAX_LENGTH_WWW] = '\0'; + Ban_EditBanners (); } diff --git a/swad_banner.h b/swad_banner.h index 67b9d1f6..d5af6548 100644 --- a/swad_banner.h +++ b/swad_banner.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -41,10 +41,10 @@ struct Banner { long BanCod; bool Hidden; - char ShrtName[Ban_MAX_LENGTH_SHRT_NAME+1]; - char FullName[Ban_MAX_LENGTH_FULL_NAME+1]; - char Img[Ban_MAX_LENGTH_IMAGE+1]; - char WWW[Cns_MAX_LENGTH_WWW+1]; + char ShrtName[Ban_MAX_LENGTH_SHRT_NAME + 1]; + char FullName[Ban_MAX_LENGTH_FULL_NAME + 1]; + char Img[Ban_MAX_LENGTH_IMAGE + 1]; + char WWW[Cns_MAX_LENGTH_WWW + 1]; }; /*****************************************************************************/ diff --git a/swad_calendar.c b/swad_calendar.c index 00affe93..25f39177 100644 --- a/swad_calendar.c +++ b/swad_calendar.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_calendar.h b/swad_calendar.h index 06a6a647..a4af1ea5 100644 --- a/swad_calendar.h +++ b/swad_calendar.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_centre.c b/swad_centre.c index 18194cbd..3c7a9d21 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -1038,13 +1038,16 @@ void Ctr_GetListCentres (long InsCod) Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]); /* Get the short name of the centre (row[5]) */ - strcpy (Ctr->ShrtName,row[5]); + strncpy (Ctr->ShrtName,row[5],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME); + Ctr->ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME] = '\0'; /* Get the full name of the centre (row[6]) */ - strcpy (Ctr->FullName,row[6]); + strncpy (Ctr->FullName,row[6],Ctr_MAX_LENGTH_CENTRE_FULL_NAME); + Ctr->FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME] = '\0'; /* Get the URL of the centre (row[7]) */ - strcpy (Ctr->WWW,row[7]); + strncpy (Ctr->WWW,row[7],Cns_MAX_LENGTH_WWW); + Ctr->WWW[Cns_MAX_LENGTH_WWW] = '\0'; /* Get number of users who claim to belong to this centre (row[8]) */ if (sscanf (row[8],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1) @@ -1133,13 +1136,16 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr) Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]); /* Get the short name of the centre (row[4]) */ - strcpy (Ctr->ShrtName,row[4]); + strncpy (Ctr->ShrtName,row[4],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME); + Ctr->ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME] = '\0'; /* Get the full name of the centre (row[5]) */ - strcpy (Ctr->FullName,row[5]); + strncpy (Ctr->FullName,row[5],Ctr_MAX_LENGTH_CENTRE_FULL_NAME); + Ctr->FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME] = '\0'; /* Get the URL of the centre (row[6]) */ - strcpy (Ctr->WWW,row[6]); + strncpy (Ctr->WWW,row[6],Cns_MAX_LENGTH_WWW); + Ctr->WWW[Cns_MAX_LENGTH_WWW] = '\0'; /* Get number of users who claim to belong to this centre (row[7]) */ if (sscanf (row[7],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1) @@ -1216,7 +1222,9 @@ void Ctr_GetShortNameOfCentreByCod (struct Centre *Ctr) { /***** Get the short name of this centre *****/ row = mysql_fetch_row (mysql_res); - strcpy (Ctr->ShrtName,row[0]); + + strncpy (Ctr->ShrtName,row[0],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME); + Ctr->ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME] = '\0'; } /***** Free structure that stores the query result *****/ @@ -1233,6 +1241,7 @@ static void Ctr_GetPhotoAttribution (long CtrCod,char **PhotoAttribution) char Query[128]; MYSQL_RES *mysql_res; MYSQL_ROW row; + size_t Length; /***** Free possible former photo attribution *****/ Ctr_FreePhotoAttribution (PhotoAttribution); @@ -1249,9 +1258,13 @@ static void Ctr_GetPhotoAttribution (long CtrCod,char **PhotoAttribution) if (row[0]) if (row[0][0]) { - if (((*PhotoAttribution) = (char *) malloc (strlen (row[0])+1)) == NULL) + Length = strlen (row[0]); + + if (((*PhotoAttribution) = (char *) malloc (Length + 1)) == NULL) Lay_ShowErrorAndExit ("Error allocating memory for photo attribution."); - strcpy (*PhotoAttribution,row[0]); + + strncpy (*PhotoAttribution,row[0],Length); + PhotoAttribution[Length] = '\0'; } } @@ -1999,7 +2012,9 @@ void Ctr_ChangeCtrWWW (void) { /***** Update database changing old WWW by new WWW *****/ Ctr_UpdateCtrWWWDB (Ctr->CtrCod,NewWWW); - strcpy (Ctr->WWW,NewWWW); + + strncpy (Ctr->WWW,NewWWW,Cns_MAX_LENGTH_WWW); + Ctr->WWW[Cns_MAX_LENGTH_WWW] = '\0'; /***** Write message to show the change made *****/ sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); @@ -2030,7 +2045,9 @@ void Ctr_ChangeCtrWWWInConfig (void) { /***** Update database changing old WWW by new WWW *****/ Ctr_UpdateCtrWWWDB (Gbl.CurrentCtr.Ctr.CtrCod,NewWWW); - strcpy (Gbl.CurrentCtr.Ctr.WWW,NewWWW); + + strncpy (Gbl.CurrentCtr.Ctr.WWW,NewWWW,Cns_MAX_LENGTH_WWW); + Gbl.CurrentCtr.Ctr.WWW[Cns_MAX_LENGTH_WWW] = '\0'; /***** Write message to show the change made *****/ sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); diff --git a/swad_centre.h b/swad_centre.h index 0ad01805..35479e16 100644 --- a/swad_centre.h +++ b/swad_centre.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -65,9 +65,9 @@ struct Centre long PlcCod; // Place code Ctr_Status_t Status; // Centre status long RequesterUsrCod; // User code of the person who requested the creation of this centre - char ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME+1]; - char FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME+1]; - char WWW[Cns_MAX_LENGTH_WWW+1]; + char ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME + 1]; + char FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME + 1]; + char WWW[Cns_MAX_LENGTH_WWW + 1]; unsigned NumUsrsWhoClaimToBelongToCtr; // Number of users who claim to belong in this centre struct ListDegrees Degs; // List of degrees in this centre unsigned NumCrss; // Number of courses in this centre diff --git a/swad_changelog.h b/swad_changelog.h index 78b7c2db..41c3a251 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -189,13 +189,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.111.16 (2016-12-30)" +#define Log_PLATFORM_VERSION "SWAD 16.112 (2017-01-13)" #define CSS_FILE "swad16.111.5.css" #define JS_FILE "swad16.101.js" // 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 /* + Version 16.112: Jan 13, 2017 Some strcpy changed to strncpy. (211415 lines) Version 16.111.16:Dec 30, 2016 Fixed minor bug in user's ID, reported by Coverity. (211185 lines) Version 16.111.15:Dec 30, 2016 Fixed bug in forums, reported by Coverity. (211182 lines) Version 16.111.14:Dec 29, 2016 Fixed bug in attendance events. (211189 lines) diff --git a/swad_chat.c b/swad_chat.c index 52b36bf3..4c51244c 100644 --- a/swad_chat.c +++ b/swad_chat.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -29,6 +29,7 @@ #include // For boolean type #include // For sprintf #include +#include // For MAX() #include "swad_chat.h" #include "swad_config.h" @@ -382,20 +383,20 @@ void Cht_OpenChatWindow (void) extern const char *Txt_Teachers_ABBREVIATION; extern const char *Txt_Degree; extern const char *Txt_Course; - char RoomCode [MAX_LENGTH_ROOM_CODE +1]; - char RoomShortName[MAX_LENGTH_ROOM_SHRT_NAME+1]; - char RoomFullName [MAX_LENGTH_ROOM_FULL_NAME +1]; - char UsrName[3*(Usr_MAX_BYTES_NAME+1)]; + char RoomCode [MAX_LENGTH_ROOM_CODE + 1]; + char RoomShortName[MAX_LENGTH_ROOM_SHRT_NAME + 1]; + char RoomFullName [MAX_LENGTH_ROOM_FULL_NAME + 1]; + char UsrName[Usr_MAX_BYTES_FULL_NAME + 1]; unsigned NumMyDeg; unsigned NumMyCrs; struct Degree Deg; struct Course Crs; - char ThisRoomCode [MAX_LENGTH_ROOM_CODE +1]; - char ThisRoomShortName[MAX_LENGTH_ROOM_SHRT_NAME+1]; - char ThisRoomFullName [MAX_LENGTH_ROOM_FULL_NAME +1]; - char ListRoomCodes [(3+Deg_MAX_DEGREES_PER_USR+Crs_MAX_COURSES_PER_USR)*MAX_LENGTH_ROOM_CODE +1]; - char ListRoomShortNames[(3+Deg_MAX_DEGREES_PER_USR+Crs_MAX_COURSES_PER_USR)*MAX_LENGTH_ROOM_SHRT_NAME+1]; - char ListRoomFullNames [(3+Deg_MAX_DEGREES_PER_USR+Crs_MAX_COURSES_PER_USR)*MAX_LENGTH_ROOM_FULL_NAME +1]; + char ThisRoomCode [MAX_LENGTH_ROOM_CODE + 1]; + char ThisRoomShortName[MAX_LENGTH_ROOM_SHRT_NAME + 1]; + char ThisRoomFullName [MAX_LENGTH_ROOM_FULL_NAME + 1]; + char ListRoomCodes [(2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_CODE + 1]; + char ListRoomShortNames[(2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_SHRT_NAME + 1]; + char ListRoomFullNames [(2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_FULL_NAME + 1]; FILE *FileChat; /***** Get the code and the nombre of the room *****/ @@ -415,45 +416,99 @@ void Cht_OpenChatWindow (void) Usr_GetMyCourses (); /***** Build my user's name *****/ - strcpy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1); + strncpy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME); + UsrName[Usr_MAX_BYTES_NAME] = '\0'; if (Gbl.Usrs.Me.UsrDat.Surname2[0]) { - strcat (UsrName," "); - strcat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2); + strncat (UsrName," ",1); + strncat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2,Usr_MAX_BYTES_NAME); } - strcat (UsrName,", "); - strcat (UsrName,Gbl.Usrs.Me.UsrDat.FirstName); + strncat (UsrName,", ",2); + strncat (UsrName,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME); /***** Build the lists of available rooms *****/ sprintf (ListRoomCodes,"#%s",RoomCode); - strcpy (ListRoomShortNames,RoomShortName); - strcpy (ListRoomFullNames ,RoomFullName); + + strncpy (ListRoomShortNames,RoomShortName,sizeof (ListRoomShortNames) - 1); + ListRoomShortNames[sizeof (ListRoomShortNames) - 1] = '\0'; + + strncpy (ListRoomFullNames ,RoomFullName,sizeof (ListRoomFullNames) - 1); + ListRoomFullNames[sizeof (ListRoomFullNames) - 1] = '\0'; + if (strcmp (RoomCode,"GBL_USR")) { - strcat (ListRoomCodes,"|#GBL_USR"); + strncat (ListRoomCodes,"|#GBL_USR", + MAX (0, + sizeof (ListRoomCodes) - 1 - + strlen (ListRoomCodes) - + strlen ("|#GBL_USR"))); + sprintf (RoomShortName,"|%s",Txt_SEX_PLURAL_Abc[Usr_SEX_ALL]); - strcat (ListRoomShortNames,RoomShortName); - sprintf (RoomFullName,"|%s (%s)",Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]); - strcat (ListRoomFullNames,RoomFullName); + strncat (ListRoomShortNames,RoomShortName, + MAX (0, + sizeof (ListRoomShortNames) - 1 - + strlen (ListRoomShortNames) - + strlen (RoomShortName))); + + sprintf (RoomFullName,"|%s (%s)", + Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]); + strncat (ListRoomFullNames,RoomFullName, + MAX (0, + sizeof (ListRoomFullNames) - 1 - + strlen (ListRoomFullNames) - + strlen (RoomFullName))); } + if (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT) if (strcmp (RoomCode,"GBL_STD")) { - strcat (ListRoomCodes,"|#GBL_STD"); + strncat (ListRoomCodes,"|#GBL_STD", + MAX (0, + sizeof (ListRoomCodes) - 1 - + strlen (ListRoomCodes) - + strlen ("|#GBL_STD"))); + sprintf (RoomShortName,"|%s",Txt_Students_ABBREVIATION); - strcat (ListRoomShortNames,RoomShortName); - sprintf (RoomFullName,"|%s (%s)",Txt_General,Txt_ROLES_PLURAL_abc[Rol_STUDENT][Usr_SEX_ALL]); - strcat (ListRoomFullNames,RoomFullName); + strncat (ListRoomShortNames,RoomShortName, + MAX (0, + sizeof (ListRoomShortNames) - 1 - + strlen (ListRoomShortNames) - + strlen (RoomShortName))); + + sprintf (RoomFullName,"|%s (%s)",Txt_General, + Txt_ROLES_PLURAL_abc[Rol_STUDENT][Usr_SEX_ALL]); + strncat (ListRoomFullNames,RoomFullName, + MAX (0, + sizeof (ListRoomFullNames) - 1 - + strlen (ListRoomFullNames) - + strlen (RoomFullName))); } + if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER) if (strcmp (RoomCode,"GBL_TCH")) { - strcat (ListRoomCodes,"|#GBL_TCH"); + strncat (ListRoomCodes,"|#GBL_TCH", + MAX (0, + sizeof (ListRoomCodes) - 1 - + strlen (ListRoomCodes) - + strlen ("|#GBL_TCH"))); + sprintf (RoomShortName,"|%s",Txt_Teachers_ABBREVIATION); - strcat (ListRoomShortNames,RoomShortName); - sprintf (RoomFullName,"|%s (%s)",Txt_General,Txt_ROLES_PLURAL_abc[Rol_TEACHER][Usr_SEX_ALL]); - strcat (ListRoomFullNames,RoomFullName); + strncat (ListRoomShortNames,RoomShortName, + MAX (0, + sizeof (ListRoomShortNames) - 1 - + strlen (ListRoomShortNames) - + strlen (RoomShortName))); + + sprintf (RoomFullName,"|%s (%s)", + Txt_General,Txt_ROLES_PLURAL_abc[Rol_TEACHER][Usr_SEX_ALL]); + strncat (ListRoomFullNames,RoomFullName, + MAX (0, + sizeof (ListRoomFullNames) - 1 - + strlen (ListRoomFullNames) - + strlen (RoomFullName))); } + for (NumMyDeg = 0; NumMyDeg < Gbl.Usrs.Me.MyDegs.Num; NumMyDeg++) @@ -461,22 +516,52 @@ void Cht_OpenChatWindow (void) sprintf (ThisRoomCode,"DEG_%ld",Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod); if (strcmp (RoomCode,ThisRoomCode)) { - strcat (ListRoomCodes,"|#"); - strcat (ListRoomCodes,ThisRoomCode); + strncat (ListRoomCodes,"|#", + MAX (0, + sizeof (ListRoomCodes) - 1 - + strlen (ListRoomCodes) - + strlen ("|#"))); + + strncat (ListRoomCodes,ThisRoomCode, + MAX (0, + sizeof (ListRoomCodes) - 1 - + strlen (ListRoomCodes) - + strlen (ThisRoomCode))); /* Get data of this degree */ Deg.DegCod = Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod; Deg_GetDataOfDegreeByCod (&Deg); sprintf (ThisRoomShortName,"%s",Deg.ShrtName); - strcat (ListRoomShortNames,"|"); - strcat (ListRoomShortNames,ThisRoomShortName); + + strncat (ListRoomShortNames,"|", + MAX (0, + sizeof (ListRoomShortNames) - 1 - + strlen (ListRoomShortNames) - + strlen ("|"))); + + strncat (ListRoomShortNames,ThisRoomShortName, + MAX (0, + sizeof (ListRoomShortNames) - 1 - + strlen (ListRoomShortNames) - + strlen (ThisRoomShortName))); sprintf (ThisRoomFullName,"%s %s",Txt_Degree,Deg.ShrtName); - strcat (ListRoomFullNames,"|"); - strcat (ListRoomFullNames,ThisRoomFullName); + + strncat (ListRoomFullNames,"|", + MAX (0, + sizeof (ListRoomFullNames) - 1 - + strlen (ListRoomFullNames) - + strlen ("|"))); + + strncat (ListRoomFullNames,ThisRoomFullName, + MAX (0, + sizeof (ListRoomFullNames) - 1 - + strlen (ListRoomFullNames) - + strlen (ThisRoomFullName))); } } + for (NumMyCrs = 0; NumMyCrs < Gbl.Usrs.Me.MyCrss.Num; NumMyCrs++) @@ -484,20 +569,53 @@ void Cht_OpenChatWindow (void) sprintf (ThisRoomCode,"CRS_%ld",Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod); if (strcmp (RoomCode,ThisRoomCode)) { - strcat (ListRoomCodes,"|#"); - strcat (ListRoomCodes,ThisRoomCode); + strncat (ListRoomCodes,"|#", + MAX (0, + sizeof (ListRoomCodes) - 1 - + strlen (ListRoomCodes) - + strlen ("|#"))); + + strncat (ListRoomCodes,ThisRoomCode, + MAX (0, + sizeof (ListRoomCodes) - 1 - + strlen (ListRoomCodes) - + strlen (ThisRoomCode))); /* Get data of this course */ Crs.CrsCod = Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod; Crs_GetDataOfCourseByCod (&Crs); sprintf (ThisRoomShortName,"%s",Crs.ShrtName); - strcat (ListRoomShortNames,"|"); - strcat (ListRoomShortNames,ThisRoomShortName); + strncat (ListRoomShortNames,"|", + MAX (0, + sizeof (ListRoomShortNames) - 1 - + strlen (ListRoomShortNames) - + strlen ("|"))); + + strncat (ListRoomShortNames,ThisRoomShortName, + MAX (0, + sizeof (ListRoomShortNames) - 1 - + strlen (ListRoomShortNames) - + strlen (ThisRoomShortName))); + + strncat (ListRoomShortNames,"|", + MAX (0, + sizeof (ListRoomShortNames) - 1 - + strlen (ListRoomShortNames) - + strlen (ThisRoomShortName))); sprintf (ThisRoomFullName,"%s %s",Txt_Course,Crs.ShrtName); - strcat (ListRoomFullNames,"|"); - strcat (ListRoomFullNames,ThisRoomFullName); + strncat (ListRoomFullNames,"|", + MAX (0, + sizeof (ListRoomFullNames) - 1 - + strlen (ListRoomFullNames) - + strlen ("|"))); + + strncat (ListRoomFullNames,"|", + MAX (0, + sizeof (ListRoomFullNames) - 1 - + strlen (ListRoomFullNames) - + strlen (ThisRoomFullName))); } } diff --git a/swad_chat.h b/swad_chat.h index c51ad081..9c989012 100644 --- a/swad_chat.h +++ b/swad_chat.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_config.c b/swad_config.c index 22a6912f..a4a5cf48 100644 --- a/swad_config.c +++ b/swad_config.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_config.h b/swad_config.h index 741ca8c6..bb68239f 100644 --- a/swad_config.h +++ b/swad_config.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_connected.c b/swad_connected.c index da683df5..dafe0aee 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -457,39 +457,56 @@ static void Con_ShowConnectedUsrsBelongingToLocation (void) { extern const char *The_ClassConnected[The_NUM_THEMES]; extern const char *Txt_from; - char LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR+1]; + char LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR + 1]; struct ConnectedUsrs Usrs; /***** Set location name depending on scope *****/ switch (Gbl.Scope.Current) { case Sco_SCOPE_SYS: // Show connected users in the whole platform - strcpy (LocationName,Cfg_PLATFORM_SHORT_NAME); + strncpy (LocationName,Cfg_PLATFORM_SHORT_NAME, + Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); + LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0'; break; case Sco_SCOPE_CTY: // Show connected users in the current country if (Gbl.CurrentCty.Cty.CtyCod <= 0) // There is no country selected return; - strcpy (LocationName,Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]); + + strncpy (LocationName,Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language], + Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); + LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0'; break; case Sco_SCOPE_INS: // Show connected users in the current institution if (Gbl.CurrentIns.Ins.InsCod <= 0) // There is no institution selected return; - strcpy (LocationName,Gbl.CurrentIns.Ins.ShrtName); + + strncpy (LocationName,Gbl.CurrentIns.Ins.ShrtName, + Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); + LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0'; break; case Sco_SCOPE_CTR: // Show connected users in the current centre if (Gbl.CurrentCtr.Ctr.CtrCod <= 0) // There is no centre selected return; - strcpy (LocationName,Gbl.CurrentCtr.Ctr.ShrtName); + + strncpy (LocationName,Gbl.CurrentCtr.Ctr.ShrtName, + Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); + LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0'; break; case Sco_SCOPE_DEG: // Show connected users in the current degree if (Gbl.CurrentDeg.Deg.DegCod <= 0) // There is no degree selected return; - strcpy (LocationName,Gbl.CurrentDeg.Deg.ShrtName); + + strncpy (LocationName,Gbl.CurrentDeg.Deg.ShrtName, + Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); + LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0'; break; case Sco_SCOPE_CRS: // Show connected users in the current course if (Gbl.CurrentCrs.Crs.CrsCod <= 0) // There is no course selected return; - strcpy (LocationName,Gbl.CurrentCrs.Crs.ShrtName); + + strncpy (LocationName,Gbl.CurrentCrs.Crs.ShrtName, + Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); + LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0'; break; default: return; @@ -541,7 +558,7 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void) extern const char *The_ClassConnected[The_NUM_THEMES]; extern const char *Txt_Connected_users; extern const char *Txt_from; - char CourseName[Crs_MAX_LENGTH_COURSE_SHRT_NAME+1]; + char CourseName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1]; struct ConnectedUsrs Usrs; if (Gbl.CurrentCrs.Crs.CrsCod <= 0) // There is no course selected @@ -558,7 +575,9 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void) Act_LinkFormSubmitUnique (Txt_Connected_users,The_ClassConnected[Gbl.Prefs.Theme]); /* Write total number of connected users belonging to the current course */ - strcpy (CourseName,Gbl.CurrentCrs.Crs.ShrtName); + strncpy (CourseName,Gbl.CurrentCrs.Crs.ShrtName, + Crs_MAX_LENGTH_COURSE_SHRT_NAME); + CourseName[Crs_MAX_LENGTH_COURSE_SHRT_NAME] = '\0'; Str_LimitLengthHTMLStr (CourseName,12); Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNKNOWN,&Usrs); fprintf (Gbl.F.Out,"%u %s %s", diff --git a/swad_connected.h b/swad_connected.h index c6a0be5d..26e2f993 100644 --- a/swad_connected.h +++ b/swad_connected.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_constant.h b/swad_constant.h index d74908cb..45465ad9 100644 --- a/swad_constant.h +++ b/swad_constant.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -33,24 +33,24 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ -#define Cns_MAX_LENGTH_WWW 255 // Max. length of a URL +#define Cns_MAX_LENGTH_WWW (256 - 1) // Max. length of a URL -#define Cns_MAX_LENGTH_IP 15 // Max. bytes of an IP address +#define Cns_MAX_LENGTH_IP (16 - 1) // Max. bytes of an IP address #define Cns_MAX_LENGTH_DATE (4+1+2+1+2) #define Cns_MAX_BYTES_DATE 19 // Examples: "20030614143857", "14/06/2003 14:38:57" -#define Cns_MAX_LENGTH_SUBJECT 255 -#define Cns_MAX_BYTES_SUBJECT (Cns_MAX_LENGTH_SUBJECT*Str_MAX_CHARACTER) +#define Cns_MAX_LENGTH_SUBJECT (256 - 1) +#define Cns_MAX_BYTES_SUBJECT (Cns_MAX_LENGTH_SUBJECT * Str_MAX_CHARACTER) -#define Cns_MAX_BYTES_TEXT ( 64*1024-1) // Used for subjects and other medium texts -#define Cns_MAX_BYTES_LONG_TEXT (256*1024-1) // Used for big contents +#define Cns_MAX_BYTES_TEXT ( 64*1024 - 1) // Used for subjects and other medium texts +#define Cns_MAX_BYTES_LONG_TEXT (256*1024 - 1) // Used for big contents -#define Cns_MAX_LENGTH_STRING 127 -#define Cns_MAX_BYTES_STRING 127 +#define Cns_MAX_LENGTH_STRING (128 - 1) +#define Cns_MAX_BYTES_STRING (128 - 1) -#define Cns_MAX_LENGTH_URL 127 -#define Cns_MAX_BYTES_URL 255 +#define Cns_MAX_LENGTH_URL (128 - 1) +#define Cns_MAX_BYTES_URL (256 - 1) /*****************************************************************************/ /******************************* Public types ********************************/ diff --git a/swad_country.c b/swad_country.c index 33d8ba21..45c7ac3b 100644 --- a/swad_country.c +++ b/swad_country.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -1049,7 +1049,9 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData) Cty->NumUsrs = 0; /* Get the name of the country in current language */ - strcpy (Cty->Name[Gbl.Prefs.Language],row[2]); + strncpy (Cty->Name[Gbl.Prefs.Language],row[2], + Cty_MAX_BYTES_COUNTRY_NAME); + Cty->Name[Gbl.Prefs.Language][Cty_MAX_BYTES_COUNTRY_NAME] = '\0'; break; case Cty_GET_EXTRA_DATA: /* Get the name of the country in several languages */ @@ -1057,8 +1059,13 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData) Lan <= Txt_NUM_LANGUAGES; Lan++) { - strcpy (Cty->Name[Lan],row[1+Lan]); - strcpy (Cty->WWW[Lan],row[1+Txt_NUM_LANGUAGES+Lan]); + strncpy (Cty->Name[Lan],row[1 + Lan], + Cty_MAX_BYTES_COUNTRY_NAME); + Cty->Name[Lan][Cty_MAX_BYTES_COUNTRY_NAME] = '\0'; + + strncpy (Cty->WWW[Lan],row[1 + Txt_NUM_LANGUAGES + Lan], + Cns_MAX_LENGTH_WWW); + Cty->WWW[Lan][Cns_MAX_LENGTH_WWW] = '\0'; } /* Get number of users who claim to belong to this country */ @@ -1223,7 +1230,11 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD Lan <= Txt_NUM_LANGUAGES; Lan++) if (Lan == Gbl.Prefs.Language) - strcpy (Cty->Name[Lan],Txt_Another_country); + { + strncpy (Cty->Name[Lan],Txt_Another_country, + Cty_MAX_BYTES_COUNTRY_NAME); + Cty->Name[Lan][Cty_MAX_BYTES_COUNTRY_NAME] = '\0'; + } else Cty->Name[Lan][0] = '\0'; return false; @@ -1294,8 +1305,12 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD { case Cty_GET_BASIC_DATA: /* Get name and WWW of the country in current language */ - strcpy (Cty->Name[Gbl.Prefs.Language],row[1]); - strcpy (Cty->WWW [Gbl.Prefs.Language],row[2]); + strncpy (Cty->Name[Gbl.Prefs.Language],row[1], + Cty_MAX_BYTES_COUNTRY_NAME); + Cty->Name[Gbl.Prefs.Language][Cty_MAX_BYTES_COUNTRY_NAME] = '\0'; + + strncpy (Cty->WWW[Gbl.Prefs.Language],row[2],Cns_MAX_LENGTH_WWW); + Cty->WWW[Gbl.Prefs.Language][Cns_MAX_LENGTH_WWW] = '\0'; break; case Cty_GET_EXTRA_DATA: /* Get name and WWW of the country in several languages */ @@ -1303,8 +1318,13 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD Lan <= Txt_NUM_LANGUAGES; Lan++) { - strcpy (Cty->Name[Lan],row[Lan]); - strcpy (Cty->WWW[Lan],row[Txt_NUM_LANGUAGES+Lan]); + strncpy (Cty->Name[Lan],row[Lan], + Cty_MAX_BYTES_COUNTRY_NAME); + Cty->Name[Lan][Cty_MAX_BYTES_COUNTRY_NAME] = '\0'; + + strncpy (Cty->WWW[Lan],row[Txt_NUM_LANGUAGES + Lan], + Cns_MAX_LENGTH_WWW); + Cty->WWW[Lan][Cns_MAX_LENGTH_WWW] = '\0'; } /* Get number of users who claim to belong to this country */ @@ -1373,6 +1393,7 @@ static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution) char Query[128]; MYSQL_RES *mysql_res; MYSQL_ROW row; + size_t Length; /***** Free possible former map attribution *****/ Cty_FreeMapAttribution (MapAttribution); @@ -1389,9 +1410,11 @@ static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution) if (row[0]) if (row[0][0]) { - if (((*MapAttribution) = (char *) malloc (strlen (row[0])+1)) == NULL) + Length = strlen (row[0]); + if (((*MapAttribution) = (char *) malloc (Length + 1)) == NULL) Lay_ShowErrorAndExit ("Error allocating memory for map attribution."); - strcpy (*MapAttribution,row[0]); + strncpy (*MapAttribution,row[0],Length); + MapAttribution[Length] = '\0'; } } @@ -1532,7 +1555,7 @@ static void Cty_ListCountriesForEdition (void) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_WWW\"" " onchange=\"document.getElementById('%s').submit();\" />", - Cty_MAX_LENGTH_COUNTRY_WWW, + Cns_MAX_LENGTH_WWW, Cty->WWW[Lan],Gbl.Form.Id); Act_FormEnd (); fprintf (Gbl.F.Out,"" @@ -1700,7 +1723,8 @@ void Cty_RenameCountry (void) } /***** Show the form again *****/ - strcpy (Cty->Name[Language],NewCtyName); + strncpy (Cty->Name[Language],NewCtyName,Cty_MAX_BYTES_COUNTRY_NAME); + Cty->Name[Language][Cty_MAX_BYTES_COUNTRY_NAME] = '\0'; Cty_EditCountries (); } @@ -1756,9 +1780,9 @@ void Cty_ChangeCtyWWW (void) { extern const char *Txt_The_new_web_address_is_X; extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES]; - char Query[256+Cty_MAX_LENGTH_COUNTRY_WWW]; + char Query[256+Cns_MAX_LENGTH_WWW]; struct Country *Cty; - char NewWWW[Cty_MAX_LENGTH_COUNTRY_WWW+1]; + char NewWWW[Cns_MAX_LENGTH_WWW+1]; Txt_Language_t Language; Cty = &Gbl.Ctys.EditingCty; @@ -1787,7 +1811,8 @@ void Cty_ChangeCtyWWW (void) Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); /***** Show the form again *****/ - strcpy (Cty->WWW[Language],NewWWW); + strncpy (Cty->WWW[Language],NewWWW,Cns_MAX_LENGTH_WWW); + Cty->WWW[Language][Cns_MAX_LENGTH_WWW] = '\0'; Cty_EditCountries (); } @@ -1909,7 +1934,7 @@ static void Cty_PutFormToCreateCountry (void) "" "", Txt_STR_LANG_ID[Lan], - Cty_MAX_LENGTH_COUNTRY_WWW, + Cns_MAX_LENGTH_WWW, Cty->WWW[Lan]); } @@ -2053,7 +2078,7 @@ void Cty_RecFormNewCountry (void) } sprintf (ParamName,"WWW_%s",Txt_STR_LANG_ID[Lan]); - Par_GetParToText (ParamName,Cty->WWW[Lan],Cty_MAX_LENGTH_COUNTRY_WWW); + Par_GetParToText (ParamName,Cty->WWW[Lan],Cns_MAX_LENGTH_WWW); } } } @@ -2079,8 +2104,8 @@ static void Cty_CreateCountry (struct Country *Cty) char SubQueryNam1[(1+Txt_NUM_LANGUAGES)*32]; char SubQueryNam2[(1+Txt_NUM_LANGUAGES)*Cty_MAX_BYTES_COUNTRY_NAME]; char SubQueryWWW1[(1+Txt_NUM_LANGUAGES)*32]; - char SubQueryWWW2[(1+Txt_NUM_LANGUAGES)*Cty_MAX_LENGTH_COUNTRY_WWW]; - char Query[1024+(1+Txt_NUM_LANGUAGES)*(32+Cty_MAX_BYTES_COUNTRY_NAME+32+Cty_MAX_LENGTH_COUNTRY_WWW)]; + char SubQueryWWW2[(1+Txt_NUM_LANGUAGES)*Cns_MAX_LENGTH_WWW]; + char Query[1024 + (1 + Txt_NUM_LANGUAGES) * (32 + Cty_MAX_BYTES_COUNTRY_NAME + 32 + Cns_MAX_LENGTH_WWW)]; /***** Create a new country *****/ SubQueryNam1[0] = '\0'; diff --git a/swad_country.h b/swad_country.h index b540c860..0468d6b9 100644 --- a/swad_country.h +++ b/swad_country.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -38,7 +38,6 @@ /*****************************************************************************/ #define Cty_MAX_BYTES_COUNTRY_NAME 255 -#define Cty_MAX_LENGTH_COUNTRY_WWW 255 #define Cty_MAX_LENGTH_MAP_ATTRIBUTION (4*1024) #define Cty_MAX_COUNTRS_PER_USR 10 // Used in list of my countries @@ -46,9 +45,9 @@ struct Country { long CtyCod; - char Alpha2[2+1]; - char Name[1+Txt_NUM_LANGUAGES][Cty_MAX_BYTES_COUNTRY_NAME+1]; - char WWW [1+Txt_NUM_LANGUAGES][Cty_MAX_LENGTH_COUNTRY_WWW+1]; + char Alpha2[2 + 1]; + char Name[1 + Txt_NUM_LANGUAGES][Cty_MAX_BYTES_COUNTRY_NAME + 1]; + char WWW [1 + Txt_NUM_LANGUAGES][Cns_MAX_LENGTH_WWW + 1]; unsigned NumUsrsWhoClaimToBelongToCty; unsigned NumInss; unsigned NumCtrs; diff --git a/swad_course.c b/swad_course.c index 3dca191c..dec25469 100644 --- a/swad_course.c +++ b/swad_course.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -105,6 +105,10 @@ static void Crs_UpdateCrsDegDB (long CrsCod,long DegCod); static void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear); +static void Crs_GetShortNamesByCod (long CrsCod, + char CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1], + char DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME + 1]); + static void Crs_EmptyCourseCompletely (long CrsCod); static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName); @@ -516,11 +520,11 @@ static void Crs_WriteListMyCoursesToSelectOne (void) struct Centre Ctr; struct Degree Deg; struct Course Crs; - char InsFullName[Ins_MAX_LENGTH_INSTIT_FULL_NAME+1]; - char CtrFullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME+1]; - char DegFullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME+1]; - char CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME+1]; - bool IsLastItemInLevel[1+5]; + char InsFullName[Ins_MAX_LENGTH_INSTIT_FULL_NAME + 1]; + char CtrFullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME + 1]; + char DegFullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME + 1]; + char CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME + 1]; + bool IsLastItemInLevel[1 + 5]; bool Highlight; // Highlight because degree, course, etc. is selected MYSQL_RES *mysql_resCty; MYSQL_RES *mysql_resIns; @@ -540,10 +544,10 @@ static void Crs_WriteListMyCoursesToSelectOne (void) unsigned NumCrss; char ActTxt[Act_MAX_LENGTH_ACTION_TXT+1]; char PathRelRSSFile[PATH_MAX+1]; - char ClassNormal[64]; + const char *ClassNormal; char ClassHighlight[64]; - strcpy (ClassNormal,The_ClassForm[Gbl.Prefs.Theme]); + ClassNormal = The_ClassForm[Gbl.Prefs.Theme]; sprintf (ClassHighlight,"%s LIGHT_BLUE",The_ClassFormDark[Gbl.Prefs.Theme]); /***** Table start *****/ @@ -639,7 +643,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Highlight ? ClassHighlight : ClassNormal,NULL); Log_DrawLogo (Sco_SCOPE_INS,Ins.InsCod,Ins.ShrtName,20,NULL,true); - strcpy (InsFullName,Ins.FullName); + strncpy (InsFullName,Ins.FullName,Ins_MAX_LENGTH_INSTIT_FULL_NAME); + InsFullName[Ins_MAX_LENGTH_INSTIT_FULL_NAME] = '\0'; Str_LimitLengthHTMLStr (InsFullName,Crs_MAX_BYTES_TXT_LINK); fprintf (Gbl.F.Out," %s",InsFullName); Act_FormEnd (); @@ -674,7 +679,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Highlight ? ClassHighlight : ClassNormal,NULL); Log_DrawLogo (Sco_SCOPE_CTR,Ctr.CtrCod,Ctr.ShrtName,20,NULL,true); - strcpy (CtrFullName,Ctr.FullName); + strncpy (CtrFullName,Ctr.FullName,Ctr_MAX_LENGTH_CENTRE_FULL_NAME); + CtrFullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME] = '\0'; Str_LimitLengthHTMLStr (CtrFullName,Crs_MAX_BYTES_TXT_LINK); fprintf (Gbl.F.Out," %s",CtrFullName); Act_FormEnd (); @@ -709,7 +715,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Highlight ? ClassHighlight : ClassNormal,NULL); Log_DrawLogo (Sco_SCOPE_DEG,Deg.DegCod,Deg.ShrtName,20,NULL,true); - strcpy (DegFullName,Deg.FullName); + strncpy (DegFullName,Deg.FullName,Deg_MAX_LENGTH_DEGREE_FULL_NAME); + DegFullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME] = '\0'; Str_LimitLengthHTMLStr (DegFullName,Crs_MAX_BYTES_TXT_LINK); fprintf (Gbl.F.Out," %s",DegFullName); Act_FormEnd (); @@ -749,7 +756,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Gbl.Prefs.IconsURL, Crs.ShrtName, Crs.FullName); - strcpy (CrsFullName,Crs.FullName); + strncpy (CrsFullName,Crs.FullName,Crs_MAX_LENGTH_COURSE_FULL_NAME); + CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME] = '\0'; Str_LimitLengthHTMLStr (CrsFullName,Crs_MAX_BYTES_TXT_LINK); fprintf (Gbl.F.Out," %s",CrsFullName); Act_FormEnd (); @@ -1091,8 +1099,8 @@ void Crs_WriteSelectorMyCourses (void) long CrsCod; long DegCod; long LastDegCod; - char CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME+1]; - char DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME+1]; + char CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1]; + char DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME + 1]; /***** Fill the list with the courses I belong to, if not filled *****/ if (Gbl.Usrs.Me.Logged) @@ -2130,7 +2138,9 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row) /******* Get the short names of degree and course from a course code *********/ /*****************************************************************************/ -void Crs_GetShortNamesByCod (long CrsCod,char *CrsShortName,char *DegShortName) +static void Crs_GetShortNamesByCod (long CrsCod, + char CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1], + char DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME + 1]) { char Query[512]; MYSQL_RES *mysql_res; @@ -2150,8 +2160,12 @@ void Crs_GetShortNamesByCod (long CrsCod,char *CrsShortName,char *DegShortName) { /***** Get the short name of this course *****/ row = mysql_fetch_row (mysql_res); - strcpy (CrsShortName,row[0]); - strcpy (DegShortName,row[1]); + + strncpy (CrsShortName,row[0],Crs_MAX_LENGTH_COURSE_SHRT_NAME); + CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME] = '\0'; + + strncpy (DegShortName,row[1],Deg_MAX_LENGTH_DEGREE_SHRT_NAME); + DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME] = '\0'; } /***** Free structure that stores the query result *****/ @@ -2376,7 +2390,9 @@ void Crs_ChangeInsCrsCod (void) else { Gbl.Error = true; - strcpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course); + strncpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course, + Lay_MAX_BYTES_ALERT); + Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0'; } } @@ -2582,7 +2598,9 @@ void Crs_ChangeCrsYear (void) else { Gbl.Error = true; - strcpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course); + strncpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course, + Lay_MAX_BYTES_ALERT); + Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0'; } } @@ -2738,7 +2756,9 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull else { Gbl.Error = true; - strcpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course); + strncpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course, + Lay_MAX_BYTES_ALERT); + Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0'; } } diff --git a/swad_course.h b/swad_course.h index 0e666fc3..34aca750 100644 --- a/swad_course.h +++ b/swad_course.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -39,9 +39,9 @@ #define Crs_MAX_COURSES_PER_USR 100 // Used in list of my courses and list of distinct courses in sent or received messages -#define Crs_LENGTH_INSTITUTIONAL_CRS_COD 7 +#define Crs_LENGTH_INSTITUTIONAL_CRS_COD 7 #define Crs_MAX_LENGTH_COURSE_SHRT_NAME 32 -#define Crs_MAX_LENGTH_COURSE_FULL_NAME 127 +#define Crs_MAX_LENGTH_COURSE_FULL_NAME (128 - 1) #define Crs_MIN_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 6 #define Crs_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 12 @@ -115,7 +115,6 @@ void Crs_RecFormNewCrs (void); void Crs_RemoveCourse (void); bool Crs_GetDataOfCourseByCod (struct Course *Crs); -void Crs_GetShortNamesByCod (long CrsCod,char *CrsShortName,char *DegShortName); void Crs_RemoveCourseCompletely (long CrsCod); void Crs_ChangeInsCrsCodInConfig (void); void Crs_ChangeInsCrsCod (void); diff --git a/swad_cryptography.c b/swad_cryptography.c index 3cfffe0b..75a50af9 100644 --- a/swad_cryptography.c +++ b/swad_cryptography.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_cryptography.h b/swad_cryptography.h index c94987f9..8f2bbe81 100644 --- a/swad_cryptography.h +++ b/swad_cryptography.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_database.c b/swad_database.c index 56823d12..eebffe46 100644 --- a/swad_database.c +++ b/swad_database.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_database.h b/swad_database.h index af6b4993..d61c9831 100644 --- a/swad_database.h +++ b/swad_database.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_date.c b/swad_date.c index ae9aede7..4e9a60fe 100644 --- a/swad_date.c +++ b/swad_date.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -142,8 +142,8 @@ bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDD) { if (sscanf (YYYYMMDD,"%04u%02u%02u",&(Date->Year),&(Date->Month),&(Date->Day)) == 3) { - strncpy (Date->YYYYMMDD,YYYYMMDD,4+2+2); - Date->YYYYMMDD[4+2+2] = '\0'; + strncpy (Date->YYYYMMDD,YYYYMMDD,Dat_LENGTH_YYYYMMDD); + Date->YYYYMMDD[Dat_LENGTH_YYYYMMDD] = '\0'; return true; } else @@ -1263,7 +1263,8 @@ void Dat_AssignDate (struct Date *DateDst,struct Date *DateSrc) DateDst->Month = DateSrc->Month; DateDst->Day = DateSrc->Day; DateDst->Week = DateSrc->Week; - strcpy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD); + strncpy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD,Dat_LENGTH_YYYYMMDD); + DateDst->YYYYMMDD[Dat_LENGTH_YYYYMMDD] = '\0'; } /*****************************************************************************/ diff --git a/swad_date.h b/swad_date.h index 1d39a46c..35d36dd4 100644 --- a/swad_date.h +++ b/swad_date.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -43,13 +43,14 @@ /******************************* Public types ********************************/ /*****************************************************************************/ +#define Dat_LENGTH_YYYYMMDD (4 + 2 + 2) struct Date { unsigned Day; unsigned Month; unsigned Year; unsigned Week; - char YYYYMMDD[4+2+2+1]; + char YYYYMMDD[Dat_LENGTH_YYYYMMDD + 1]; }; struct Time { diff --git a/swad_degree.c b/swad_degree.c index efeae6d8..2529a719 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -1738,13 +1738,16 @@ static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row) Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]); /***** Get degree short name (row[5]) *****/ - strcpy (Deg->ShrtName,row[5]); + strncpy (Deg->ShrtName,row[5],Deg_MAX_LENGTH_DEGREE_SHRT_NAME); + Deg->ShrtName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME] = '\0'; /***** Get degree full name (row[6]) *****/ - strcpy (Deg->FullName,row[6]); + strncpy (Deg->FullName,row[6],Deg_MAX_LENGTH_DEGREE_FULL_NAME); + Deg->FullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME] = '\0'; /***** Get WWW (row[7]) *****/ - strcpy (Deg->WWW,row[7]); + strncpy (Deg->WWW,row[7],Cns_MAX_LENGTH_WWW); + Deg->WWW[Cns_MAX_LENGTH_WWW] = '\0'; } /*****************************************************************************/ @@ -1768,7 +1771,9 @@ void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg) { /***** Get the short name of this degree *****/ row = mysql_fetch_row (mysql_res); - strcpy (Deg->ShrtName,row[0]); + + strncpy (Deg->ShrtName,row[0],Deg_MAX_LENGTH_DEGREE_SHRT_NAME); + Deg->ShrtName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME] = '\0'; } /***** Free structure that stores the query result *****/ @@ -2138,7 +2143,8 @@ void Deg_ChangeDegWWW (void) { /***** Update the table changing old WWW by new WWW *****/ Deg_UpdateDegWWWDB (Deg->DegCod,NewWWW); - strcpy (Deg->WWW,NewWWW); + strncpy (Deg->WWW,NewWWW,Cns_MAX_LENGTH_WWW); + Deg->WWW[Cns_MAX_LENGTH_WWW] = '\0'; /***** Write message to show the change made *****/ sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); @@ -2169,7 +2175,8 @@ void Deg_ChangeDegWWWInConfig (void) { /***** Update the table changing old WWW by new WWW *****/ Deg_UpdateDegWWWDB (Gbl.CurrentDeg.Deg.DegCod,NewWWW); - strcpy (Gbl.CurrentDeg.Deg.WWW,NewWWW); + strncpy (Gbl.CurrentDeg.Deg.WWW,NewWWW,Cns_MAX_LENGTH_WWW); + Gbl.CurrentDeg.Deg.WWW[Cns_MAX_LENGTH_WWW] = '\0'; /***** Write message to show the change made *****/ sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); diff --git a/swad_degree.h b/swad_degree.h index 53e53306..5bbf6095 100644 --- a/swad_degree.h +++ b/swad_degree.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -36,15 +36,15 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ -#define Deg_MAX_YEARS_PER_DEGREE 12 // Max number of academic years per degree +#define Deg_MAX_YEARS_PER_DEGREE 12 // Max number of academic years per degree -#define Deg_MAX_DEGREES_PER_USR 20 // Used in list of my degrees +#define Deg_MAX_DEGREES_PER_USR 20 // Used in list of my degrees -#define Deg_MAX_LENGTH_DEGREE_SHRT_NAME 32 -#define Deg_MAX_LENGTH_DEGREE_FULL_NAME 127 +#define Deg_MAX_LENGTH_DEGREE_SHRT_NAME 32 +#define Deg_MAX_LENGTH_DEGREE_FULL_NAME (128 - 1) #define Deg_MAX_LENGTH_LOCATION_SHORT_NAME 32 -#define Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR (Deg_MAX_LENGTH_LOCATION_SHORT_NAME*Str_MAX_LENGTH_SPEC_CHAR_HTML) +#define Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR (Deg_MAX_LENGTH_LOCATION_SHORT_NAME * Str_MAX_LENGTH_SPEC_CHAR_HTML) /*****************************************************************************/ /******************************* Public types ********************************/ @@ -73,9 +73,9 @@ struct Degree long CtrCod; // Centre code Deg_Status_t Status; // Degree status long RequesterUsrCod; // User code of the person who requested the creation of this degree - char ShrtName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME+1]; // Short name of degree - char FullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME+1]; // Full name of degree - char WWW[Cns_MAX_LENGTH_WWW+1]; + char ShrtName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME + 1]; // Short name of degree + char FullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME + 1]; // Full name of degree + char WWW[Cns_MAX_LENGTH_WWW + 1]; struct Course *LstCrss; // List of courses in this degree }; diff --git a/swad_degree_type.c b/swad_degree_type.c index b3a18759..1eba6465 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -650,7 +650,8 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp) row = mysql_fetch_row (mysql_res); /* Get the name of the degree type (row[0]) */ - strcpy (DegTyp->DegTypName,row[0]); + strncpy (DegTyp->DegTypName,row[0],Deg_MAX_LENGTH_DEGREE_TYPE_NAME); + DegTyp->DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME] = '\0'; /* Count number of degrees of this type */ DegTyp->NumDegs = DT_CountNumDegsOfType (DegTyp->DegTypCod); @@ -785,7 +786,8 @@ void DT_RenameDegreeType (void) } /***** Show the form again *****/ - strcpy (DegTyp->DegTypName,NewNameDegTyp); + strncpy (DegTyp->DegTypName,NewNameDegTyp,Deg_MAX_LENGTH_DEGREE_TYPE_NAME); + DegTyp->DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME] = '\0'; DT_ReqEditDegreeTypes (); } diff --git a/swad_degree_type.h b/swad_degree_type.h index 4e3253bd..ad92c947 100644 --- a/swad_degree_type.h +++ b/swad_degree_type.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -39,9 +39,9 @@ struct DegreeType { - long DegTypCod; // Degree type code - char DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME+1]; // Degree type name - unsigned NumDegs; // Number of degrees of this type + long DegTypCod; // Degree type code + char DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME + 1]; // Degree type name + unsigned NumDegs; // Number of degrees of this type }; /*****************************************************************************/ diff --git a/swad_department.c b/swad_department.c index 0abc725e..ae4611d0 100644 --- a/swad_department.c +++ b/swad_department.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -351,13 +351,16 @@ void Dpt_GetListDepartments (long InsCod) Lay_ShowErrorAndExit ("Wrong code of institution."); /* Get the short name of the department (row[2]) */ - strcpy (Dpt->ShrtName,row[2]); + strncpy (Dpt->ShrtName,row[2],MAX_LENGTH_DEPARTMENT_SHRT_NAME); + Dpt->ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME] = '\0'; /* Get the full name of the department (row[3]) */ - strcpy (Dpt->FullName,row[3]); + strncpy (Dpt->FullName,row[3],MAX_LENGTH_DEPARTMENT_FULL_NAME); + Dpt->FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME] = '\0'; /* Get the URL of the department (row[4]) */ - strcpy (Dpt->WWW,row[4]); + strncpy (Dpt->WWW,row[4],Cns_MAX_LENGTH_WWW); + Dpt->WWW[Cns_MAX_LENGTH_WWW] = '\0'; /* Get number of teachers in this department (row[5]) */ if (sscanf (row[5],"%u",&Dpt->NumTchs) != 1) @@ -391,8 +394,11 @@ void Dpt_GetDataOfDepartmentByCod (struct Department *Dpt) /***** Check if department code is correct *****/ if (Dpt->DptCod == 0) { - strcpy (Dpt->ShrtName,Txt_Another_department); - strcpy (Dpt->FullName,Txt_Another_department); + strncpy (Dpt->ShrtName,Txt_Another_department,MAX_LENGTH_DEPARTMENT_SHRT_NAME); + Dpt->ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME] = '\0'; + + strncpy (Dpt->FullName,Txt_Another_department,MAX_LENGTH_DEPARTMENT_FULL_NAME); + Dpt->FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME] = '\0'; } else if (Dpt->DptCod > 0) { @@ -424,13 +430,16 @@ void Dpt_GetDataOfDepartmentByCod (struct Department *Dpt) Dpt->InsCod = Str_ConvertStrCodToLongCod (row[0]); /* Get the short name of the department (row[1]) */ - strcpy (Dpt->ShrtName,row[1]); + strncpy (Dpt->ShrtName,row[1],MAX_LENGTH_DEPARTMENT_SHRT_NAME); + Dpt->ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME] = '\0'; /* Get the full name of the department (row[2]) */ - strcpy (Dpt->FullName,row[2]); + strncpy (Dpt->FullName,row[2],MAX_LENGTH_DEPARTMENT_FULL_NAME); + Dpt->FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME] = '\0'; /* Get the URL of the department (row[3]) */ - strcpy (Dpt->WWW,row[3]); + strncpy (Dpt->WWW,row[3],Cns_MAX_LENGTH_WWW); + Dpt->WWW[Cns_MAX_LENGTH_WWW] = '\0'; /* Get number of teachers in this department (row[4]) */ if (sscanf (row[4],"%u",&Dpt->NumTchs) != 1) @@ -716,9 +725,9 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName) struct Department *Dpt; const char *ParamName = NULL; // Initialized to avoid warning const char *FieldName = NULL; // Initialized to avoid warning - unsigned MaxLength = 0; // Initialized to avoid warning + size_t MaxLength = 0; // Initialized to avoid warning char *CurrentDptName = NULL; // Initialized to avoid warning - char NewDptName[MAX_LENGTH_DEPARTMENT_FULL_NAME+1]; + char NewDptName[MAX_LENGTH_DEPARTMENT_FULL_NAME + 1]; Dpt = &Gbl.Dpts.EditingDpt; switch (ShrtOrFullName) @@ -789,7 +798,8 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName) } /***** Show the form again *****/ - strcpy (CurrentDptName,NewDptName); + strncpy (CurrentDptName,NewDptName,MaxLength); + CurrentDptName[MaxLength] = '\0'; Dpt_EditDepartments (); } @@ -850,7 +860,8 @@ void Dpt_ChangeDptWWW (void) } /***** Show the form again *****/ - strcpy (Dpt->WWW,NewWWW); + strncpy (Dpt->WWW,NewWWW,Cns_MAX_LENGTH_WWW); + Dpt->WWW[Cns_MAX_LENGTH_WWW] = '\0'; Dpt_EditDepartments (); } diff --git a/swad_department.h b/swad_department.h index 3c251d1b..1d71fded 100644 --- a/swad_department.h +++ b/swad_department.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -32,15 +32,15 @@ /*****************************************************************************/ #define MAX_LENGTH_DEPARTMENT_SHRT_NAME 32 -#define MAX_LENGTH_DEPARTMENT_FULL_NAME 255 +#define MAX_LENGTH_DEPARTMENT_FULL_NAME (256 - 1) struct Department { long DptCod; long InsCod; - char ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME+1]; - char FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME+1]; - char WWW[Cns_MAX_LENGTH_WWW+1]; + char ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME + 1]; + char FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME + 1]; + char WWW[Cns_MAX_LENGTH_WWW + 1]; unsigned NumTchs; }; diff --git a/swad_duplicate.c b/swad_duplicate.c index 5df677df..efbc9c46 100644 --- a/swad_duplicate.c +++ b/swad_duplicate.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_duplicate.h b/swad_duplicate.h index 1e4de3e9..5886eab4 100644 --- a/swad_duplicate.h +++ b/swad_duplicate.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_enrollment.c b/swad_enrollment.c index 7a2fd083..e342dd6c 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as @@ -359,7 +359,7 @@ void Enr_ReqAcceptRegisterInCrs (void) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Enr_GetNotifEnrollment (char *SummaryStr, +void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], long CrsCod,long UsrCod, unsigned MaxChars) { @@ -396,7 +396,8 @@ void Enr_GetNotifEnrollment (char *SummaryStr, /* Role (row[0]) */ Role = Rol_ConvertUnsignedStrToRole (row[0]); - strcpy (SummaryStr,Txt_ROLES_SINGUL_Abc[Role][UsrDat.Sex]); + strncpy (SummaryStr,Txt_ROLES_SINGUL_Abc[Role][UsrDat.Sex],Cns_MAX_BYTES_TEXT); + SummaryStr[Cns_MAX_BYTES_TEXT] = '\0'; if (MaxChars) Str_LimitLengthHTMLStr (SummaryStr,MaxChars); @@ -1936,7 +1937,7 @@ void Enr_SignUpInCrs (void) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Enr_GetNotifEnrollmentRequest (char *SummaryStr,char **ContentStr, +void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, long ReqCod,unsigned MaxChars,bool GetContent) { extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; @@ -1972,7 +1973,8 @@ void Enr_GetNotifEnrollmentRequest (char *SummaryStr,char **ContentStr, /* Role (row[1]) */ DesiredRole = Rol_ConvertUnsignedStrToRole (row[1]); - strcpy (SummaryStr,Txt_ROLES_SINGUL_Abc[DesiredRole][UsrDat.Sex]); + strncpy (SummaryStr,Txt_ROLES_SINGUL_Abc[DesiredRole][UsrDat.Sex],Cns_MAX_BYTES_TEXT); + SummaryStr[Cns_MAX_BYTES_TEXT] = '\0'; if (MaxChars) Str_LimitLengthHTMLStr (SummaryStr,MaxChars); diff --git a/swad_enrollment.h b/swad_enrollment.h index 4abc6d92..bb1961a7 100644 --- a/swad_enrollment.h +++ b/swad_enrollment.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -79,7 +79,7 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, void Enr_WriteFormToReqAnotherUsrID (Act_Action_t NextAction); void Enr_ReqAcceptRegisterInCrs (void); -void Enr_GetNotifEnrollment (char *SummaryStr, +void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], long CrsCod,long UsrCod, unsigned MaxChars); void Enr_UpdateUsrData (struct UsrData *UsrDat); @@ -104,7 +104,7 @@ void Enr_RemAllStdsThisCrs (void); unsigned Enr_RemAllStdsInCrs (struct Course *Crs); void Enr_ReqSignUpInCrs (void); void Enr_SignUpInCrs (void); -void Enr_GetNotifEnrollmentRequest (char *SummaryStr,char **ContentStr, +void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, long ReqCod,unsigned MaxChars,bool GetContent); void Enr_AskIfRejectSignUp (void); void Enr_RejectSignUp (void); diff --git a/swad_exam.c b/swad_exam.c index d6ab600d..0385ba11 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -126,7 +126,11 @@ static long Exa_GetParamsExamAnnouncement (void) Par_GetParToText ("CrsName",Gbl.ExamAnnouncements.ExaDat.CrsFullName,Cns_MAX_BYTES_STRING); // If the parameter is not present or is empty, initialize the string to the full name of the current course if (!Gbl.ExamAnnouncements.ExaDat.CrsFullName[0]) - strcpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,Gbl.CurrentCrs.Crs.FullName); + { + strncpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,Gbl.CurrentCrs.Crs.FullName, + Crs_MAX_LENGTH_COURSE_FULL_NAME); + Gbl.ExamAnnouncements.ExaDat.CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME] = '\0'; + } /***** Get the year *****/ Par_GetParToText ("Year",UnsignedStr,10); @@ -937,14 +941,17 @@ static void Exa_GetDataExamAnnouncementFromDB (void) Gbl.ExamAnnouncements.ExaDat.Status = (Exa_ExamAnnouncementStatus_t) UnsignedNum; /* Name of the course (row[2]) */ - strcpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,row[2]); + strncpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,row[2], + Crs_MAX_LENGTH_COURSE_FULL_NAME); + Gbl.ExamAnnouncements.ExaDat.CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME] = '\0'; /* Year (row[3]) */ if (sscanf (row[3],"%u",&Gbl.ExamAnnouncements.ExaDat.Year) != 1) Lay_ShowErrorAndExit ("Wrong year."); /* Exam session (row[4]) */ - strcpy (Gbl.ExamAnnouncements.ExaDat.Session,row[4]); + strncpy (Gbl.ExamAnnouncements.ExaDat.Session,row[4],Cns_MAX_BYTES_STRING); + Gbl.ExamAnnouncements.ExaDat.Session[Cns_MAX_BYTES_STRING] = '\0'; /* Date of exam announcement (row[5]) */ if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u", diff --git a/swad_exam.h b/swad_exam.h index a77c8cab..c1787490 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -30,6 +30,7 @@ #include // For boolean type #include "swad_constant.h" +#include "swad_course.h" #include "swad_date.h" /*****************************************************************************/ @@ -57,9 +58,9 @@ struct ExamData long ExaCod; long CrsCod; Exa_ExamAnnouncementStatus_t Status; - char CrsFullName[Cns_MAX_BYTES_STRING+1]; + char CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME + 1]; unsigned Year; // Number of year (0 (N.A.), 1, 2, 3, 4, 5, 6) in the degree - char Session[Cns_MAX_BYTES_STRING+1]; // Exam session is june, september, etc. + char Session[Cns_MAX_BYTES_STRING + 1]; // Exam session is june, september, etc. struct Date CallDate; struct Date ExamDate; struct Hour StartTime; diff --git a/swad_file.c b/swad_file.c index 89fb67e8..22b86ac6 100644 --- a/swad_file.c +++ b/swad_file.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_file.h b/swad_file.h index b4ca5ccf..d6d82e5d 100644 --- a/swad_file.h +++ b/swad_file.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_file_browser.c b/swad_file_browser.c index 157aa48e..fd2f829d 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -1485,19 +1485,28 @@ static void Brw_GetAndUpdateDateLastAccFileBrowser (void); static long Brw_GetGrpLastAccZone (const char *FieldNameDB); static void Brw_ResetFileBrowserSize (void); static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path); -static void Brw_ListDir (unsigned Level,const char *Path,const char *PathInTree); +static void Brw_ListDir (unsigned Level, + const char Path[PATH_MAX + 1], + const char PathInTree[PATH_MAX + 1]); static bool Brw_WriteRowFileBrowser (unsigned Level,Brw_ExpandTree_t ExpandTree, - const char *PathInTree,const char *FileName); + const char PathInTree[PATH_MAX + 1], + const char *FileName); static void Brw_PutIconsRemoveCopyPaste (unsigned Level, - const char *PathInTree,const char *FileName,const char *FileNameToShow); + const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow); static bool Brw_CheckIfCanPasteIn (unsigned Level); -static void Brw_PutIconRemoveFile (const char *PathInTree,const char *FileName,const char *FileNameToShow); -static void Brw_PutIconRemoveDir (const char *PathInTree,const char *FileName,const char *FileNameToShow); -static void Brw_PutIconCopy (const char *PathInTree,const char *FileName,const char *FileNameShow); -static void Brw_PutIconPasteOn (const char *PathInTree,const char *FileName,const char *FileNameToShow); +static void Brw_PutIconRemoveFile (const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow); +static void Brw_PutIconRemoveDir (const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow); +static void Brw_PutIconCopy (const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameShow); +static void Brw_PutIconPasteOn (const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow); static void Brw_PutIconPasteOff (void); static void Brw_IndentAndWriteIconExpandContract (unsigned Level,Brw_ExpandTree_t ExpandTree, - const char *PathInTree,const char *FileName,const char *FileNameToShow); + const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow); static void Brw_IndentDependingOnLevel (unsigned Level); static void Brw_PutIconShow (unsigned Level,const char *PathInTree,const char *FileName,const char *FileNameToShow); static void Brw_PutIconHide (unsigned Level,const char *PathInTree,const char *FileName,const char *FileNameToShow); @@ -1529,16 +1538,16 @@ static void Brw_UpdatePathInClipboard (void); static long Brw_GetCodForClipboard (void); static long Brw_GetWorksUsrCodForClipboard (void); -static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char *Path); -static void Brw_RemThisFolderAndUpdOtherFoldersFromExpandedFolders (const char *Path); -static void Brw_InsertFolderInExpandedFolders (const char *Path); +static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char Path[PATH_MAX + 1]); +static void Brw_RemThisFolderAndUpdOtherFoldersFromExpandedFolders (const char Path[PATH_MAX + 1]); +static void Brw_InsertFolderInExpandedFolders (const char Path[PATH_MAX + 1]); static void Brw_UpdateClickTimeOfThisFileBrowserInExpandedFolders (void); -static void Brw_RemoveFolderFromExpandedFolders (const char *Path); -static void Brw_RemoveAffectedExpandedFolders (const char *Path); +static void Brw_RemoveFolderFromExpandedFolders (const char Path[PATH_MAX + 1]); +static void Brw_RemoveAffectedExpandedFolders (const char Path[PATH_MAX + 1]); static void Brw_RenameAffectedExpandedFolders (Brw_FileBrowser_t FileBrowser, long MyUsrCod,long WorksUsrCod, const char *OldPath,const char *NewPath); -static bool Brw_GetIfExpandedTree (const char *Path); +static bool Brw_GetIfExpandedTree (const char Path[PATH_MAX + 1]); static long Brw_GetCodForExpandedFolders (void); static long Brw_GetWorksUsrCodForExpandedFolders (void); @@ -1546,10 +1555,10 @@ static void Brw_RemoveExpiredClipboards (void); static void Brw_RemoveAffectedClipboards (Brw_FileBrowser_t FileBrowser, long MyUsrCod,long WorksUsrCod); static void Brw_PasteClipboard (void); -static unsigned Brw_NumLevelsInPath (const char *Path); +static unsigned Brw_NumLevelsInPath (const char Path[PATH_MAX + 1]); static bool Brw_PasteTreeIntoFolder (unsigned Level, - const char *PathOrg, - const char *PathDstInTree, + const char PathOrg[PATH_MAX + 1], + const char PathDstInTree[PATH_MAX + 1], struct Brw_NumObjects *Pasted, long *FirstFilCod); static void Brw_PutFormToCreateAFolder (const char *FileNameToShow); @@ -1573,19 +1582,21 @@ static void Brw_GetFileViewsFromLoggedUsrs (struct FileMetadata *FileMetadata); static void Brw_GetFileViewsFromNonLoggedUsrs (struct FileMetadata *FileMetadata); static unsigned Brw_GetFileViewsFromMe (long FilCod); static void Brw_UpdateFileViews (unsigned NumViews,long FilCod); -static bool Brw_GetIfFolderHasPublicFiles (const char *Path); +static bool Brw_GetIfFolderHasPublicFiles (const char Path[PATH_MAX + 1]); -static void Brw_ChangeFileOrFolderHiddenInDB (const char *Path,bool IsHidden); +static void Brw_ChangeFileOrFolderHiddenInDB (const char Path[PATH_MAX + 1],bool IsHidden); static void Brw_ChangeFilePublicInDB (long PublisherUsrCod,const char *Path, bool IsPublic,Brw_License_t License); static long Brw_GetZoneUsrCodForFiles (void); -static void Brw_RemoveOneFileOrFolderFromDB (const char *Path); -static void Brw_RemoveChildrenOfFolderFromDB (const char *Path); -static void Brw_RenameOneFolderInDB (const char *OldPath,const char *NewPath); -static void Brw_RenameChildrenFilesOrFoldersInDB (const char *OldPath,const char *NewPath); +static void Brw_RemoveOneFileOrFolderFromDB (const char Path[PATH_MAX + 1]); +static void Brw_RemoveChildrenOfFolderFromDB (const char Path[PATH_MAX + 1]); +static void Brw_RenameOneFolderInDB (const char OldPath[PATH_MAX + 1], + const char NewPath[PATH_MAX + 1]); +static void Brw_RenameChildrenFilesOrFoldersInDB (const char OldPath[PATH_MAX + 1], + const char NewPath[PATH_MAX + 1]); static bool Brw_CheckIfICanEditFileOrFolder (unsigned Level); static bool Brw_CheckIfICanCreateIntoFolder (unsigned Level); static bool Brw_CheckIfICanModifySharedFileOrFolder (void); @@ -1594,15 +1605,16 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row); static void Brw_PutLinkToAskRemOldFiles (void); static void Brw_RemoveOldFilesInBrowser (unsigned Months,struct Brw_NumObjects *Removed); -static void Brw_ScanDirRemovingOldFiles (unsigned Level,const char *Path, - const char *PathInTree, +static void Brw_ScanDirRemovingOldFiles (unsigned Level, + const char Path[PATH_MAX + 1], + const char PathInTree[PATH_MAX + 1], time_t TimeRemoveFilesOlder, struct Brw_NumObjects *Removed); -static void Brw_RemoveFileFromDiskAndDB (const char *Path, - const char *FullPathInTree); -static int Brw_RemoveFolderFromDiskAndDB (const char *Path, - const char *FullPathInTree); +static void Brw_RemoveFileFromDiskAndDB (const char Path[PATH_MAX + 1], + const char FullPathInTree[PATH_MAX + 1]); +static int Brw_RemoveFolderFromDiskAndDB (const char Path[PATH_MAX + 1], + const char FullPathInTree[PATH_MAX + 1]); /*****************************************************************************/ /***************** Get parameters related to file browser ********************/ @@ -2372,8 +2384,15 @@ static void Brw_GetDataCurrentGrp (void) if (Gbl.CurrentCrs.Grps.GrpCod > 0) { Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod = GrpDat.GrpTypCod; - strcpy (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName , GrpDat.GrpTypName); - strcpy (Gbl.CurrentCrs.Grps.GrpName , GrpDat.GrpName); + + strncpy (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,GrpDat.GrpTypName, + Grp_MAX_LENGTH_GROUP_TYPE_NAME); + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME] = '\0'; + + strncpy (Gbl.CurrentCrs.Grps.GrpName,GrpDat.GrpName, + Grp_MAX_LENGTH_GROUP_NAME); + Gbl.CurrentCrs.Grps.GrpName[Grp_MAX_LENGTH_GROUP_NAME] = '\0'; + Gbl.CurrentCrs.Grps.MaxStudents = GrpDat.MaxStudents; Gbl.CurrentCrs.Grps.Open = GrpDat.Open; Gbl.CurrentCrs.Grps.FileZones = GrpDat.FileZones; @@ -2593,8 +2612,9 @@ static void Brw_SetPathFileBrowser (void) case Brw_ADMI_SHARE_CRS: case Brw_SHOW_MARKS_CRS: case Brw_ADMI_MARKS_CRS: - strcpy (Gbl.FileBrowser.Priv.PathAboveRootFolder, - Gbl.CurrentCrs.PathPriv); + strncpy (Gbl.FileBrowser.Priv.PathAboveRootFolder, + Gbl.CurrentCrs.PathPriv,PATH_MAX); + Gbl.FileBrowser.Priv.PathAboveRootFolder[PATH_MAX] = '\0'; break; case Brw_SHOW_DOCUM_GRP: case Brw_ADMI_DOCUM_GRP: @@ -2644,8 +2664,9 @@ static void Brw_SetPathFileBrowser (void) } break; case Brw_ADMI_BRIEF_USR: - strcpy (Gbl.FileBrowser.Priv.PathAboveRootFolder, - Gbl.Usrs.Me.PathDir); + strncpy (Gbl.FileBrowser.Priv.PathAboveRootFolder, + Gbl.Usrs.Me.PathDir,PATH_MAX); + Gbl.FileBrowser.Priv.PathAboveRootFolder[PATH_MAX] = '\0'; break; default: return; @@ -4786,7 +4807,10 @@ void Brw_CreateDirDownloadTmp (void) if (NumDir) sprintf (Gbl.FileBrowser.TmpPubDir,"%s_%u",Gbl.UniqueNameEncrypted,NumDir); else - strcpy (Gbl.FileBrowser.TmpPubDir,Gbl.UniqueNameEncrypted); + { + strncpy (Gbl.FileBrowser.TmpPubDir,Gbl.UniqueNameEncrypted,NAME_MAX); + Gbl.FileBrowser.TmpPubDir[NAME_MAX] = '\0'; + } sprintf (PathPubDirTmp,"%s/%s",PathFileBrowserTmpPubl,Gbl.FileBrowser.TmpPubDir); if (mkdir (PathPubDirTmp,(mode_t) 0xFFF)) Lay_ShowErrorAndExit ("Can not create a temporary folder for download."); @@ -5009,7 +5033,9 @@ static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path) /************************ List a directory recursively ***********************/ /*****************************************************************************/ -static void Brw_ListDir (unsigned Level,const char *Path,const char *PathInTree) +static void Brw_ListDir (unsigned Level, + const char Path[PATH_MAX + 1], + const char PathInTree[PATH_MAX + 1]) { struct dirent **FileList; struct dirent **SubdirFileList; @@ -5098,7 +5124,8 @@ static void Brw_ListDir (unsigned Level,const char *Path,const char *PathInTree) // If the row is visible, return true. If it is hidden, return false static bool Brw_WriteRowFileBrowser (unsigned Level,Brw_ExpandTree_t ExpandTree, - const char *PathInTree,const char *FileName) + const char PathInTree[PATH_MAX + 1], + const char *FileName) { bool RowSetAsHidden = false; bool RowSetAsPublic = false; @@ -5329,8 +5356,11 @@ void Brw_SetFullPathInTree (const char *PathInTreeUntilFileOrFolder,const char * sprintf (Gbl.FileBrowser.Priv.FullPathInTree,"%s/%s", PathInTreeUntilFileOrFolder,FilFolLnkName); else // It's the root folder - strcpy (Gbl.FileBrowser.Priv.FullPathInTree, - PathInTreeUntilFileOrFolder); + { + strncpy (Gbl.FileBrowser.Priv.FullPathInTree, + PathInTreeUntilFileOrFolder,PATH_MAX); + Gbl.FileBrowser.Priv.FullPathInTree[PATH_MAX] = '\0'; + } } /*****************************************************************************/ @@ -5338,7 +5368,8 @@ void Brw_SetFullPathInTree (const char *PathInTreeUntilFileOrFolder,const char * /*****************************************************************************/ static void Brw_PutIconsRemoveCopyPaste (unsigned Level, - const char *PathInTree,const char *FileName,const char *FileNameToShow) + const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow) { /***** Icon to remove folder, file or link *****/ switch (Gbl.FileBrowser.FileType) @@ -5424,7 +5455,8 @@ static bool Brw_CheckIfCanPasteIn (unsigned Level) /*****************************************************************************/ // Gbl.FileBrowser.FileType can be Brw_IS_FILE or Brw_IS_LINK -static void Brw_PutIconRemoveFile (const char *PathInTree,const char *FileName,const char *FileNameToShow) +static void Brw_PutIconRemoveFile (const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow) { extern const char *Txt_Remove_FILE_OR_LINK_X; @@ -5455,7 +5487,8 @@ static void Brw_PutIconRemoveFile (const char *PathInTree,const char *FileName,c /****************** Write link and icon to remove a folder *******************/ /*****************************************************************************/ -static void Brw_PutIconRemoveDir (const char *PathInTree,const char *FileName,const char *FileNameToShow) +static void Brw_PutIconRemoveDir (const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow) { extern const char *Txt_Remove_folder_X; @@ -5486,7 +5519,8 @@ static void Brw_PutIconRemoveDir (const char *PathInTree,const char *FileName,co /************** Write link e icon to copy a file o a folder ******************/ /*****************************************************************************/ -static void Brw_PutIconCopy (const char *PathInTree,const char *FileName,const char *FileNameToShow) +static void Brw_PutIconCopy (const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow) { extern const char *Txt_Copy_FOLDER_FILE_OR_LINK_X; @@ -5513,7 +5547,8 @@ static void Brw_PutIconCopy (const char *PathInTree,const char *FileName,const c /************** Write link e icon to paste a file or a folder ****************/ /*****************************************************************************/ -static void Brw_PutIconPasteOn (const char *PathInTree,const char *FileName,const char *FileNameToShow) +static void Brw_PutIconPasteOn (const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow) { extern const char *Txt_Paste_in_X; @@ -5558,7 +5593,8 @@ static void Brw_PutIconPasteOff (void) /*****************************************************************************/ static void Brw_IndentAndWriteIconExpandContract (unsigned Level,Brw_ExpandTree_t ExpandTree, - const char *PathInTree,const char *FileName,const char *FileNameToShow) + const char PathInTree[PATH_MAX + 1], + const char *FileName,const char *FileNameToShow) { extern const char *Txt_Expand; extern const char *Txt_Contract; @@ -6688,7 +6724,8 @@ static bool Brw_GetMyClipboard (void) Gbl.FileBrowser.Clipboard.FileType = (Brw_FileType_t) UnsignedNum; /* Get file path (row[4]) */ - strcpy (Gbl.FileBrowser.Clipboard.Path,row[4]); + strncpy (Gbl.FileBrowser.Clipboard.Path,row[4],PATH_MAX); + Gbl.FileBrowser.Clipboard.Path[PATH_MAX] = '\0'; Str_SplitFullPathIntoPathAndFileName (Gbl.FileBrowser.Clipboard.Path, PathUntilFileName, Gbl.FileBrowser.Clipboard.FileName); @@ -6868,10 +6905,10 @@ static long Brw_GetWorksUsrCodForClipboard (void) /*****************************************************************************/ // Important: parameter Path must end in a folder, not in a file -static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char *Path) +static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char Path[PATH_MAX + 1]) { char *Ptr; - char CopyOfPath[PATH_MAX+1]; + char CopyOfPath[PATH_MAX + 1]; /* Example: Path = root_folder/folder1/folder2/folder3 1. Try to insert CopyOfPath = "root_folder/folder1/folder2/folder3" @@ -6883,7 +6920,8 @@ static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char // if (strcmp (Path,Brw_RootFolderInternalNames[Gbl.FileBrowser.Type])) // Don't insert root folder /***** Make a copy to keep Path unchanged *****/ - strcpy (CopyOfPath,Path); + strncpy (CopyOfPath,Path,PATH_MAX); + CopyOfPath[PATH_MAX] = '\0'; /***** Insert paths in table of expanded folders if they are not yet there *****/ do @@ -6907,7 +6945,7 @@ static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char /******* and update click time of the other folders in the expl. tree ********/ /*****************************************************************************/ -static void Brw_RemThisFolderAndUpdOtherFoldersFromExpandedFolders (const char *Path) +static void Brw_RemThisFolderAndUpdOtherFoldersFromExpandedFolders (const char Path[PATH_MAX + 1]) { /***** Remove Path from expanded folders table *****/ Brw_RemoveFolderFromExpandedFolders (Path); @@ -6920,7 +6958,7 @@ static void Brw_RemThisFolderAndUpdOtherFoldersFromExpandedFolders (const char * /************************* Insert path in expanded folders *******************/ /*****************************************************************************/ -static void Brw_InsertFolderInExpandedFolders (const char *Path) +static void Brw_InsertFolderInExpandedFolders (const char Path[PATH_MAX + 1]) { long Cod = Brw_GetCodForExpandedFolders (); long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders (); @@ -6980,7 +7018,7 @@ static void Brw_UpdateClickTimeOfThisFileBrowserInExpandedFolders (void) /********************** Remove path from expanded folders ********************/ /*****************************************************************************/ -static void Brw_RemoveFolderFromExpandedFolders (const char *Path) +static void Brw_RemoveFolderFromExpandedFolders (const char Path[PATH_MAX + 1]) { long Cod = Brw_GetCodForExpandedFolders (); long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders (); @@ -7017,7 +7055,7 @@ static void Brw_RemoveFolderFromExpandedFolders (const char *Path) /***** Remove expanded folders with paths from a course or from a user *******/ /*****************************************************************************/ -static void Brw_RemoveAffectedExpandedFolders (const char *Path) +static void Brw_RemoveAffectedExpandedFolders (const char Path[PATH_MAX + 1]) { long Cod = Brw_GetCodForExpandedFolders (); long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders (); @@ -7122,7 +7160,7 @@ static void Brw_RenameAffectedExpandedFolders (Brw_FileBrowser_t FileBrowser, /************* Check if a folder from a file browser is expanded *************/ /*****************************************************************************/ -static bool Brw_GetIfExpandedTree (const char *Path) +static bool Brw_GetIfExpandedTree (const char Path[PATH_MAX + 1]) { long Cod = Brw_GetCodForExpandedFolders (); long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders (); @@ -7578,7 +7616,7 @@ static void Brw_PasteClipboard (void) /****************** Compute number of levels in a path ***********************/ /*****************************************************************************/ -static unsigned Brw_NumLevelsInPath (const char *Path) +static unsigned Brw_NumLevelsInPath (const char Path[PATH_MAX + 1]) { unsigned NumLevls = 0; @@ -7595,8 +7633,8 @@ static unsigned Brw_NumLevelsInPath (const char *Path) // Return true if the copy has been made successfully, and false if not static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg, - const char *PathOrg, - const char *PathDstInTree, + const char PathOrg[PATH_MAX + 1], + const char PathDstInTree[PATH_MAX + 1], struct Brw_NumObjects *Pasted, long *FirstFilCod) { @@ -7651,7 +7689,10 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg, if (LevelOrg == 0) // Origin of copy is the root folder, // for example "sha" // ==> do not copy the root folder itself into destination - strcpy (PathDstInTreeWithFile,PathDstInTree); + { + strncpy (PathDstInTreeWithFile,PathDstInTree,PATH_MAX); + PathDstInTreeWithFile[PATH_MAX] = '\0'; + } else // Origin of copy is a file or folder inside the root folder // for example "sha/folder1/file1" sprintf (PathDstInTreeWithFile,"%s/%s",PathDstInTree,FileNameOrg); @@ -8532,10 +8573,18 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType) } } else // Empty filename - strcpy (Gbl.Message,Txt_UPLOAD_FILE_You_must_specify_the_file_NO_HTML); + { + strncpy (Gbl.Message,Txt_UPLOAD_FILE_You_must_specify_the_file_NO_HTML, + Lay_MAX_BYTES_ALERT); + Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0'; + } } else // I do not have permission to create files here - strcpy (Gbl.Message,Txt_UPLOAD_FILE_Forbidden_NO_HTML); + { + strncpy (Gbl.Message,Txt_UPLOAD_FILE_Forbidden_NO_HTML, + Lay_MAX_BYTES_ALERT); + Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0'; + } return UploadSucessful; } @@ -10425,7 +10474,7 @@ static void Brw_UpdateFileViews (unsigned NumViews,long FilCod) /*********** Check if a folder contains file(s) marked as public *************/ /*****************************************************************************/ -static bool Brw_GetIfFolderHasPublicFiles (const char *Path) +static bool Brw_GetIfFolderHasPublicFiles (const char Path[PATH_MAX + 1]) { long Cod = Brw_GetCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); @@ -10480,7 +10529,7 @@ unsigned Brw_GetNumPublicFilesUsr (long UsrCod) /***************** Change hiddeness of file in the database ******************/ /*****************************************************************************/ -static void Brw_ChangeFileOrFolderHiddenInDB (const char *Path,bool IsHidden) +static void Brw_ChangeFileOrFolderHiddenInDB (const char Path[PATH_MAX + 1],bool IsHidden) { long Cod = Brw_GetCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); @@ -10690,7 +10739,7 @@ long Brw_AddPathToDB (long PublisherUsrCod,Brw_FileType_t FileType, /**************** Remove a file or folder from the database ******************/ /*****************************************************************************/ -static void Brw_RemoveOneFileOrFolderFromDB (const char *Path) +static void Brw_RemoveOneFileOrFolderFromDB (const char Path[PATH_MAX + 1]) { long Cod = Brw_GetCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); @@ -10735,7 +10784,7 @@ static void Brw_RemoveOneFileOrFolderFromDB (const char *Path) /************** Remove children of a folder from the database ****************/ /*****************************************************************************/ -static void Brw_RemoveChildrenOfFolderFromDB (const char *Path) +static void Brw_RemoveChildrenOfFolderFromDB (const char Path[PATH_MAX + 1]) { long Cod = Brw_GetCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); @@ -10780,7 +10829,8 @@ static void Brw_RemoveChildrenOfFolderFromDB (const char *Path) /*************** Rename a file or folder in table of files *******************/ /*****************************************************************************/ -static void Brw_RenameOneFolderInDB (const char *OldPath,const char *NewPath) +static void Brw_RenameOneFolderInDB (const char OldPath[PATH_MAX + 1], + const char NewPath[PATH_MAX + 1]) { long Cod = Brw_GetCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); @@ -10800,7 +10850,8 @@ static void Brw_RenameOneFolderInDB (const char *OldPath,const char *NewPath) /************** Rename children of a folder in table of files ****************/ /*****************************************************************************/ -static void Brw_RenameChildrenFilesOrFoldersInDB (const char *OldPath,const char *NewPath) +static void Brw_RenameChildrenFilesOrFoldersInDB (const char OldPath[PATH_MAX + 1], + const char NewPath[PATH_MAX + 1]) { long Cod = Brw_GetCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); @@ -11115,9 +11166,9 @@ void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat,Cns_QuietOrVerbose_t Qu /*****************************************************************************/ // This function may be called inside a web service, so don't report error -#define Brw_MAX_BYTES_FILE_CONTENT_STR (100+NAME_MAX + 100+PATH_MAX + 100+(Usr_MAX_BYTES_NAME+1)*3 + 100+Fil_MAX_BYTES_FILE_SIZE_STRING) +#define Brw_MAX_BYTES_FILE_CONTENT_STR (100 + NAME_MAX + 100 + PATH_MAX + 100+(Usr_MAX_BYTES_NAME + 1) * 3 + 100 + Fil_MAX_BYTES_FILE_SIZE_STRING) -void Brw_GetSummaryAndContentOfFile (char *SummaryStr,char **ContentStr, +void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, long FilCod,unsigned MaxChars,bool GetContent) { extern const char *Txt_Filename; @@ -11138,7 +11189,8 @@ void Brw_GetSummaryAndContentOfFile (char *SummaryStr,char **ContentStr, Brw_GetFileMetadataByCod (&FileMetadata); /***** Copy file name into summary string *****/ - strcpy (SummaryStr,FileMetadata.FilFolLnkName); + strncpy (SummaryStr,FileMetadata.FilFolLnkName,Cns_MAX_BYTES_TEXT); + SummaryStr[Cns_MAX_BYTES_TEXT] = '\0'; if (MaxChars) Str_LimitLengthHTMLStr (SummaryStr,MaxChars); @@ -11669,8 +11721,9 @@ static void Brw_RemoveOldFilesInBrowser (unsigned Months,struct Brw_NumObjects * /************* Scan a directory recursively removing old files ***************/ /*****************************************************************************/ -static void Brw_ScanDirRemovingOldFiles (unsigned Level,const char *Path, - const char *PathInTree, +static void Brw_ScanDirRemovingOldFiles (unsigned Level, + const char Path[PATH_MAX + 1], + const char PathInTree[PATH_MAX + 1], time_t TimeRemoveFilesOlder, struct Brw_NumObjects *Removed) { @@ -11767,8 +11820,8 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,const char *Path, /******************* Remove file/link from disk and database *****************/ /*****************************************************************************/ -static void Brw_RemoveFileFromDiskAndDB (const char *Path, - const char *FullPathInTree) +static void Brw_RemoveFileFromDiskAndDB (const char Path[PATH_MAX + 1], + const char FullPathInTree[PATH_MAX + 1]) { /***** Remove file from disk *****/ if (unlink (Path)) @@ -11785,8 +11838,8 @@ static void Brw_RemoveFileFromDiskAndDB (const char *Path, /*****************************************************************************/ // Return the returned value of rmdir -static int Brw_RemoveFolderFromDiskAndDB (const char *Path, - const char *FullPathInTree) +static int Brw_RemoveFolderFromDiskAndDB (const char Path[PATH_MAX + 1], + const char FullPathInTree[PATH_MAX + 1]) { int Result; diff --git a/swad_file_browser.h b/swad_file_browser.h index ff4378fa..d6f2924c 100644 --- a/swad_file_browser.h +++ b/swad_file_browser.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -245,7 +245,7 @@ void Brw_RemoveGrpZones (long CrsCod,long GrpCod); void Brw_RemoveUsrWorksInCrs (struct UsrData *UsrDat,struct Course *Crs,Cns_QuietOrVerbose_t QuietOrVerbose); void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat,Cns_QuietOrVerbose_t QuietOrVerbose); -void Brw_GetSummaryAndContentOfFile (char *SummaryStr,char **ContentStr, +void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, long FilCod,unsigned MaxChars,bool GetContent); unsigned Brw_ListDocsFound (const char *Query, diff --git a/swad_follow.c b/swad_follow.c index e4952999..c7af32f0 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_follow.h b/swad_follow.h index 1a407d17..f061bc8d 100644 --- a/swad_follow.h +++ b/swad_follow.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_forum.c b/swad_forum.c index 96aa4fa1..4c64e0b1 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_forum.h b/swad_forum.h index ddd78905..b1429fda 100644 --- a/swad_forum.h +++ b/swad_forum.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_global.c b/swad_global.c index d8784fd5..06c943d8 100644 --- a/swad_global.c +++ b/swad_global.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_global.h b/swad_global.h index 605bd1da..7ac4a05d 100644 --- a/swad_global.h +++ b/swad_global.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -178,8 +178,8 @@ struct Globals time_t StartExecutionTimeUTC; struct DateTime Now; struct Date Yesterday; - char Message[Lay_MAX_BYTES_ALERT]; // String for alerts - char Title[Lay_MAX_BYTES_TITLE]; // String for the help message in a link + char Message[Lay_MAX_BYTES_ALERT + 1]; // String for alerts + char Title[Lay_MAX_BYTES_TITLE + 1]; // String for the help message in a link unsigned RowEvenOdd; // To alternate row colors in listings char *ColorRows[2]; const char *XMLPtr; @@ -453,7 +453,7 @@ struct Globals struct GroupTypes GrpTypes; struct GroupType GrpTyp; long GrpCod; - char GrpName[MAX_LENGTH_GROUP_NAME+1]; + char GrpName[Grp_MAX_LENGTH_GROUP_NAME + 1]; int MaxStudents; bool Open; bool FileZones; @@ -513,13 +513,13 @@ struct Globals } Size; struct { - char PathAboveRootFolder[PATH_MAX+1]; - char PathRootFolder[PATH_MAX+1]; - char PathInTreeUntilFilFolLnk[PATH_MAX+1]; - char FullPathInTree[PATH_MAX+1]; + char PathAboveRootFolder[PATH_MAX + 1]; + char PathRootFolder[PATH_MAX + 1]; + char PathInTreeUntilFilFolLnk[PATH_MAX + 1]; + char FullPathInTree[PATH_MAX + 1]; } Priv; - char NewFilFolLnkName[NAME_MAX+1]; - char FilFolLnkName[NAME_MAX+1]; + char NewFilFolLnkName[NAME_MAX + 1]; + char FilFolLnkName[NAME_MAX + 1]; Brw_FileType_t FileType; unsigned Level; bool ICanEditFileOrFolder; // Can I modify (remove, rename, create inside, etc.) a file or folder? @@ -529,22 +529,22 @@ struct Globals Brw_FileBrowser_t FileBrowser; // Type of the file browser long Cod; // Code of the institution/centre/degree/course/group related to the file browser with the clipboard long WorksUsrCod; // User code of the user related to the works file browser with the clipboard - char Path[PATH_MAX+1]; // Complete path in the file browser - char FileName[NAME_MAX+1]; // File name, last part of complete path in the file browser + char Path[PATH_MAX + 1]; // Complete path in the file browser + char FileName[NAME_MAX + 1]; // File name, last part of complete path in the file browser unsigned Level; Brw_FileType_t FileType; // Folder, file or link bool IsThisTree; // When showing a file browser, is it that corresponding to the clipboard? bool IsThisFile; // When showing a row of a file browser, are we in the path of the clipboard? } Clipboard; - char TmpPubDir[NAME_MAX+1]; - bool HiddenLevels[1+Brw_MAX_DIR_LEVELS]; + char TmpPubDir[NAME_MAX + 1]; + bool HiddenLevels[1 + Brw_MAX_DIR_LEVELS]; const char *TxtStyle; const char *InputStyle; struct Assignment Asg; // Data of assignment when browsing level 1 or an assignment zone struct { bool CreateZIP; - char TmpDir[NAME_MAX+1]; + char TmpDir[NAME_MAX + 1]; } ZIP; } FileBrowser; // Struct used for a file browser struct @@ -576,7 +576,7 @@ struct Globals struct Course Crs; int Level; For_ForumOrderType_t SelectedOrderType; - char PathRelOld[PATH_MAX+1]; + char PathRelOld[PATH_MAX + 1]; long ThreadToMove; } Forum; struct @@ -588,17 +588,17 @@ struct Globals Msg_TypeOfMessages_t TypeOfMessages; unsigned NumMsgs; int MsgId; - char Subject[Cns_MAX_BYTES_SUBJECT+1]; + char Subject[Cns_MAX_BYTES_SUBJECT + 1]; unsigned NumCourses; struct { long CrsCod; - char ShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME+1]; + char ShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1]; } Courses[Crs_MAX_COURSES_PER_USR]; // Distinct courses in my messages sent or received long FilterCrsCod; // Show only messages sent from this course code - char FilterCrsShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME+1]; - char FilterFromTo[Usr_MAX_LENGTH_USR_NAME_OR_SURNAME*3+1]; // Show only messages from/to these users - char FilterContent[Msg_MAX_LENGTH_FILTER_CONTENT+1]; // Show only messages that match this content + char FilterCrsShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1]; + char FilterFromTo[Usr_MAX_LENGTH_USR_NAME_OR_SURNAME*3 + 1]; // Show only messages from/to these users + char FilterContent[Msg_MAX_LENGTH_FILTER_CONTENT + 1]; // Show only messages that match this content bool ShowOnlyUnreadMsgs; // Show only unread messages (this option is applicable only for received messages) long ExpandedMsgCod; // The current expanded message code struct @@ -607,7 +607,7 @@ struct Globals long OriginalMsgCod; // Original message code when I am editing a reply } Reply; bool ShowOnlyOneRecipient; // Shown only a selected recipient or also other potential recipients? - char FileNameMail[PATH_MAX+1]; + char FileNameMail[PATH_MAX + 1]; FILE *FileMail; } Msg; struct diff --git a/swad_group.c b/swad_group.c index 49e54ddc..828f6775 100644 --- a/swad_group.c +++ b/swad_group.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -1161,7 +1161,7 @@ static void Grp_ListGroupTypesForEdition (void) fprintf (Gbl.F.Out,"", - MAX_LENGTH_GROUP_TYPE_NAME, + Grp_MAX_LENGTH_GROUP_TYPE_NAME, Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName, Gbl.Form.Id); Act_FormEnd (); @@ -1405,7 +1405,7 @@ static void Grp_ListGroupsForEdition (void) fprintf (Gbl.F.Out,"", - MAX_LENGTH_GROUP_NAME,Grp->GrpName,Gbl.Form.Id); + Grp_MAX_LENGTH_GROUP_NAME,Grp->GrpName,Gbl.Form.Id); Act_FormEnd (); fprintf (Gbl.F.Out,""); @@ -2121,7 +2121,7 @@ static void Grp_PutFormToCreateGroupType (void) " size=\"12\" maxlength=\"%u\" value=\"%s\"" " required=\"required\" />" "", - MAX_LENGTH_GROUP_TYPE_NAME,Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); + Grp_MAX_LENGTH_GROUP_TYPE_NAME,Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); /***** Is it mandatory to register in any groups of this type? *****/ fprintf (Gbl.F.Out,"" @@ -2264,7 +2264,7 @@ static void Grp_PutFormToCreateGroup (void) " size=\"40\" maxlength=\"%u\" value=\"%s\"" " required=\"required\" />" "", - MAX_LENGTH_GROUP_NAME,Gbl.CurrentCrs.Grps.GrpName); + Grp_MAX_LENGTH_GROUP_NAME,Gbl.CurrentCrs.Grps.GrpName); /***** Maximum number of students *****/ fprintf (Gbl.F.Out,"" @@ -2367,7 +2367,7 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes) Lay_ShowErrorAndExit ("Wrong type of group."); /* Get group type name (row[1]) */ - strncpy (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].GrpTypName,row[1],MAX_LENGTH_GROUP_TYPE_NAME); + strncpy (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].GrpTypName,row[1],Grp_MAX_LENGTH_GROUP_TYPE_NAME); /* Is it mandatory to register in any groups of this type? (row[2]) */ Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].MandatoryEnrollment = (row[2][0] == 'Y'); @@ -3121,7 +3121,7 @@ void Grp_RecFormNewGrpTyp (void) /***** Get parameters from form *****/ /* Get the name of group type */ - Par_GetParToText ("GrpTypName",Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,MAX_LENGTH_GROUP_TYPE_NAME); + Par_GetParToText ("GrpTypName",Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,Grp_MAX_LENGTH_GROUP_TYPE_NAME); /* Get whether it is mandatory to regisrer in any group of this type */ Par_GetParToText ("MandatoryEnrollment",YN,1); @@ -3185,7 +3185,7 @@ void Grp_RecFormNewGrp (void) if ((Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) > 0) // Group type valid { /* Get group name */ - Par_GetParToText ("GrpName",Gbl.CurrentCrs.Grps.GrpName,MAX_LENGTH_GROUP_NAME); + Par_GetParToText ("GrpName",Gbl.CurrentCrs.Grps.GrpName,Grp_MAX_LENGTH_GROUP_NAME); /* Get maximum number of students */ Par_GetParToText ("MaxStudents",UnsignedStr,10); @@ -3957,7 +3957,7 @@ void Grp_RenameGroupType (void) extern const char *Txt_The_type_of_group_X_has_been_renamed_as_Y; extern const char *Txt_The_name_of_the_type_of_group_X_has_not_changed; char Query[1024]; - char NewNameGrpTyp[MAX_LENGTH_GROUP_TYPE_NAME+1]; + char NewNameGrpTyp[Grp_MAX_LENGTH_GROUP_TYPE_NAME+1]; /***** Get parameters from form *****/ /* Get the code of the group type */ @@ -3965,7 +3965,7 @@ void Grp_RenameGroupType (void) Lay_ShowErrorAndExit ("Code of type of group is missing."); /* Get the new name for the group type */ - Par_GetParToText ("GrpTypName",NewNameGrpTyp,MAX_LENGTH_GROUP_TYPE_NAME); + Par_GetParToText ("GrpTypName",NewNameGrpTyp,Grp_MAX_LENGTH_GROUP_TYPE_NAME); /***** Get from the database the old name of the group type *****/ Grp_GetDataOfGroupTypeByCod (&Gbl.CurrentCrs.Grps.GrpTyp); @@ -4030,7 +4030,7 @@ void Grp_RenameGroup (void) extern const char *Txt_The_name_of_the_group_X_has_not_changed; struct GroupData GrpDat; char Query[512]; - char NewNameGrp[MAX_LENGTH_GROUP_NAME+1]; + char NewNameGrp[Grp_MAX_LENGTH_GROUP_NAME+1]; /***** Get parameters from form *****/ /* Get the code of the group */ @@ -4038,7 +4038,7 @@ void Grp_RenameGroup (void) Lay_ShowErrorAndExit ("Code of group is missing."); /* Get the new name for the group */ - Par_GetParToText ("GrpName",NewNameGrp,MAX_LENGTH_GROUP_NAME); + Par_GetParToText ("GrpName",NewNameGrp,Grp_MAX_LENGTH_GROUP_NAME); /***** Get from the database the type and the old name of the group *****/ GrpDat.GrpCod = Gbl.CurrentCrs.Grps.GrpCod; diff --git a/swad_group.h b/swad_group.h index 0a81e70f..4d1275a2 100644 --- a/swad_group.h +++ b/swad_group.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -34,8 +34,8 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ -#define MAX_LENGTH_GROUP_TYPE_NAME 255 -#define MAX_LENGTH_GROUP_NAME 255 +#define Grp_MAX_LENGTH_GROUP_TYPE_NAME (256 - 1) +#define Grp_MAX_LENGTH_GROUP_NAME (256 - 1) #define Grp_MAX_STUDENTS_IN_A_GROUP 10000 // If max of students in a group is greater than this, it is considered infinite @@ -55,8 +55,8 @@ struct GroupData long GrpCod; long GrpTypCod; long CrsCod; - char GrpTypName[MAX_LENGTH_GROUP_TYPE_NAME+1]; - char GrpName[MAX_LENGTH_GROUP_NAME+1]; + char GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME+1]; + char GrpName[Grp_MAX_LENGTH_GROUP_NAME+1]; unsigned MaxStudents; int Vacant; bool Open; // Group is open? @@ -66,7 +66,7 @@ struct GroupData struct Group { long GrpCod; // Code of group - char GrpName[MAX_LENGTH_GROUP_NAME+1]; // Name of group + char GrpName[Grp_MAX_LENGTH_GROUP_NAME+1]; // Name of group unsigned MaxStudents; unsigned NumStudents; // Number of students in the group bool Open; // Group is open? @@ -76,7 +76,7 @@ struct Group struct GroupType { long GrpTypCod; // Code of type of group - char GrpTypName[MAX_LENGTH_GROUP_TYPE_NAME+1]; // Name of type of group + char GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1]; // Name of type of group bool MandatoryEnrollment; // Enrollment is mandatory? bool MultipleEnrollment; // Enrollment is multiple? bool MustBeOpened; // Groups must be opened? diff --git a/swad_help.c b/swad_help.c index f7a4aeec..8431e8bc 100644 --- a/swad_help.c +++ b/swad_help.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_help.h b/swad_help.h index abe48c97..2ac1feee 100644 --- a/swad_help.h +++ b/swad_help.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_hierarchy.c b/swad_hierarchy.c index d41530f6..ddb68a7a 100644 --- a/swad_hierarchy.c +++ b/swad_hierarchy.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_hierarchy.h b/swad_hierarchy.h index f30468e5..9d0f11e2 100644 --- a/swad_hierarchy.h +++ b/swad_hierarchy.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_holiday.c b/swad_holiday.c index 020b2257..4ed5d8a7 100644 --- a/swad_holiday.c +++ b/swad_holiday.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_holiday.h b/swad_holiday.h index 98bad5aa..91986717 100644 --- a/swad_holiday.h +++ b/swad_holiday.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_icon.c b/swad_icon.c index b4c593f2..a37f9070 100644 --- a/swad_icon.c +++ b/swad_icon.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_icon.h b/swad_icon.h index 623725c5..86283b9a 100644 --- a/swad_icon.h +++ b/swad_icon.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_image.c b/swad_image.c index e8a73833..eb9e9609 100644 --- a/swad_image.c +++ b/swad_image.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_image.h b/swad_image.h index 6773825c..0c8550cb 100644 --- a/swad_image.h +++ b/swad_image.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_indicator.c b/swad_indicator.c index 12544942..cc20c51d 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_indicator.h b/swad_indicator.h index 2f5237bd..88dcc176 100644 --- a/swad_indicator.h +++ b/swad_indicator.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_info.c b/swad_info.c index b8f3cd8e..0678bff2 100644 --- a/swad_info.c +++ b/swad_info.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_info.h b/swad_info.h index b1602e0f..a8754157 100644 --- a/swad_info.h +++ b/swad_info.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_institution.c b/swad_institution.c index 40cc5ad7..221f7bd6 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_institution.h b/swad_institution.h index 70683533..955f8e64 100644 --- a/swad_institution.h +++ b/swad_institution.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_layout.c b/swad_layout.c index 25ea897a..2c46a340 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_layout.h b/swad_layout.h index f750120c..4a2eb571 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -33,10 +33,10 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Lay_MAX_BYTES_ALERT (16*1024) // Max. size for alert message +#define Lay_MAX_BYTES_ALERT (16*1024-1) // Max. size for alert message // Important: the size of alert message must be enough large to store the longest message. -#define Lay_MAX_BYTES_TITLE 1024 // Max. size for window status message +#define Lay_MAX_BYTES_TITLE (1024-1) #define Lay_HIDE_BOTH_COLUMNS 0 // 00 #define Lay_SHOW_RIGHT_COLUMN 1 // 01 diff --git a/swad_link.c b/swad_link.c index 63c6145b..01e51259 100644 --- a/swad_link.c +++ b/swad_link.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_link.h b/swad_link.h index 42e5d375..521558a8 100644 --- a/swad_link.h +++ b/swad_link.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_logo.c b/swad_logo.c index ed7b5df1..bdb5153e 100644 --- a/swad_logo.c +++ b/swad_logo.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_logo.h b/swad_logo.h index 38354c37..6c0c1e0e 100644 --- a/swad_logo.h +++ b/swad_logo.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_mail.c b/swad_mail.c index f58992d1..d2d22b01 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_mail.h b/swad_mail.h index 86c4bae3..6d9604df 100644 --- a/swad_mail.h +++ b/swad_mail.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_main.c b/swad_main.c index 762bf019..3feeec6f 100644 --- a/swad_main.c +++ b/swad_main.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_mark.c b/swad_mark.c index dda856f9..a0a17192 100644 --- a/swad_mark.c +++ b/swad_mark.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_mark.h b/swad_mark.h index 536d4c36..9b6ed1d6 100644 --- a/swad_mark.h +++ b/swad_mark.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_menu.c b/swad_menu.c index 3e637c0e..b223462e 100644 --- a/swad_menu.c +++ b/swad_menu.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_menu.h b/swad_menu.h index 074b770f..85ecaf24 100644 --- a/swad_menu.h +++ b/swad_menu.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_message.c b/swad_message.c index 0e5d1f38..cddc1ecb 100644 --- a/swad_message.c +++ b/swad_message.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -707,7 +707,7 @@ void Msg_RecMsgFromUsr (void) /***** Allocate space to store a list of recipients with the following format: "FirstName Surname1 Surname2; FirstName Surname1 Surname2; FirstName Surname1 Surname2" *****/ - if ((ListUsrsDst = (char *) malloc (((Usr_MAX_BYTES_NAME+1)*3+1)*NumRecipients)) == NULL) + if ((ListUsrsDst = (char *) malloc (((Usr_MAX_BYTES_NAME + 1) * 3 + 1)*NumRecipients)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store email addresses of recipients."); ListUsrsDst[0] = '\0'; diff --git a/swad_message.h b/swad_message.h index e2945a16..bac55cac 100644 --- a/swad_message.h +++ b/swad_message.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_network.c b/swad_network.c index 6011d42a..a0b022c2 100644 --- a/swad_network.c +++ b/swad_network.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_network.h b/swad_network.h index 24dcaace..289a0b64 100644 --- a/swad_network.h +++ b/swad_network.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_nickname.c b/swad_nickname.c index cbd10af9..259ad80b 100644 --- a/swad_nickname.c +++ b/swad_nickname.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_nickname.h b/swad_nickname.h index 19927e7f..6a76b90c 100644 --- a/swad_nickname.h +++ b/swad_nickname.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_notice.c b/swad_notice.c index 1f294815..23370ae5 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_notice.h b/swad_notice.h index 1c87b9c2..764fad44 100644 --- a/swad_notice.h +++ b/swad_notice.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_notification.c b/swad_notification.c index df6c7e09..263144bd 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -322,7 +322,7 @@ void Ntf_ShowMyNotifications (void) time_t DateTimeUTC; // Date-time of the event Ntf_Status_t Status; Ntf_StatusTxt_t StatusTxt; - char *SummaryStr; + char SummaryStr[Cns_MAX_BYTES_TEXT + 1]; char *ContentStr; const char *ClassBackground; const char *ClassAnchor; @@ -374,10 +374,6 @@ void Ntf_ShowMyNotifications (void) /***** List my notifications *****/ if (NumNotifications) // Notifications found { - /***** Allocate memory for the summary of the notification *****/ - if ((SummaryStr = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) - Lay_ShowErrorAndExit ("Not enough memory to store the summary of the notification."); - /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDat); @@ -628,9 +624,6 @@ void Ntf_ShowMyNotifications (void) /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&UsrDat); - - /***** Free summary *****/ - free ((void *) SummaryStr); } else Lay_ShowAlert (Lay_INFO,AllNotifications ? Txt_You_have_no_notifications : @@ -868,7 +861,7 @@ Ntf_StatusTxt_t Ntf_GetStatusTxtFromStatusBits (Ntf_Status_t Status) /******************* Get notification summary and content ********************/ /*****************************************************************************/ -void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr, +void Ntf_GetNotifSummaryAndContent (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, Ntf_NotifyEvent_t NotifyEvent, long Cod,long CrsCod,long UsrCod, unsigned MaxChars,bool GetContent) diff --git a/swad_notification.h b/swad_notification.h index c9272d19..d4e7a0ad 100644 --- a/swad_notification.h +++ b/swad_notification.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -107,7 +107,7 @@ void Ntf_ShowMyNotifications (void); Ntf_NotifyEvent_t Ntf_GetParamNotifyEvent (void); Ntf_StatusTxt_t Ntf_GetStatusTxtFromStatusBits (Ntf_Status_t Status); -void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr, +void Ntf_GetNotifSummaryAndContent (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, Ntf_NotifyEvent_t NotifyEvent, long Cod,long CrsCod,long UsrCod, unsigned MaxChars,bool GetContent); diff --git a/swad_pagination.c b/swad_pagination.c index cc81457d..c432c36d 100644 --- a/swad_pagination.c +++ b/swad_pagination.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_pagination.h b/swad_pagination.h index c12ff2ad..68c5bd54 100644 --- a/swad_pagination.h +++ b/swad_pagination.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_parameter.c b/swad_parameter.c index 2f7e9192..34a54a1e 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_parameter.h b/swad_parameter.h index 3722a272..f1c6e7f0 100644 --- a/swad_parameter.h +++ b/swad_parameter.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_password.c b/swad_password.c index 25f93974..2d1324d3 100644 --- a/swad_password.c +++ b/swad_password.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_password.h b/swad_password.h index da542bac..fa045188 100644 --- a/swad_password.h +++ b/swad_password.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_photo.c b/swad_photo.c index ac4cb4e4..947bbd7d 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -1129,9 +1129,9 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL, bool FormUnique) { extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; - char FullName [3*(Usr_MAX_BYTES_NAME_SPEC_CHAR+1)+1]; - char ShortName[3*(Usr_MAX_BYTES_NAME_SPEC_CHAR+1)+6]; - char Surnames [2*(Usr_MAX_BYTES_NAME_SPEC_CHAR+1)+1]; + char FullName [3*(Usr_MAX_BYTES_NAME+1)]; + char ShortName[3*(Usr_MAX_BYTES_NAME+1)]; + char Surnames [Usr_MAX_BYTES_SURNAMES + 1]; bool PhotoExists; bool PutLinkToPublicProfile = !Gbl.Form.Inside && // Only if not inside another form Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW; // Only in main window diff --git a/swad_photo.h b/swad_photo.h index 8737d1bd..91c0f763 100644 --- a/swad_photo.h +++ b/swad_photo.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_place.c b/swad_place.c index 487b1259..08dd8a47 100644 --- a/swad_place.c +++ b/swad_place.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_place.h b/swad_place.h index 21da89fd..67f6c529 100644 --- a/swad_place.h +++ b/swad_place.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_plugin.c b/swad_plugin.c index ca524bb1..56404ef1 100644 --- a/swad_plugin.c +++ b/swad_plugin.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_plugin.h b/swad_plugin.h index cb01a2a7..7dc5e91c 100644 --- a/swad_plugin.h +++ b/swad_plugin.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_preference.c b/swad_preference.c index 97966bd4..bf6990ad 100644 --- a/swad_preference.c +++ b/swad_preference.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_preference.h b/swad_preference.h index 10b83a24..490de559 100644 --- a/swad_preference.h +++ b/swad_preference.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_privacy.c b/swad_privacy.c index 2c250bfc..c4fd43ac 100644 --- a/swad_privacy.c +++ b/swad_privacy.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_privacy.h b/swad_privacy.h index 65da4a61..bfb7a81c 100644 --- a/swad_privacy.h +++ b/swad_privacy.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_privacy_visibility_type.h b/swad_privacy_visibility_type.h index a53f1674..7dd81f5e 100644 --- a/swad_privacy_visibility_type.h +++ b/swad_privacy_visibility_type.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_profile.c b/swad_profile.c index f71ab4e7..993a97a2 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_profile.h b/swad_profile.h index 7acc2a8e..db5c588c 100644 --- a/swad_profile.h +++ b/swad_profile.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_record.c b/swad_record.c index 598ff3fa..e43a7bc9 100644 --- a/swad_record.c +++ b/swad_record.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -2567,7 +2567,7 @@ static void Rec_ShowPhoto (struct UsrData *UsrDat) static void Rec_ShowFullName (struct UsrData *UsrDat) { - char Name[Usr_MAX_BYTES_NAME+1]; // To shorten length of FirstName, Surname1, Surname2 + char Name[Usr_MAX_BYTES_NAME + 1]; // To shorten length of FirstName, Surname1, Surname2 fprintf (Gbl.F.Out,""); diff --git a/swad_record.h b/swad_record.h index 65fdc321..294aaec4 100644 --- a/swad_record.h +++ b/swad_record.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_report.c b/swad_report.c index 31cfdcd4..6797da87 100644 --- a/swad_report.c +++ b/swad_report.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_report.h b/swad_report.h index 524908d3..1702de82 100644 --- a/swad_report.h +++ b/swad_report.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_role.c b/swad_role.c index 299ae309..7213f653 100644 --- a/swad_role.c +++ b/swad_role.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_role.h b/swad_role.h index a32b04b8..e623e212 100644 --- a/swad_role.h +++ b/swad_role.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_role_type.h b/swad_role_type.h index 22a4cc15..a9359c05 100644 --- a/swad_role_type.h +++ b/swad_role_type.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_scope.c b/swad_scope.c index aea2d379..20d46f8a 100644 --- a/swad_scope.c +++ b/swad_scope.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_scope.h b/swad_scope.h index 6a2d91ff..2f7b5440 100644 --- a/swad_scope.h +++ b/swad_scope.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_search.c b/swad_search.c index 24dbec84..2e3cc91b 100644 --- a/swad_search.c +++ b/swad_search.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as diff --git a/swad_search.h b/swad_search.h index b667f5c4..98d23204 100644 --- a/swad_search.h +++ b/swad_search.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_session.c b/swad_session.c index 3aa65204..275b1a19 100644 --- a/swad_session.c +++ b/swad_session.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_session.h b/swad_session.h index e4575fb8..8b0ef8fd 100644 --- a/swad_session.h +++ b/swad_session.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_setup.c b/swad_setup.c index 78a73a1b..44095f16 100644 --- a/swad_setup.c +++ b/swad_setup.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_setup.h b/swad_setup.h index 90efbdd3..674a6025 100644 --- a/swad_setup.h +++ b/swad_setup.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_social.c b/swad_social.c index d0a547fc..e41d4e20 100644 --- a/swad_social.c +++ b/swad_social.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as @@ -166,7 +166,7 @@ static void Soc_WriteDateTime (time_t TimeUTC); static void Soc_GetAndWriteSocialPost (long PstCod); static void Soc_PutFormGoToAction (const struct SocialNote *SocNot); static void Soc_GetNoteSummary (const struct SocialNote *SocNot, - char *SummaryStr,unsigned MaxChars); + char SummaryStr[Cns_MAX_BYTES_TEXT + 1],unsigned MaxChars); static void Soc_PublishSocialNoteInTimeline (struct SocialPublishing *SocPub); static void Soc_PutFormToWriteNewPost (void); @@ -1091,7 +1091,7 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot, bool ShowPhoto = false; char PhotoURL[PATH_MAX+1]; char ForumName[512]; - char SummaryStr[Cns_MAX_BYTES_TEXT+1]; + char SummaryStr[Cns_MAX_BYTES_TEXT + 1]; unsigned NumComments; char IdNewComment[Act_MAX_LENGTH_ID]; @@ -1689,7 +1689,7 @@ static void Soc_PutFormGoToAction (const struct SocialNote *SocNot) /*****************************************************************************/ static void Soc_GetNoteSummary (const struct SocialNote *SocNot, - char *SummaryStr,unsigned MaxChars) + char SummaryStr[Cns_MAX_BYTES_TEXT + 1],unsigned MaxChars) { SummaryStr[0] = '\0'; @@ -1955,7 +1955,7 @@ static void Soc_PutFormToWriteNewPost (void) extern const char *Txt_New_SOCIAL_post; bool ShowPhoto; char PhotoURL[PATH_MAX+1]; - char FullName[(Usr_MAX_BYTES_NAME+1)*3]; + char FullName[(Usr_MAX_BYTES_NAME + 1) * 3]; /***** Start list *****/ fprintf (Gbl.F.Out,"
    " diff --git a/swad_social.h b/swad_social.h index 9106e4ed..aa443cd1 100644 --- a/swad_social.h +++ b/swad_social.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_statistic.c b/swad_statistic.c index 30ef7a83..09977aba 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_statistic.h b/swad_statistic.h index 024cc9f7..92dbc708 100644 --- a/swad_statistic.h +++ b/swad_statistic.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_string.c b/swad_string.c index 66f66c65..8efaf332 100644 --- a/swad_string.c +++ b/swad_string.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -2706,15 +2706,19 @@ bool Str_ConvertFilFolLnkNameToValid (char *FileName) if (NumAlfanum) FileNameIsOK = true; else - sprintf (Gbl.Message, - Gbl.FileBrowser.UploadingWithDropzone ? Txt_UPLOAD_FILE_X_invalid_name_NO_HTML : - Txt_UPLOAD_FILE_X_invalid_name, - FileName); + snprintf (Gbl.Message,Lay_MAX_BYTES_ALERT, + Gbl.FileBrowser.UploadingWithDropzone ? Txt_UPLOAD_FILE_X_invalid_name_NO_HTML : + Txt_UPLOAD_FILE_X_invalid_name, + FileName); } else // FileName is empty - strcpy (Gbl.Message, - Gbl.FileBrowser.UploadingWithDropzone ? Txt_UPLOAD_FILE_Invalid_name_NO_HTML : - Txt_UPLOAD_FILE_Invalid_name); + { + strncpy (Gbl.Message, + Gbl.FileBrowser.UploadingWithDropzone ? Txt_UPLOAD_FILE_Invalid_name_NO_HTML : + Txt_UPLOAD_FILE_Invalid_name, + Lay_MAX_BYTES_ALERT); + Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0'; + } return FileNameIsOK; } diff --git a/swad_string.h b/swad_string.h index 0ef641c7..5394ee6b 100644 --- a/swad_string.h +++ b/swad_string.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_survey.c b/swad_survey.c index e16df0a7..81429b77 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -672,8 +672,8 @@ static void Svy_WriteAuthor (struct Survey *Svy) { bool ShowPhoto = false; char PhotoURL[PATH_MAX+1]; - char FirstName[Usr_MAX_BYTES_NAME+1]; - char Surnames[2*(Usr_MAX_BYTES_NAME+1)]; + char FirstName[Usr_MAX_BYTES_NAME + 1]; + char Surnames[Usr_MAX_BYTES_SURNAMES + 1]; struct UsrData UsrDat; /***** Initialize structure with user's data *****/ diff --git a/swad_survey.h b/swad_survey.h index 85380018..eafac453 100644 --- a/swad_survey.h +++ b/swad_survey.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_syllabus.c b/swad_syllabus.c index 96d81a07..25d42060 100644 --- a/swad_syllabus.c +++ b/swad_syllabus.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_syllabus.h b/swad_syllabus.h index 897ef1b6..bb8dd5f4 100644 --- a/swad_syllabus.h +++ b/swad_syllabus.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_tab.c b/swad_tab.c index c519d57c..9e375c3d 100644 --- a/swad_tab.c +++ b/swad_tab.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_tab.h b/swad_tab.h index d92e8005..33ab9b7f 100644 --- a/swad_tab.h +++ b/swad_tab.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_test.c b/swad_test.c index e929483a..ed7d679d 100644 --- a/swad_test.c +++ b/swad_test.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_test.h b/swad_test.h index 918ea405..292fe8df 100644 --- a/swad_test.h +++ b/swad_test.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_test_import.c b/swad_test_import.c index c916c8ee..d633da2f 100644 --- a/swad_test_import.c +++ b/swad_test_import.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_test_import.h b/swad_test_import.h index 2a93a7d1..caa9921c 100644 --- a/swad_test_import.h +++ b/swad_test_import.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_text.c b/swad_text.c index ba442f56..49bc4da6 100644 --- a/swad_text.c +++ b/swad_text.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas Catalā translation: Antonio Caņas Vargas diff --git a/swad_text.h b/swad_text.h index 2f90cba7..15005d23 100644 --- a/swad_text.h +++ b/swad_text.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_theme.c b/swad_theme.c index ac57eb78..b3d2078c 100644 --- a/swad_theme.c +++ b/swad_theme.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_theme.h b/swad_theme.h index dc0a71be..23a6d871 100644 --- a/swad_theme.h +++ b/swad_theme.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_timetable.c b/swad_timetable.c index fcdb71eb..a4270ad8 100644 --- a/swad_timetable.c +++ b/swad_timetable.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_timetable.h b/swad_timetable.h index 5e60387f..de70972c 100644 --- a/swad_timetable.h +++ b/swad_timetable.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_user.c b/swad_user.c index 0ef0f296..1c454edd 100644 --- a/swad_user.c +++ b/swad_user.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as @@ -741,8 +741,8 @@ void Usr_BuildFullName (struct UsrData *UsrDat) void Usr_RestrictLengthAndWriteName (const struct UsrData *UsrDat,unsigned MaxChars) { - char FirstName[Usr_MAX_BYTES_NAME_SPEC_CHAR+1]; - char Surnames[2*(Usr_MAX_BYTES_NAME_SPEC_CHAR+1)]; + char FirstName[Usr_MAX_BYTES_NAME + 1]; + char Surnames[Usr_MAX_BYTES_SURNAMES + 1]; /***** Restrict length of firstname and surnames *****/ strcpy (FirstName,UsrDat->FirstName); @@ -2089,7 +2089,7 @@ void Usr_WriteLoggedUsrHead (void) extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; bool ShowPhoto; char PhotoURL[PATH_MAX+1]; - char UsrName[Usr_MAX_BYTES_NAME+1]; + char UsrName[Usr_MAX_BYTES_NAME + 1]; /***** User's role *****/ if (Rol_GetNumAvailableRoles () == 1) @@ -5686,7 +5686,7 @@ static void Usr_ListMainDataStds (bool PutCheckBoxToSelectUsr) if (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { /***** Allocate memory for the string with the list of group names where student belongs to *****/ - if ((GroupNames = (char *) malloc ((MAX_LENGTH_GROUP_NAME+3)*Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal)) == NULL) + if ((GroupNames = (char *) malloc ((Grp_MAX_LENGTH_GROUP_NAME+3)*Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store names of groups."); /***** Start table with list of students *****/ @@ -6007,7 +6007,7 @@ void Usr_ListAllDataStds (void) /***** Allocate memory for the string with the list of group names where student belongs to *****/ if (Gbl.Scope.Current == Sco_SCOPE_CRS) - if ((GroupNames = (char *) malloc ((MAX_LENGTH_GROUP_NAME+3)*Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal)) == NULL) + if ((GroupNames = (char *) malloc ((Grp_MAX_LENGTH_GROUP_NAME+3)*Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store names of groups."); /***** Start table with list of students *****/ diff --git a/swad_user.h b/swad_user.h index 08075029..4ba17382 100644 --- a/swad_user.h +++ b/swad_user.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -53,13 +53,17 @@ #define Usr_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 12 #define Usr_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 60 -#define Usr_MAX_BYTES_USR_EMAIL 127 -#define Usr_MAX_LENGTH_USR_LOGIN 127 // @nick, email or ID -#define Usr_MAX_BYTES_USR_LOGIN 127 +#define Usr_MAX_BYTES_USR_EMAIL (128-1) +#define Usr_MAX_LENGTH_USR_LOGIN (128-1) // @nick, email or ID +#define Usr_MAX_BYTES_USR_LOGIN (128-1) #define Usr_MAX_LENGTH_USR_NAME_OR_SURNAME 32 #define Usr_MAX_BYTES_NAME 32 -#define Usr_MAX_BYTES_NAME_SPEC_CHAR (Usr_MAX_BYTES_NAME*Str_MAX_LENGTH_SPEC_CHAR_HTML) + +#define Usr_MAX_BYTES_SURNAMES (Usr_MAX_BYTES_NAME + 1 + Usr_MAX_BYTES_NAME) + // Surname1 +' '+ Surname2 +#define Usr_MAX_BYTES_FULL_NAME (Usr_MAX_BYTES_NAME + 1 + Usr_MAX_BYTES_NAME + 1 + 1 + Usr_MAX_BYTES_NAME) + // Surname1 +' '+ Surname2 +','+' '+ FirstName #define Usr_BIRTHDAY_STR_DB_LENGTH (1+4+1+2+1+2+1) // "'%04u-%02u-%02u'" @@ -126,10 +130,10 @@ struct UsrData // >=0 ==> filled/calculated // <0 ==> not yet filled/calculated bool Accepted; // User has accepted joining to current course? - char Surname1 [Usr_MAX_BYTES_NAME+1]; - char Surname2 [Usr_MAX_BYTES_NAME+1]; - char FirstName [Usr_MAX_BYTES_NAME+1]; - char FullName [(Usr_MAX_BYTES_NAME+1)*3]; + char Surname1 [Usr_MAX_BYTES_NAME + 1]; + char Surname2 [Usr_MAX_BYTES_NAME + 1]; + char FirstName [Usr_MAX_BYTES_NAME + 1]; + char FullName [(Usr_MAX_BYTES_NAME + 1)*3]; Usr_Sex_t Sex; char Email [Usr_MAX_BYTES_USR_EMAIL+1]; bool EmailConfirmed; @@ -179,9 +183,9 @@ struct UsrInList { long UsrCod; char EncryptedUsrCod [Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+1]; - char Surname1 [Usr_MAX_BYTES_NAME+1]; - char Surname2 [Usr_MAX_BYTES_NAME+1]; - char FirstName[Usr_MAX_BYTES_NAME+1]; + char Surname1 [Usr_MAX_BYTES_NAME + 1]; + char Surname2 [Usr_MAX_BYTES_NAME + 1]; + char FirstName[Usr_MAX_BYTES_NAME + 1]; Usr_Sex_t Sex; char Photo[Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+1]; // Name of public link to photo Pri_Visibility_t PhotoVisibility; // Who can see user's photo diff --git a/swad_web_service.c b/swad_web_service.c index aa22cb04..f1a520b7 100644 --- a/swad_web_service.c +++ b/swad_web_service.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -595,8 +595,8 @@ static bool Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod) /* Get user's brithday */ if (row[4]) { - strncpy (UsrDat->Birthday.YYYYMMDD,row[4],4+2+2); - UsrDat->Birthday.YYYYMMDD[4+2+2] = '\0'; + strncpy (UsrDat->Birthday.YYYYMMDD,row[4],Dat_LENGTH_YYYYMMDD); + UsrDat->Birthday.YYYYMMDD[Dat_LENGTH_YYYYMMDD] = '\0'; } else strcpy (UsrDat->Birthday.YYYYMMDD,"00000000"); @@ -815,9 +815,9 @@ int swad__loginByUserPasswordKey (struct soap *soap, loginByUserPasswordKeyOut->wsKey = (char *) soap_malloc (Gbl.soap,256); loginByUserPasswordKeyOut->userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA+1); loginByUserPasswordKeyOut->userID = (char *) soap_malloc (Gbl.soap,256); - loginByUserPasswordKeyOut->userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1); - loginByUserPasswordKeyOut->userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1); - loginByUserPasswordKeyOut->userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1); + loginByUserPasswordKeyOut->userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); + loginByUserPasswordKeyOut->userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); + loginByUserPasswordKeyOut->userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); loginByUserPasswordKeyOut->userPhoto = (char *) soap_malloc (Gbl.soap,PATH_MAX+1); loginByUserPasswordKeyOut->userBirthday = (char *) soap_malloc (Gbl.soap,8+2+2+1); @@ -917,19 +917,19 @@ int swad__loginByUserPasswordKey (struct soap *soap, loginByUserPasswordKeyOut->userID[255] = '\0'; } - strncpy (loginByUserPasswordKeyOut->userSurname1,Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME_SPEC_CHAR); - loginByUserPasswordKeyOut->userSurname1[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0'; - strncpy (loginByUserPasswordKeyOut->userSurname2,Gbl.Usrs.Me.UsrDat.Surname2,Usr_MAX_BYTES_NAME_SPEC_CHAR); - loginByUserPasswordKeyOut->userSurname2[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0'; - strncpy (loginByUserPasswordKeyOut->userFirstname,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME_SPEC_CHAR); - loginByUserPasswordKeyOut->userFirstname[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0'; + strncpy (loginByUserPasswordKeyOut->userSurname1 ,Gbl.Usrs.Me.UsrDat.Surname1 ,Usr_MAX_BYTES_NAME); + loginByUserPasswordKeyOut->userSurname1 [Usr_MAX_BYTES_NAME] = '\0'; + strncpy (loginByUserPasswordKeyOut->userSurname2 ,Gbl.Usrs.Me.UsrDat.Surname2 ,Usr_MAX_BYTES_NAME); + loginByUserPasswordKeyOut->userSurname2 [Usr_MAX_BYTES_NAME] = '\0'; + strncpy (loginByUserPasswordKeyOut->userFirstname,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME); + loginByUserPasswordKeyOut->userFirstname[Usr_MAX_BYTES_NAME] = '\0'; Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL); strncpy (loginByUserPasswordKeyOut->userPhoto,PhotoURL,PATH_MAX); loginByUserPasswordKeyOut->userPhoto[PATH_MAX] = '\0'; - strncpy (loginByUserPasswordKeyOut->userBirthday,Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,4+2+2); - loginByUserPasswordKeyOut->userBirthday[4+2+2] = '\0'; + strncpy (loginByUserPasswordKeyOut->userBirthday,Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,Dat_LENGTH_YYYYMMDD); + loginByUserPasswordKeyOut->userBirthday[Dat_LENGTH_YYYYMMDD] = '\0'; loginByUserPasswordKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB]; @@ -975,11 +975,11 @@ int swad__loginBySessionKey (struct soap *soap, /***** Allocate space for strings *****/ loginBySessionKeyOut->wsKey = (char *) soap_malloc (Gbl.soap,256); - loginBySessionKeyOut->userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA+1); + loginBySessionKeyOut->userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA + 1); loginBySessionKeyOut->userID = (char *) soap_malloc (Gbl.soap,256); - loginBySessionKeyOut->userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1); - loginBySessionKeyOut->userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1); - loginBySessionKeyOut->userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1); + loginBySessionKeyOut->userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); + loginBySessionKeyOut->userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); + loginBySessionKeyOut->userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); loginBySessionKeyOut->userPhoto = (char *) soap_malloc (Gbl.soap,PATH_MAX+1); loginBySessionKeyOut->userBirthday = (char *) soap_malloc (Gbl.soap,8+2+2+1); loginBySessionKeyOut->degreeName = (char *) soap_malloc (Gbl.soap,256); @@ -1071,19 +1071,19 @@ int swad__loginBySessionKey (struct soap *soap, loginBySessionKeyOut->userID[255] = '\0'; } - strncpy (loginBySessionKeyOut->userSurname1,Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME_SPEC_CHAR); - loginBySessionKeyOut->userSurname1[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0'; - strncpy (loginBySessionKeyOut->userSurname2,Gbl.Usrs.Me.UsrDat.Surname2,Usr_MAX_BYTES_NAME_SPEC_CHAR); - loginBySessionKeyOut->userSurname2[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0'; - strncpy (loginBySessionKeyOut->userFirstname,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME_SPEC_CHAR); - loginBySessionKeyOut->userFirstname[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0'; + strncpy (loginBySessionKeyOut->userSurname1 ,Gbl.Usrs.Me.UsrDat.Surname1 ,Usr_MAX_BYTES_NAME); + loginBySessionKeyOut->userSurname1 [Usr_MAX_BYTES_NAME] = '\0'; + strncpy (loginBySessionKeyOut->userSurname2 ,Gbl.Usrs.Me.UsrDat.Surname2 ,Usr_MAX_BYTES_NAME); + loginBySessionKeyOut->userSurname2 [Usr_MAX_BYTES_NAME] = '\0'; + strncpy (loginBySessionKeyOut->userFirstname,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME); + loginBySessionKeyOut->userFirstname[Usr_MAX_BYTES_NAME] = '\0'; Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL); strncpy (loginBySessionKeyOut->userPhoto,PhotoURL,PATH_MAX); loginBySessionKeyOut->userPhoto[PATH_MAX] = '\0'; - strncpy (loginBySessionKeyOut->userBirthday,Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,4+2+2); - loginBySessionKeyOut->userBirthday[4+2+2] = '\0'; + strncpy (loginBySessionKeyOut->userBirthday,Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,Dat_LENGTH_YYYYMMDD); + loginBySessionKeyOut->userBirthday[Dat_LENGTH_YYYYMMDD] = '\0'; loginBySessionKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB]; @@ -2804,7 +2804,7 @@ int swad__getNotifications (struct soap *soap, struct Course Crs; long Cod; char ForumName[512]; - char *SummaryStr; + char SummaryStr[Cns_MAX_BYTES_TEXT + 1]; char *ContentStr; Ntf_Status_t Status; @@ -2842,12 +2842,6 @@ int swad__getNotifications (struct soap *soap, NumNotifications = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get user's notifications"); if (NumNotifications) // Notifications found { - /* Allocate memory for summary string */ - if ((SummaryStr = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) - return soap_receiver_fault (Gbl.soap, - "Not enough memory", - "Not enough memory to store the summary of the notification"); - getNotificationsOut->numNotifications = (int) NumNotifications; getNotificationsOut->notificationsArray.__size = (int) NumNotifications; getNotificationsOut->notificationsArray.__ptr = soap_malloc (Gbl.soap,(getNotificationsOut->notificationsArray.__size) * sizeof (*(getNotificationsOut->notificationsArray.__ptr))); @@ -2888,17 +2882,17 @@ int swad__getNotifications (struct soap *soap, strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname,Gbl.Usrs.Other.UsrDat.Nickname,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA); getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA] = '\0'; - getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1); - strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1,Gbl.Usrs.Other.UsrDat.Surname1,Usr_MAX_BYTES_NAME_SPEC_CHAR); - getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0'; + getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); + strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 ,Gbl.Usrs.Other.UsrDat.Surname1 ,Usr_MAX_BYTES_NAME); + getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 [Usr_MAX_BYTES_NAME] = '\0'; - getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1); - strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2,Gbl.Usrs.Other.UsrDat.Surname2,Usr_MAX_BYTES_NAME_SPEC_CHAR); - getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0'; + getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); + strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 ,Gbl.Usrs.Other.UsrDat.Surname2 ,Usr_MAX_BYTES_NAME); + getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 [Usr_MAX_BYTES_NAME] = '\0'; - getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME_SPEC_CHAR+1); - strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname,Gbl.Usrs.Other.UsrDat.FirstName,Usr_MAX_BYTES_NAME_SPEC_CHAR); - getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname[Usr_MAX_BYTES_NAME_SPEC_CHAR] = '\0'; + getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); + strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname,Gbl.Usrs.Other.UsrDat.FirstName,Usr_MAX_BYTES_NAME); + getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname[Usr_MAX_BYTES_NAME] = '\0'; Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL); getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto = (char *) soap_malloc (Gbl.soap,PATH_MAX+1); @@ -2989,9 +2983,6 @@ int swad__getNotifications (struct soap *soap, ContentStr = NULL; } } - - /* Free memory used by summary string */ - free ((void *) SummaryStr); } else // No notifications found { diff --git a/swad_web_service.h b/swad_web_service.h index 812e040a..65757838 100644 --- a/swad_web_service.h +++ b/swad_web_service.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_xml.c b/swad_xml.c index cac30aed..3a400f37 100644 --- a/swad_xml.c +++ b/swad_xml.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_xml.h b/swad_xml.h index de64aabb..64911497 100644 --- a/swad_xml.h +++ b/swad_xml.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/swad_zip.c b/swad_zip.c index 4de674ef..afd11c81 100644 --- a/swad_zip.c +++ b/swad_zip.c @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as @@ -285,7 +285,7 @@ static void ZIP_CreateTmpDirForCompression (void) static void ZIP_CreateDirCompressionUsr (struct UsrData *UsrDat) { - char FullNameAndUsrID[(Usr_MAX_BYTES_NAME+1)*3+ + char FullNameAndUsrID[(Usr_MAX_BYTES_NAME + 1)*3+ ID_MAX_LENGTH_USR_ID+1+ 10+1]; char PathFolderUsrInsideCrs[PATH_MAX+1]; diff --git a/swad_zip.h b/swad_zip.h index e3f4c4c2..f8edefae 100644 --- a/swad_zip.h +++ b/swad_zip.h @@ -8,7 +8,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2016 Antonio Caņas Vargas + Copyright (C) 1999-2017 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as