diff --git a/swad_ID.c b/swad_ID.c index 2a13accf..a51d1705 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -810,7 +810,9 @@ static void ID_RemoveUsrID (const struct UsrData *UsrDat,bool ItsMe) /***** Show message *****/ Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = ID_ID_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_ID_X_removed,UsrID); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_ID_X_removed, + UsrID); } else { @@ -950,8 +952,9 @@ static void ID_NewUsrID (const struct UsrData *UsrDat,bool ItsMe) { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = ID_ID_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_ID_X_matches_one_of_the_existing, - NewID); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_ID_X_matches_one_of_the_existing, + NewID); } else // It's not me && !Confirmed { @@ -960,16 +963,18 @@ static void ID_NewUsrID (const struct UsrData *UsrDat,bool ItsMe) Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = ID_ID_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_ID_X_has_been_confirmed, - NewID); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_ID_X_has_been_confirmed, + NewID); } } else if (UsrDat->IDs.Num >= ID_MAX_IDS_PER_USER) { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = ID_ID_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_A_user_can_not_have_more_than_X_IDs, - ID_MAX_IDS_PER_USER); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_A_user_can_not_have_more_than_X_IDs, + ID_MAX_IDS_PER_USER); } else // OK ==> add this new ID to my list of IDs { @@ -980,15 +985,18 @@ static void ID_NewUsrID (const struct UsrData *UsrDat,bool ItsMe) Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = ID_ID_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_ID_X_has_been_registered_successfully, - NewID); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_ID_X_has_been_registered_successfully, + NewID); } } else // New ID is not valid { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = ID_ID_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_ID_X_is_not_valid,NewID); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_ID_X_is_not_valid, + NewID); } } else @@ -1074,8 +1082,9 @@ void ID_ConfirmOtherUsrID (void) /***** ID found and already confirmed *****/ Gbl.Alert.Type = Ale_INFO; Gbl.Alert.Section = ID_ID_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_ID_X_had_already_been_confirmed, - Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].ID); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_ID_X_had_already_been_confirmed, + Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].ID); } else { @@ -1087,8 +1096,9 @@ void ID_ConfirmOtherUsrID (void) /***** Write success message *****/ Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = ID_ID_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_ID_X_has_been_confirmed, - Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].ID); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_ID_X_has_been_confirmed, + Gbl.Usrs.Other.UsrDat.IDs.List[NumIDFound].ID); } } else // User's ID not found diff --git a/swad_account.c b/swad_account.c index 401ec9a2..b54b2d15 100644 --- a/swad_account.c +++ b/swad_account.c @@ -247,8 +247,9 @@ void Acc_CheckIfEmptyAccountExists (void) } else { - sprintf (Gbl.Alert.Txt,Txt_There_is_no_empty_account_associated_with_your_ID_X, - ID); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_is_no_empty_account_associated_with_your_ID_X, + ID); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } @@ -630,18 +631,20 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES if (DB_QueryCOUNT (Query,"can not check if nickname already existed")) // A nickname of another user is the same that this nickname { Error = true; - sprintf (Gbl.Alert.Txt,Txt_The_nickname_X_had_been_registered_by_another_user, - NewNicknameWithoutArroba); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_nickname_X_had_been_registered_by_another_user, + NewNicknameWithoutArroba); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } } else // New nickname is not valid { Error = true; - sprintf (Gbl.Alert.Txt,Txt_The_nickname_entered_X_is_not_valid_, - NewNicknameWithArroba, - Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA, - Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_nickname_entered_X_is_not_valid_, + NewNicknameWithArroba, + Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA, + Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } @@ -658,16 +661,18 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES if (DB_QueryCOUNT (Query,"can not check if email already existed")) // An email of another user is the same that my email { Error = true; - sprintf (Gbl.Alert.Txt,Txt_The_email_address_X_had_been_registered_by_another_user, - NewEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_address_X_had_been_registered_by_another_user, + NewEmail); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } } else // New email is not valid { Error = true; - sprintf (Gbl.Alert.Txt,Txt_The_email_address_entered_X_is_not_valid, - NewEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_address_entered_X_is_not_valid, + NewEmail); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } @@ -836,9 +841,10 @@ void Acc_AfterCreationNewAccount (void) if (Gbl.Usrs.Me.Logged) // If account has been created without problem, I am logged { /***** Show message of success *****/ - sprintf (Gbl.Alert.Txt,Txt_Congratulations_You_have_created_your_account_X_Now_Y_will_request_you_, - Gbl.Usrs.Me.UsrDat.Nickname, - Cfg_PLATFORM_SHORT_NAME); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Congratulations_You_have_created_your_account_X_Now_Y_will_request_you_, + Gbl.Usrs.Me.UsrDat.Nickname, + Cfg_PLATFORM_SHORT_NAME); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show form with account data *****/ @@ -1038,8 +1044,9 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, if (QuietOrVerbose == Cns_VERBOSE) { - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_removed_from_all_his_her_courses, - UsrDat->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_removed_from_all_his_her_courses, + UsrDat->FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1050,8 +1057,9 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, if (QuietOrVerbose == Cns_VERBOSE) { - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_removed_as_administrator, - UsrDat->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_removed_as_administrator, + UsrDat->FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1065,8 +1073,9 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, Acc_RemoveUsrBriefcase (UsrDat); if (QuietOrVerbose == Cns_VERBOSE) { - sprintf (Gbl.Alert.Txt,Txt_Briefcase_of_THE_USER_X_has_been_removed, - UsrDat->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Briefcase_of_THE_USER_X_has_been_removed, + UsrDat->FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1081,8 +1090,9 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, Msg_DelAllRecAndSntMsgsUsr (UsrDat->UsrCod); if (QuietOrVerbose == Cns_VERBOSE) { - sprintf (Gbl.Alert.Txt,Txt_Messages_of_THE_USER_X_have_been_deleted, - UsrDat->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Messages_of_THE_USER_X_have_been_deleted, + UsrDat->FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1128,8 +1138,9 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, PhotoRemoved = Pho_RemovePhoto (UsrDat); if (PhotoRemoved && QuietOrVerbose == Cns_VERBOSE) { - sprintf (Gbl.Alert.Txt,Txt_Photo_of_THE_USER_X_has_been_removed, - UsrDat->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Photo_of_THE_USER_X_has_been_removed, + UsrDat->FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1137,8 +1148,9 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, Acc_RemoveUsr (UsrDat); if (QuietOrVerbose == Cns_VERBOSE) { - sprintf (Gbl.Alert.Txt,Txt_Record_card_of_THE_USER_X_has_been_removed, - UsrDat->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Record_card_of_THE_USER_X_has_been_removed, + UsrDat->FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } diff --git a/swad_agenda.c b/swad_agenda.c index 36910298..6bc457fe 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -1299,8 +1299,9 @@ void Agd_AskRemEvent (void) /***** Show question and button to remove event *****/ Gbl.Agenda.AgdCodToEdit = AgdEvent.AgdCod; - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_event_X, - AgdEvent.Event); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_event_X, + AgdEvent.Event); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, ActRemEvtMyAgd,NULL,NULL, Agd_PutCurrentParamsMyAgenda, @@ -1335,7 +1336,9 @@ void Agd_RemoveEvent (void) DB_QueryDELETE (Query,"can not remove event"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Event_X_removed,AgdEvent.Event); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Event_X_removed, + AgdEvent.Event); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show events again *****/ @@ -1367,7 +1370,9 @@ void Agd_HideEvent (void) DB_QueryUPDATE (Query,"can not hide event"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Event_X_is_now_hidden,AgdEvent.Event); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Event_X_is_now_hidden, + AgdEvent.Event); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show events again *****/ @@ -1399,8 +1404,9 @@ void Agd_UnhideEvent (void) DB_QueryUPDATE (Query,"can not show event"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Event_X_is_now_visible, - AgdEvent.Event); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Event_X_is_now_visible, + AgdEvent.Event); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show events again *****/ @@ -1432,7 +1438,9 @@ void Agd_MakeEventPrivate (void) DB_QueryUPDATE (Query,"can not make event private"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Event_X_is_now_private,AgdEvent.Event); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Event_X_is_now_private, + AgdEvent.Event); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show events again *****/ @@ -1464,8 +1472,9 @@ void Agd_MakeEventPublic (void) DB_QueryUPDATE (Query,"can not make event public"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Event_X_is_now_visible_to_users_of_your_courses, - AgdEvent.Event); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Event_X_is_now_visible_to_users_of_your_courses, + AgdEvent.Event); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show events again *****/ @@ -1664,7 +1673,9 @@ void Agd_RecFormEvent (void) Agd_CreateEvent (&AgdEvent,Txt); // Add new event to database /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_event_X,AgdEvent.Event); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_event_X, + AgdEvent.Event); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else diff --git a/swad_assignment.c b/swad_assignment.c index 60758b68..e2a1ca66 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -972,8 +972,9 @@ void Asg_ReqRemAssignment (void) /***** Show question and button to remove the assignment *****/ Gbl.Asgs.AsgCodToEdit = Asg.AsgCod; - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_assignment_X, - Asg.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_assignment_X, + Asg.Title); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, ActRemAsg,NULL,NULL,Asg_PutParams, Btn_REMOVE_BUTTON,Txt_Remove_assignment); @@ -1016,8 +1017,9 @@ void Asg_RemoveAssignment (void) Ntf_MarkNotifAsRemoved (Ntf_EVENT_ASSIGNMENT,Asg.AsgCod); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Assignment_X_removed, - Asg.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Assignment_X_removed, + Asg.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show assignments again *****/ @@ -1048,8 +1050,9 @@ void Asg_HideAssignment (void) DB_QueryUPDATE (Query,"can not hide assignment"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Assignment_X_is_now_hidden, - Asg.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Assignment_X_is_now_hidden, + Asg.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show assignments again *****/ @@ -1080,8 +1083,9 @@ void Asg_ShowAssignment (void) DB_QueryUPDATE (Query,"can not show assignment"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Assignment_X_is_now_visible, - Asg.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Assignment_X_is_now_visible, + Asg.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show assignments again *****/ @@ -1368,8 +1372,9 @@ void Asg_RecFormAssignment (void) if (Asg_CheckIfSimilarAssignmentExists ("Title",NewAsg.Title,NewAsg.AsgCod)) { NewAssignmentIsCorrect = false; - sprintf (Gbl.Alert.Txt,Txt_Already_existed_an_assignment_with_the_title_X, - NewAsg.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Already_existed_an_assignment_with_the_title_X, + NewAsg.Title); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // Title is correct @@ -1381,8 +1386,9 @@ void Asg_RecFormAssignment (void) if (Asg_CheckIfSimilarAssignmentExists ("Folder",NewAsg.Folder,NewAsg.AsgCod)) // If folder of assignment was in database... { NewAssignmentIsCorrect = false; - sprintf (Gbl.Alert.Txt,Txt_Already_existed_an_assignment_with_the_folder_X, - NewAsg.Folder); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Already_existed_an_assignment_with_the_folder_X, + NewAsg.Folder); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } } @@ -1422,7 +1428,9 @@ void Asg_RecFormAssignment (void) Asg_CreateAssignment (&NewAsg,Txt); // Add new assignment to database /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_assignment_X,NewAsg.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_assignment_X, + NewAsg.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else diff --git a/swad_attendance.c b/swad_attendance.c index 048d4287..8b517fe0 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -887,8 +887,9 @@ void Att_AskRemAttEvent (void) Pag_PutHiddenParamPagNum (Pag_ATT_EVENTS,Gbl.AttEvents.CurrentPage); /***** Ask for confirmation of removing *****/ - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_event_X, - Att.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_event_X, + Att.Title); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); Btn_PutRemoveButton (Txt_Remove_event); Act_EndForm (); @@ -918,7 +919,9 @@ void Att_GetAndRemAttEvent (void) Att_RemoveAttEventFromDB (Att.AttCod); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Event_X_removed,Att.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Event_X_removed, + Att.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show attendance events again *****/ @@ -965,8 +968,9 @@ void Att_HideAttEvent (void) DB_QueryUPDATE (Query,"can not hide attendance event"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Event_X_is_now_hidden, - Att.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Event_X_is_now_hidden, + Att.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show attendance events again *****/ @@ -997,8 +1001,9 @@ void Att_ShowAttEvent (void) DB_QueryUPDATE (Query,"can not show attendance event"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Event_X_is_now_visible, - Att.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Event_X_is_now_visible, + Att.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show attendance events again *****/ @@ -1282,8 +1287,9 @@ void Att_RecFormAttEvent (void) if (Att_CheckIfSimilarAttEventExists ("Title",ReceivedAtt.Title,ReceivedAtt.AttCod)) { ReceivedAttEventIsCorrect = false; - sprintf (Gbl.Alert.Txt,Txt_Already_existed_an_event_with_the_title_X, - ReceivedAtt.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Already_existed_an_event_with_the_title_X, + ReceivedAtt.Title); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } } @@ -1305,7 +1311,9 @@ void Att_RecFormAttEvent (void) Att_CreateAttEvent (&ReceivedAtt,Txt); // Add new attendance event to database /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_event_X,ReceivedAtt.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_event_X, + ReceivedAtt.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -2396,8 +2404,9 @@ void Att_RegisterStudentsInAttEvent (void) /***** Write final message *****/ sprintf (Format,"%s: %%u
%s: %%u",Txt_Presents,Txt_Absents); - sprintf (Gbl.Alert.Txt,Format, - NumStdsPresent,NumStdsAbsent); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Format, + NumStdsPresent,NumStdsAbsent); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0 diff --git a/swad_banner.c b/swad_banner.c index c0bc8da3..6a9efe1d 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -521,8 +521,9 @@ void Ban_RemoveBanner (void) DB_QueryDELETE (Query,"can not remove a banner"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Banner_X_removed, - Ban.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Banner_X_removed, + Ban.ShrtName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show the form again *****/ @@ -579,9 +580,10 @@ static void Ban_ShowOrHideBanner (bool Hide) } /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Hide ? Txt_The_banner_X_is_now_hidden : - Txt_The_banner_X_is_now_visible, - Ban.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Hide ? Txt_The_banner_X_is_now_hidden : + Txt_The_banner_X_is_now_visible, + Ban.ShrtName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show the form again *****/ @@ -654,8 +656,9 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Check if new name is empty *****/ if (!NewBanName[0]) { - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_banner_X_empty, - CurrentBanName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_banner_X_empty, + CurrentBanName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -666,8 +669,9 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName) /***** If banner was in database... *****/ if (Ban_CheckIfBannerNameExists (ParamName,NewBanName,Ban->BanCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_banner_X_already_exists, - NewBanName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_banner_X_already_exists, + NewBanName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -676,15 +680,17 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName) Ban_UpdateBanNameDB (Ban->BanCod,FieldName,NewBanName); /* Write message to show the change made */ - sprintf (Gbl.Alert.Txt,Txt_The_banner_X_has_been_renamed_as_Y, - CurrentBanName,NewBanName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_banner_X_has_been_renamed_as_Y, + CurrentBanName,NewBanName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } else // The same name { - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_banner_X_has_not_changed, - CurrentBanName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_banner_X_has_not_changed, + CurrentBanName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -755,8 +761,9 @@ void Ban_ChangeBannerImg (void) DB_QueryUPDATE (Query,"can not update the image of a banner"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_image_is_X, - NewImg); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_image_is_X, + NewImg); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -800,8 +807,9 @@ void Ban_ChangeBannerWWW (void) DB_QueryUPDATE (Query,"can not update the web of a banner"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X, - NewWWW); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_web_address_is_X, + NewWWW); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -946,14 +954,16 @@ void Ban_RecFormNewBanner (void) /***** If name of banner was in database... *****/ if (Ban_CheckIfBannerNameExists ("ShortName",Ban->ShrtName,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_banner_X_already_exists, - Ban->ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_banner_X_already_exists, + Ban->ShrtName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (Ban_CheckIfBannerNameExists ("FullName",Ban->FullName,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_banner_X_already_exists, - Ban->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_banner_X_already_exists, + Ban->FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (!Ban->Img[0]) @@ -988,8 +998,9 @@ static void Ban_CreateBanner (struct Banner *Ban) DB_QueryINSERT (Query,"can not create banner"); /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_banner_X, - Ban->ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_banner_X, + Ban->ShrtName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_centre.c b/swad_centre.c index 1b04fa85..6366c536 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -1775,8 +1775,9 @@ void Ctr_RemoveCentre (void) DB_QueryDELETE (Query,"can not remove a centre"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Centre_X_removed, - Ctr.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Centre_X_removed, + Ctr.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1810,8 +1811,9 @@ void Ctr_ChangeCtrInsInConfig (void) NewIns.InsCod)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_centre_X_already_exists, - Gbl.CurrentCtr.Ctr.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_centre_X_already_exists, + Gbl.CurrentCtr.Ctr.ShrtName); } else if (Ctr_CheckIfCtrNameExistsInIns ("FullName", Gbl.CurrentCtr.Ctr.FullName, @@ -1819,8 +1821,9 @@ void Ctr_ChangeCtrInsInConfig (void) NewIns.InsCod)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_centre_X_already_exists, - Gbl.CurrentCtr.Ctr.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_centre_X_already_exists, + Gbl.CurrentCtr.Ctr.FullName); } else { @@ -1834,8 +1837,9 @@ void Ctr_ChangeCtrInsInConfig (void) /***** Write message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_centre_X_has_been_moved_to_the_institution_Y, - Gbl.CurrentCtr.Ctr.FullName,NewIns.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_centre_X_has_been_moved_to_the_institution_Y, + Gbl.CurrentCtr.Ctr.FullName,NewIns.FullName); } } } @@ -2005,8 +2009,9 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull if (!NewCtrName[0]) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_centre_X_empty, - CurrentCtrName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_centre_X_empty, + CurrentCtrName); } else { @@ -2017,7 +2022,8 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull if (Ctr_CheckIfCtrNameExistsInIns (ParamName,NewCtrName,Ctr->CtrCod,Gbl.CurrentIns.Ins.InsCod)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_centre_X_already_exists,NewCtrName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_centre_X_already_exists,NewCtrName); } else { @@ -2026,8 +2032,9 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull /* Write message to show the change made */ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_centre_X_has_been_renamed_as_Y, - CurrentCtrName,NewCtrName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_centre_X_has_been_renamed_as_Y, + CurrentCtrName,NewCtrName); /* Change current centre name in order to display it properly */ Str_Copy (CurrentCtrName,NewCtrName, @@ -2037,8 +2044,9 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull else // The same name { Gbl.Alert.Type = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_centre_X_has_not_changed, - CurrentCtrName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_centre_X_has_not_changed, + CurrentCtrName); } } } @@ -2102,7 +2110,9 @@ void Ctr_ChangeCtrWWW (void) /***** Write message to show the change made and put button to go to centre changed *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X,NewWWW); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_web_address_is_X, + NewWWW); Ctr_ShowAlertAndButtonToGoToCtr (); } else @@ -2131,7 +2141,9 @@ void Ctr_ChangeCtrWWWInConfig (void) Cns_MAX_BYTES_WWW); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X,NewWWW); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_web_address_is_X, + NewWWW); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -2193,8 +2205,9 @@ void Ctr_ChangeCtrStatus (void) /***** Write message to show the change made and put button to go to centre changed *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_status_of_the_centre_X_has_changed, - Gbl.Ctrs.EditingCtr.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_status_of_the_centre_X_has_changed, + Gbl.Ctrs.EditingCtr.ShrtName); Ctr_ShowAlertAndButtonToGoToCtr (); /***** Show the form again *****/ @@ -2293,14 +2306,15 @@ void Ctr_RequestPhoto (void) NULL,Box_NOT_CLOSABLE); /***** Write help message *****/ - sprintf (Gbl.Alert.Txt,"%s: %s
" - "%s: %u×%u %s", - Txt_Recommended_aspect_ratio, - Ctr_RECOMMENDED_ASPECT_RATIO, - Txt_Recommended_resolution, - Ctr_PHOTO_SAVED_MAX_WIDTH, - Ctr_PHOTO_SAVED_MAX_HEIGHT, - Txt_XxY_pixels_or_higher); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "%s: %s
" + "%s: %u×%u %s", + Txt_Recommended_aspect_ratio, + Ctr_RECOMMENDED_ASPECT_RATIO, + Txt_Recommended_resolution, + Ctr_PHOTO_SAVED_MAX_WIDTH, + Ctr_PHOTO_SAVED_MAX_HEIGHT, + Txt_XxY_pixels_or_higher); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Upload photo *****/ @@ -2428,9 +2442,10 @@ void Ctr_ReceivePhoto (void) ReturnCode = WEXITSTATUS(ReturnCode); if (ReturnCode != 0) { - sprintf (Gbl.Alert.Txt,"Image could not be processed successfully.
" - "Error code returned by the program of processing: %d", - ReturnCode); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Image could not be processed successfully.
" + "Error code returned by the program of processing: %d", + ReturnCode); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } @@ -2756,14 +2771,16 @@ static void Ctr_RecFormRequestOrCreateCtr (unsigned Status) /***** If name of centre was in database... *****/ if (Ctr_CheckIfCtrNameExistsInIns ("ShortName",Gbl.Ctrs.EditingCtr.ShrtName,-1L,Gbl.CurrentIns.Ins.InsCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_centre_X_already_exists, - Gbl.Ctrs.EditingCtr.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_centre_X_already_exists, + Gbl.Ctrs.EditingCtr.ShrtName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (Ctr_CheckIfCtrNameExistsInIns ("FullName",Gbl.Ctrs.EditingCtr.FullName,-1L,Gbl.CurrentIns.Ins.InsCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_centre_X_already_exists, - Gbl.Ctrs.EditingCtr.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_centre_X_already_exists, + Gbl.Ctrs.EditingCtr.FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // Add new centre to database @@ -2811,8 +2828,9 @@ static void Ctr_CreateCentre (unsigned Status) /***** Write message to show the change made and put button to go to centre created *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_Created_new_centre_X, - Gbl.Ctrs.EditingCtr.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_centre_X, + Gbl.Ctrs.EditingCtr.FullName); Ctr_ShowAlertAndButtonToGoToCtr (); } diff --git a/swad_changelog.h b/swad_changelog.h index 45896c1b..aabca7b8 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -355,10 +355,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.5.3 (2018-10-16)" +#define Log_PLATFORM_VERSION "SWAD 18.6 (2018-10-16)" #define CSS_FILE "swad18.4.css" #define JS_FILE "swad17.17.1.js" /* + Version 18.6: Oct 16, 2018 sprintf changed by snprintf in alerts. (235730 lines) Version 18.5.3: Oct 16, 2018 sprintf changed by safe string copy in some alerts. (235198 lines) Version 18.5.2: Oct 16, 2018 Code refactoring related to password change. (235170 lines) Version 18.5.1: Oct 16, 2018 Code refactoring related to edition of another user's account. (235212 lines) diff --git a/swad_chat.c b/swad_chat.c index 4dd18fec..5ebb84a8 100644 --- a/swad_chat.c +++ b/swad_chat.c @@ -80,9 +80,10 @@ void Cht_ShowChatRooms (void) extern const char *Txt_Unfortunately_Firefox_and_Chrome_no_longer_allow_Java_to_run_; /***** Help message about software needed to use the whiteboard/chat *****/ - sprintf (Gbl.Alert.Txt,Txt_To_use_chat_you_must_have_installed_the_software_X_and_add_Y_, - Cfg_JAVA_URL,Cfg_JAVA_NAME, - Cfg_PLATFORM_SERVER); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_To_use_chat_you_must_have_installed_the_software_X_and_add_Y_, + Cfg_JAVA_URL,Cfg_JAVA_NAME, + Cfg_PLATFORM_SERVER); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** List available chat rooms *****/ diff --git a/swad_country.c b/swad_country.c index ac26aed1..31ee973b 100644 --- a/swad_country.c +++ b/swad_country.c @@ -1709,8 +1709,9 @@ void Cty_RemoveCountry (void) Cty_FlushCacheCountryName (); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Country_X_removed, - Cty.Name[Gbl.Prefs.Language]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Country_X_removed, + Cty.Name[Gbl.Prefs.Language]); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1751,8 +1752,9 @@ void Cty_RenameCountry (void) /***** Check if new name is empty *****/ if (!NewCtyName[0]) { - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_country_X_empty, - Cty->Name[Language]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_country_X_empty, + Cty->Name[Language]); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -1763,8 +1765,9 @@ void Cty_RenameCountry (void) /***** If country was in database... *****/ if (Cty_CheckIfCountryNameExists (Language,NewCtyName,Cty->CtyCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_country_X_already_exists, - NewCtyName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_country_X_already_exists, + NewCtyName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -1774,8 +1777,9 @@ void Cty_RenameCountry (void) Cty_UpdateCtyNameDB (Cty->CtyCod,FieldName,NewCtyName); /* Write message to show the change made */ - sprintf (Gbl.Alert.Txt,Txt_The_country_X_has_been_renamed_as_Y, - Cty->Name[Language],NewCtyName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_country_X_has_been_renamed_as_Y, + Cty->Name[Language],NewCtyName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /* Update country name */ @@ -1785,8 +1789,9 @@ void Cty_RenameCountry (void) } else // The same name { - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_country_X_has_not_changed, - Cty->Name[Language]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_country_X_has_not_changed, + Cty->Name[Language]); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -1892,7 +1897,9 @@ void Cty_ChangeCtyWWW (void) Cns_MAX_BYTES_WWW); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X,NewWWW); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_web_address_is_X, + NewWWW); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show the form again *****/ @@ -2102,7 +2109,8 @@ void Cty_RecFormNewCountry (void) } else if (Cty_CheckIfNumericCountryCodeExists (Cty->CtyCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_numerical_code_X_already_exists, + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_numerical_code_X_already_exists, Cty->CtyCod); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); CreateCountry = false; @@ -2118,8 +2126,9 @@ void Cty_RecFormNewCountry (void) if (Cty->Alpha2[i] < 'A' || Cty->Alpha2[i] > 'Z') { - sprintf (Gbl.Alert.Txt,Txt_The_alphabetical_code_X_is_not_correct, - Cty->Alpha2); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_alphabetical_code_X_is_not_correct, + Cty->Alpha2); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); CreateCountry = false; } @@ -2127,8 +2136,9 @@ void Cty_RecFormNewCountry (void) { if (Cty_CheckIfAlpha2CountryCodeExists (Cty->Alpha2)) { - sprintf (Gbl.Alert.Txt,Txt_The_alphabetical_code_X_already_exists, - Cty->Alpha2); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_alphabetical_code_X_already_exists, + Cty->Alpha2); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); CreateCountry = false; } @@ -2147,8 +2157,9 @@ void Cty_RecFormNewCountry (void) /***** If name of country was in database... *****/ if (Cty_CheckIfCountryNameExists (Lan,Cty->Name[Lan],-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_country_X_already_exists, - Cty->Name[Lan]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_country_X_already_exists, + Cty->Name[Lan]); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); CreateCountry = false; break; @@ -2238,8 +2249,9 @@ static void Cty_CreateCountry (struct Country *Cty) DB_QueryINSERT (Query,"can not create country"); /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_country_X, - Cty->Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_country_X, + Cty->Name); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_course.c b/swad_course.c index 8ed88443..b4b712bf 100644 --- a/swad_course.c +++ b/swad_course.c @@ -1336,7 +1336,9 @@ void Crs_EditCourses (void) Deg_GetListDegsOfCurrentCtr (); /***** Start box *****/ - sprintf (Gbl.Alert.Txt,Txt_Courses_of_DEGREE_X,Gbl.CurrentDeg.Deg.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Courses_of_DEGREE_X, + Gbl.CurrentDeg.Deg.ShrtName); Box_StartBox (NULL,Gbl.Alert.Txt,Crs_PutIconToViewCourses, Hlp_DEGREE_Courses,Box_NOT_CLOSABLE); @@ -1864,15 +1866,17 @@ static void Crs_RecFormRequestOrCreateCrs (unsigned Status) Gbl.Degs.EditingCrs.DegCod,Gbl.Degs.EditingCrs.Year)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists, - Gbl.Degs.EditingCrs.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_course_X_already_exists, + Gbl.Degs.EditingCrs.ShrtName); } else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Degs.EditingCrs.FullName,-1L, Gbl.Degs.EditingCrs.DegCod,Gbl.Degs.EditingCrs.Year)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists, - Gbl.Degs.EditingCrs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_course_X_already_exists, + Gbl.Degs.EditingCrs.FullName); } else // Add new requested course to database Crs_CreateCourse (Status); @@ -1887,8 +1891,9 @@ static void Crs_RecFormRequestOrCreateCrs (unsigned Status) else // Year not valid { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_year_X_is_not_allowed, - Gbl.Degs.EditingCrs.Year); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_year_X_is_not_allowed, + Gbl.Degs.EditingCrs.Year); } } @@ -1941,8 +1946,9 @@ static void Crs_CreateCourse (unsigned Status) /***** Create success message *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_Created_new_course_X, - Gbl.Degs.EditingCrs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_course_X, + Gbl.Degs.EditingCrs.FullName); } /*****************************************************************************/ @@ -1973,8 +1979,9 @@ void Crs_RemoveCourse (void) Crs_RemoveCourseCompletely (Crs.CrsCod); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Course_X_removed, - Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Course_X_removed, + Crs.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } @@ -2295,12 +2302,14 @@ void Crs_ChangeInsCrsCodInConfig (void) { Crs_UpdateInstitutionalCrsCod (&Gbl.CurrentCrs.Crs,NewInstitutionalCrsCod); - sprintf (Gbl.Alert.Txt,Txt_The_institutional_code_of_the_course_X_has_changed_to_Y, - Gbl.CurrentCrs.Crs.ShrtName,NewInstitutionalCrsCod); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_institutional_code_of_the_course_X_has_changed_to_Y, + Gbl.CurrentCrs.Crs.ShrtName,NewInstitutionalCrsCod); } else // The same institutional code - sprintf (Gbl.Alert.Txt,Txt_The_institutional_code_of_the_course_X_has_not_changed, - Gbl.CurrentCrs.Crs.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_institutional_code_of_the_course_X_has_not_changed, + Gbl.CurrentCrs.Crs.ShrtName); } /*****************************************************************************/ @@ -2331,14 +2340,16 @@ void Crs_ChangeInsCrsCod (void) { Crs_UpdateInstitutionalCrsCod (&Gbl.Degs.EditingCrs,NewInstitutionalCrsCod); Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_institutional_code_of_the_course_X_has_changed_to_Y, - Gbl.Degs.EditingCrs.ShrtName,NewInstitutionalCrsCod); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_institutional_code_of_the_course_X_has_changed_to_Y, + Gbl.Degs.EditingCrs.ShrtName,NewInstitutionalCrsCod); } else // The same institutional code { Gbl.Alert.Type = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_institutional_code_of_the_course_X_has_not_changed, - Gbl.Degs.EditingCrs.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_institutional_code_of_the_course_X_has_not_changed, + Gbl.Degs.EditingCrs.ShrtName); } } else @@ -2374,15 +2385,19 @@ void Crs_ChangeCrsDegInConfig (void) NewDeg.DegCod,Gbl.CurrentCrs.Crs.Year)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z, - Txt_YEAR_OF_DEGREE[Gbl.CurrentCrs.Crs.Year],NewDeg.FullName,Gbl.CurrentCrs.Crs.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z, + Txt_YEAR_OF_DEGREE[Gbl.CurrentCrs.Crs.Year],NewDeg.FullName, + Gbl.CurrentCrs.Crs.ShrtName); } else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.CurrentCrs.Crs.FullName,-1L, NewDeg.DegCod,Gbl.CurrentCrs.Crs.Year)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z, - Txt_YEAR_OF_DEGREE[Gbl.CurrentCrs.Crs.Year],NewDeg.FullName,Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z, + Txt_YEAR_OF_DEGREE[Gbl.CurrentCrs.Crs.Year],NewDeg.FullName, + Gbl.CurrentCrs.Crs.FullName); } else // Update degree in database { @@ -2396,9 +2411,10 @@ void Crs_ChangeCrsDegInConfig (void) /***** Create message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_course_X_has_been_moved_to_the_degree_Y, - Gbl.CurrentCrs.Crs.FullName, - Gbl.CurrentDeg.Deg.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_course_X_has_been_moved_to_the_degree_Y, + Gbl.CurrentCrs.Crs.FullName, + Gbl.CurrentDeg.Deg.FullName); } } } @@ -2454,15 +2470,17 @@ void Crs_ChangeCrsYearInConfig (void) Gbl.CurrentCrs.Crs.DegCod,NewYear)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists_in_year_Y, - Gbl.CurrentCrs.Crs.ShrtName,Txt_YEAR_OF_DEGREE[NewYear]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_course_X_already_exists_in_year_Y, + Gbl.CurrentCrs.Crs.ShrtName,Txt_YEAR_OF_DEGREE[NewYear]); } else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.CurrentCrs.Crs.FullName,-1L, Gbl.CurrentCrs.Crs.DegCod,NewYear)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists_in_year_Y, - Gbl.CurrentCrs.Crs.FullName,Txt_YEAR_OF_DEGREE[NewYear]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_course_X_already_exists_in_year_Y, + Gbl.CurrentCrs.Crs.FullName,Txt_YEAR_OF_DEGREE[NewYear]); } else // Update year in database { @@ -2471,14 +2489,17 @@ void Crs_ChangeCrsYearInConfig (void) /***** Create message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_year_of_the_course_X_has_changed, - Gbl.CurrentCrs.Crs.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_year_of_the_course_X_has_changed, + Gbl.CurrentCrs.Crs.ShrtName); } } else // Year not valid { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_year_X_is_not_allowed,NewYear); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_year_X_is_not_allowed, + NewYear); } } @@ -2519,15 +2540,17 @@ void Crs_ChangeCrsYear (void) Gbl.Degs.EditingCrs.DegCod,NewYear)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists_in_year_Y, - Gbl.Degs.EditingCrs.ShrtName,Txt_YEAR_OF_DEGREE[NewYear]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_course_X_already_exists_in_year_Y, + Gbl.Degs.EditingCrs.ShrtName,Txt_YEAR_OF_DEGREE[NewYear]); } else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Degs.EditingCrs.FullName,-1L, Gbl.Degs.EditingCrs.DegCod,NewYear)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists_in_year_Y, - Gbl.Degs.EditingCrs.FullName,Txt_YEAR_OF_DEGREE[NewYear]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_course_X_already_exists_in_year_Y, + Gbl.Degs.EditingCrs.FullName,Txt_YEAR_OF_DEGREE[NewYear]); } else // Update year in database { @@ -2536,14 +2559,17 @@ void Crs_ChangeCrsYear (void) /***** Create message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_year_of_the_course_X_has_changed, - Gbl.Degs.EditingCrs.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_year_of_the_course_X_has_changed, + Gbl.Degs.EditingCrs.ShrtName); } } else // Year not valid { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_year_X_is_not_allowed,NewYear); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_year_X_is_not_allowed, + NewYear); } } else @@ -2665,8 +2691,9 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull if (!NewCrsName[0]) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_course_X_empty, - CurrentCrsName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_course_X_empty, + CurrentCrsName); } else { @@ -2678,8 +2705,9 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull Crs->DegCod,Crs->Year)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists, - NewCrsName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_course_X_already_exists, + NewCrsName); } else { @@ -2688,8 +2716,9 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull /* Create message to show the change made */ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_course_X_has_changed_to_Y, - CurrentCrsName,NewCrsName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_course_X_has_changed_to_Y, + CurrentCrsName,NewCrsName); /* Change current course name in order to display it properly */ Str_Copy (CurrentCrsName,NewCrsName, @@ -2699,8 +2728,9 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull else // The same name { Gbl.Alert.Type = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_course_X_has_not_changed, - CurrentCrsName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_course_X_has_not_changed, + CurrentCrsName); } } } @@ -2780,8 +2810,9 @@ void Crs_ChangeCrsStatus (void) /***** Create message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_status_of_the_course_X_has_changed, - Gbl.Degs.EditingCrs.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_status_of_the_course_X_has_changed, + Gbl.Degs.EditingCrs.ShrtName); } /*****************************************************************************/ @@ -3426,10 +3457,11 @@ void Crs_RemoveOldCrss (void) SecondsWithoutAccess); if ((NumCrss = DB_QuerySELECT (Query,&mysql_res,"can not get old users"))) { - sprintf (Gbl.Alert.Txt,Txt_Eliminating_X_courses_whithout_users_and_with_more_than_Y_months_without_access, - NumCrss, - MonthsWithoutAccess, - Cfg_PLATFORM_SHORT_NAME); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Eliminating_X_courses_whithout_users_and_with_more_than_Y_months_without_access, + NumCrss, + MonthsWithoutAccess, + Cfg_PLATFORM_SHORT_NAME); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Remove courses *****/ @@ -3448,7 +3480,8 @@ void Crs_RemoveOldCrss (void) } /***** Write end message *****/ - sprintf (Gbl.Alert.Txt,Txt_X_courses_have_been_eliminated, - NumCrssRemoved); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_courses_have_been_eliminated, + NumCrssRemoved); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_degree.c b/swad_degree.c index d812cae3..f32a6c2e 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -1153,8 +1153,9 @@ static void Deg_CreateDegree (unsigned Status) /***** Write message to show the change made and put button to go to degree created *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_Created_new_degree_X, - Gbl.Degs.EditingDeg.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_degree_X, + Gbl.Degs.EditingDeg.FullName); Deg_ShowAlertAndButtonToGoToDeg (); } @@ -1560,14 +1561,16 @@ static void Deg_RecFormRequestOrCreateDeg (unsigned Status) /***** If name of degree was in database... *****/ if (Deg_CheckIfDegNameExistsInCtr ("ShortName",Gbl.Degs.EditingDeg.ShrtName,-1L,Gbl.Degs.EditingDeg.CtrCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_degree_X_already_exists, - Gbl.Degs.EditingDeg.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_degree_X_already_exists, + Gbl.Degs.EditingDeg.ShrtName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (Deg_CheckIfDegNameExistsInCtr ("FullName",Gbl.Degs.EditingDeg.FullName,-1L,Gbl.Degs.EditingDeg.CtrCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_degree_X_already_exists, - Gbl.Degs.EditingDeg.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_degree_X_already_exists, + Gbl.Degs.EditingDeg.FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // Add new degree to database @@ -1608,8 +1611,9 @@ void Deg_RemoveDegree (void) Deg_RemoveDegreeCompletely (Deg.DegCod); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Degree_X_removed, - Deg.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Degree_X_removed, + Deg.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1966,8 +1970,9 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull if (!NewDegName[0]) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_degree_X_empty, - CurrentDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_degree_X_empty, + CurrentDegName); } else { @@ -1978,7 +1983,9 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull if (Deg_CheckIfDegNameExistsInCtr (ParamName,NewDegName,Deg->DegCod,Deg->CtrCod)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_degree_X_already_exists,NewDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_degree_X_already_exists, + NewDegName); } else { @@ -1987,8 +1994,9 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull /* Write message to show the change made */ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_degree_X_has_changed_to_Y, - CurrentDegName,NewDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_degree_X_has_changed_to_Y, + CurrentDegName,NewDegName); /* Change current degree name in order to display it properly */ Str_Copy (CurrentDegName,NewDegName, @@ -1998,8 +2006,9 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull else // The same name { Gbl.Alert.Type = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_degree_X_has_not_changed, - CurrentDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_degree_X_has_not_changed, + CurrentDegName); } } } @@ -2056,14 +2065,16 @@ void Deg_ChangeDegCtrInConfig (void) if (Deg_CheckIfDegNameExistsInCtr ("ShortName",Gbl.CurrentDeg.Deg.ShrtName,Gbl.CurrentDeg.Deg.DegCod,NewCtr.CtrCod)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_degree_X_already_exists, - Gbl.CurrentDeg.Deg.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_degree_X_already_exists, + Gbl.CurrentDeg.Deg.ShrtName); } else if (Deg_CheckIfDegNameExistsInCtr ("FullName",Gbl.CurrentDeg.Deg.FullName,Gbl.CurrentDeg.Deg.DegCod,NewCtr.CtrCod)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_degree_X_already_exists, - Gbl.CurrentDeg.Deg.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_degree_X_already_exists, + Gbl.CurrentDeg.Deg.FullName); } else { @@ -2077,9 +2088,10 @@ void Deg_ChangeDegCtrInConfig (void) /***** Create message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_degree_X_has_been_moved_to_the_centre_Y, - Gbl.CurrentDeg.Deg.FullName, - Gbl.CurrentCtr.Ctr.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_degree_X_has_been_moved_to_the_centre_Y, + Gbl.CurrentDeg.Deg.FullName, + Gbl.CurrentCtr.Ctr.FullName); } } } @@ -2142,7 +2154,9 @@ void Deg_ChangeDegWWW (void) /***** Write message to show the change made and put button to go to degree changed *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X,NewWWW); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_web_address_is_X, + NewWWW); Deg_ShowAlertAndButtonToGoToDeg (); } else @@ -2171,7 +2185,9 @@ void Deg_ChangeDegWWWInConfig (void) Cns_MAX_BYTES_WWW); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X,NewWWW); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_web_address_is_X, + NewWWW); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -2234,8 +2250,9 @@ void Deg_ChangeDegStatus (void) /***** Write message to show the change made and put button to go to degree changed *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_status_of_the_degree_X_has_changed, - Gbl.Degs.EditingDeg.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_status_of_the_degree_X_has_changed, + Gbl.Degs.EditingDeg.ShrtName); Deg_ShowAlertAndButtonToGoToDeg (); /***** Show the form again *****/ diff --git a/swad_degree_type.c b/swad_degree_type.c index 30d73fc4..caf6a85b 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -551,8 +551,9 @@ static void DT_CreateDegreeType (struct DegreeType *DegTyp) DB_QueryINSERT (Query,"can not create a new type of degree"); /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_type_of_degree_X, - DegTyp->DegTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_type_of_degree_X, + DegTyp->DegTypName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -720,8 +721,9 @@ void DT_RecFormNewDegreeType (void) /***** If name of degree type was in database... *****/ if (DT_CheckIfDegreeTypeNameExists (DegTyp->DegTypName,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_type_of_degree_X_already_exists, - DegTyp->DegTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_degree_X_already_exists, + DegTyp->DegTypName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // Add new degree type to database @@ -760,8 +762,9 @@ void DT_RemoveDegreeType (void) DT_RemoveDegreeTypeCompletely (DegTyp.DegTypCod); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Type_of_degree_X_removed, - DegTyp.DegTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Type_of_degree_X_removed, + DegTyp.DegTypName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -934,8 +937,9 @@ void DT_RenameDegreeType (void) /***** Check if new name is empty *****/ if (!NewNameDegTyp[0]) { - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_type_of_degree_X_empty, - DegTyp->DegTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_type_of_degree_X_empty, + DegTyp->DegTypName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -946,8 +950,9 @@ void DT_RenameDegreeType (void) /***** If degree type was in database... *****/ if (DT_CheckIfDegreeTypeNameExists (NewNameDegTyp,DegTyp->DegTypCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_type_of_degree_X_already_exists, - NewNameDegTyp); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_degree_X_already_exists, + NewNameDegTyp); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -959,15 +964,17 @@ void DT_RenameDegreeType (void) DB_QueryUPDATE (Query,"can not update the type of a degree"); /* Write message to show the change made */ - sprintf (Gbl.Alert.Txt,Txt_The_type_of_degree_X_has_been_renamed_as_Y, - DegTyp->DegTypName,NewNameDegTyp); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_degree_X_has_been_renamed_as_Y, + DegTyp->DegTypName,NewNameDegTyp); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } else // The same name { - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_type_of_degree_X_has_not_changed, - NewNameDegTyp); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_type_of_degree_X_has_not_changed, + NewNameDegTyp); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -1021,8 +1028,9 @@ void DT_ChangeDegreeType (void) /***** Write message to show the change made and put button to go to degree changed *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_type_of_degree_of_the_degree_X_has_changed, - Gbl.Degs.EditingDeg.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_degree_of_the_degree_X_has_changed, + Gbl.Degs.EditingDeg.FullName); Deg_ShowAlertAndButtonToGoToDeg (); /***** Show the form again *****/ diff --git a/swad_department.c b/swad_department.c index f11e8471..db73b5d7 100644 --- a/swad_department.c +++ b/swad_department.c @@ -628,7 +628,9 @@ void Dpt_RemoveDepartment (void) DB_QueryDELETE (Query,"can not remove a department"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Department_X_removed,Dpt.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Department_X_removed, + Dpt.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -732,8 +734,9 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Check if new name is empty *****/ if (!NewDptName[0]) { - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_department_X_empty, - CurrentDptName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_department_X_empty, + CurrentDptName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -744,8 +747,9 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName) /***** If degree was in database... *****/ if (Dpt_CheckIfDepartmentNameExists (ParamName,NewDptName,Dpt->DptCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_department_X_already_exists, - NewDptName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_department_X_already_exists, + NewDptName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -754,15 +758,17 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName) Dpt_UpdateDegNameDB (Dpt->DptCod,FieldName,NewDptName); /* Write message to show the change made */ - sprintf (Gbl.Alert.Txt,Txt_The_department_X_has_been_renamed_as_Y, - CurrentDptName,NewDptName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_department_X_has_been_renamed_as_Y, + CurrentDptName,NewDptName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } else // The same name { - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_department_X_has_not_changed, - CurrentDptName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_department_X_has_not_changed, + CurrentDptName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -832,8 +838,9 @@ void Dpt_ChangeDptWWW (void) DB_QueryUPDATE (Query,"can not update the web of a department"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X, - NewWWW); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_web_address_is_X, + NewWWW); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -1021,14 +1028,16 @@ void Dpt_RecFormNewDpt (void) /***** If name of department was in database... *****/ if (Dpt_CheckIfDepartmentNameExists ("ShortName",Dpt->ShrtName,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_department_X_already_exists, - Dpt->ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_department_X_already_exists, + Dpt->ShrtName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (Dpt_CheckIfDepartmentNameExists ("FullName",Dpt->FullName,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_department_X_already_exists, - Dpt->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_department_X_already_exists, + Dpt->FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // Add new department to database @@ -1065,8 +1074,9 @@ static void Dpt_CreateDepartment (struct Department *Dpt) DB_QueryINSERT (Query,"can not create a new department"); /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_department_X, - Dpt->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_department_X, + Dpt->FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_enrolment.c b/swad_enrolment.c index 4e8c5d7b..c482e14f 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -360,12 +360,13 @@ void Enr_WriteFormToReqAnotherUsrID (Act_Action_t NextAction,void (*FuncParams) Act_StartForm (NextAction); if (FuncParams) FuncParams (); - fprintf (Gbl.F.Out,"" + "", The_ClassForm[Gbl.Prefs.Theme], Txt_nick_email_or_ID, Cns_MAX_CHARS_EMAIL_ADDRESS); @@ -394,9 +395,10 @@ void Enr_ReqAcceptRegisterInCrs (void) Hlp_USERS_SignUp_confirm_enrolment,Box_NOT_CLOSABLE); /***** Show message *****/ - sprintf (Gbl.Alert.Txt,Txt_A_teacher_or_administrator_has_enroled_you_as_X_into_the_course_Y, - Txt_ROLES_SINGUL_abc[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role][Gbl.Usrs.Me.UsrDat.Sex], - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_A_teacher_or_administrator_has_enroled_you_as_X_into_the_course_Y, + Txt_ROLES_SINGUL_abc[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role][Gbl.Usrs.Me.UsrDat.Sex], + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Send button to accept register in the current course *****/ @@ -772,8 +774,9 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role) else { /* Write help message */ - sprintf (Gbl.Alert.Txt,Txt_No_groups_have_been_created_in_the_course_X_Therefore_, - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_No_groups_have_been_created_in_the_course_X_Therefore_, + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -895,10 +898,11 @@ void Enr_RemoveOldUsrs (void) (unsigned long) SecondsWithoutAccess); if ((NumUsrs = DB_QuerySELECT (Query,&mysql_res,"can not get old users"))) { - sprintf (Gbl.Alert.Txt,Txt_Eliminating_X_users_who_were_not_enroled_in_any_course_and_with_more_than_Y_months_without_access_to_Z, - NumUsrs, - MonthsWithoutAccess, - Cfg_PLATFORM_SHORT_NAME); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Eliminating_X_users_who_were_not_enroled_in_any_course_and_with_more_than_Y_months_without_access_to_Z, + NumUsrs, + MonthsWithoutAccess, + Cfg_PLATFORM_SHORT_NAME); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Initialize structure with user's data *****/ @@ -929,8 +933,9 @@ void Enr_RemoveOldUsrs (void) } /***** Write end message *****/ - sprintf (Gbl.Alert.Txt,Txt_X_users_have_been_eliminated, - NumUsrsEliminated); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_users_have_been_eliminated, + NumUsrsEliminated); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1027,15 +1032,10 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) if (Gbl.CurrentCrs.Crs.CrsCod > 0 && Gbl.Usrs.Me.Role.Logged >= Rol_STD) { - sprintf (Gbl.Alert.Txt,UsrBelongsToCrs ? (ItsMe ? Txt_Modify_me_in_the_course_X : - Txt_Modify_user_in_the_course_X) : - (ItsMe ? Txt_Register_me_in_X : - Txt_Register_USER_in_the_course_X), - Gbl.CurrentCrs.Crs.ShrtName); fprintf (Gbl.F.Out,"
  • " - "" - "
  • ", - Gbl.Alert.Txt); + "" + ""); NumOptionsShown++; } @@ -1060,12 +1066,10 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) if (!UsrIsDegAdmin && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) { - sprintf (Gbl.Alert.Txt,Txt_Register_USER_as_an_administrator_of_the_degree_X, - Gbl.CurrentDeg.Deg.ShrtName); fprintf (Gbl.F.Out,"
  • " - "" - "
  • ", - Gbl.Alert.Txt); + "" + ""); NumOptionsShown++; } @@ -1085,12 +1092,10 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) if (!UsrIsCtrAdmin && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) { - sprintf (Gbl.Alert.Txt,Txt_Register_USER_as_an_administrator_of_the_centre_X, - Gbl.CurrentCtr.Ctr.ShrtName); fprintf (Gbl.F.Out,"
  • " - "" - "
  • ", - Gbl.Alert.Txt); + "" + ""); NumOptionsShown++; } @@ -1111,12 +1119,10 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) if (!UsrIsInsAdmin && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) { - sprintf (Gbl.Alert.Txt,Txt_Register_USER_as_an_administrator_of_the_institution_X, - Gbl.CurrentIns.Ins.ShrtName); fprintf (Gbl.F.Out,"
  • " - "" - "
  • ", - Gbl.Alert.Txt); + "" + ""); NumOptionsShown++; } @@ -1137,9 +1145,9 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) if (!ItsMe && Gbl.Usrs.Me.Role.Logged >= Rol_TCH) { fprintf (Gbl.F.Out,"
  • " - "
  • ", + (unsigned) Enr_REPORT_USR_AS_POSSIBLE_DUPLICATE, Txt_Report_possible_duplicate_user); NumOptionsShown++; @@ -1158,14 +1168,10 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) /***** Remove user from the course *****/ if (UsrBelongsToCrs) { - sprintf (Gbl.Alert.Txt, - ItsMe ? Txt_Remove_me_from_THE_COURSE_X : - Txt_Remove_USER_from_THE_COURSE_X, - Gbl.CurrentCrs.Crs.ShrtName); fprintf (Gbl.F.Out,"
  • " - "" - "
  • ", - Gbl.Alert.Txt); + "" + ""); NumOptionsShown++; } @@ -1190,14 +1200,10 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) if (UsrIsDegAdmin && (ItsMe || Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM)) { - sprintf (Gbl.Alert.Txt, - ItsMe ? Txt_Remove_me_as_an_administrator_of_the_degree_X : - Txt_Remove_USER_as_an_administrator_of_the_degree_X, - Gbl.CurrentDeg.Deg.ShrtName); fprintf (Gbl.F.Out,"
  • " - "" - "
  • ", - Gbl.Alert.Txt); + "" + ""); NumOptionsShown++; } @@ -1217,14 +1227,10 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) if (UsrIsCtrAdmin && (ItsMe || Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM)) { - sprintf (Gbl.Alert.Txt, - ItsMe ? Txt_Remove_me_as_an_administrator_of_the_centre_X : - Txt_Remove_USER_as_an_administrator_of_the_centre_X, - Gbl.CurrentCtr.Ctr.ShrtName); fprintf (Gbl.F.Out,"
  • " - "" - "
  • ", - Gbl.Alert.Txt); + "" + ""); NumOptionsShown++; } @@ -1245,14 +1255,10 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) if (UsrIsInsAdmin && (ItsMe || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) { - sprintf (Gbl.Alert.Txt, - ItsMe ? Txt_Remove_me_as_an_administrator_of_the_institution_X : - Txt_Remove_USER_as_an_administrator_of_the_institution_X, - Gbl.CurrentIns.Ins.ShrtName); fprintf (Gbl.F.Out,"
  • " - "" - "
  • ", - Gbl.Alert.Txt); + "" + ""); NumOptionsShown++; } @@ -1273,16 +1283,18 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Other.UsrDat.UsrCod)) { fprintf (Gbl.F.Out,"
  • " - "
  • ", + (unsigned) Enr_ELIMINATE_ONE_USR_FROM_PLATFORM, ItsMe ? Txt_Eliminate_my_user_account : Txt_Eliminate_user_account); @@ -1316,52 +1328,62 @@ static void Enr_PutActionsRegRemSeveralUsrs (void) /***** Register / remove users listed or not listed *****/ if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected fprintf (Gbl.F.Out,"
  • " - "
  • " "
  • " - "
  • " "
  • " - "
  • " "
  • " - "
  • ", (unsigned) Enr_REGISTER_SPECIFIED_USRS_IN_CRS, + (unsigned) Enr_REGISTER_SPECIFIED_USRS_IN_CRS, + (unsigned) Enr_REGISTER_SPECIFIED_USRS_IN_CRS, Txt_Register_the_users_indicated_in_step_1, (unsigned) Enr_REMOVE_SPECIFIED_USRS_FROM_CRS, + (unsigned) Enr_REMOVE_SPECIFIED_USRS_FROM_CRS, + (unsigned) Enr_REMOVE_SPECIFIED_USRS_FROM_CRS, Txt_Remove_the_users_indicated_in_step_1, (unsigned) Enr_REMOVE_NOT_SPECIFIED_USRS_FROM_CRS, + (unsigned) Enr_REMOVE_NOT_SPECIFIED_USRS_FROM_CRS, + (unsigned) Enr_REMOVE_NOT_SPECIFIED_USRS_FROM_CRS, Txt_Remove_the_users_not_indicated_in_step_1, (unsigned) Enr_UPDATE_USRS_IN_CRS, + (unsigned) Enr_UPDATE_USRS_IN_CRS, + (unsigned) Enr_UPDATE_USRS_IN_CRS, Txt_Register_the_users_indicated_in_step_1_and_remove_the_users_not_indicated); /***** Only for superusers *****/ if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) fprintf (Gbl.F.Out,"
  • " - "
  • ", (unsigned) Enr_ELIMINATE_USRS_FROM_PLATFORM, + (unsigned) Enr_ELIMINATE_USRS_FROM_PLATFORM, + (unsigned) Enr_ELIMINATE_USRS_FROM_PLATFORM, Txt_Eliminate_from_the_platform_the_users_indicated_in_step_1); /***** End list of options *****/ @@ -1757,8 +1779,9 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role) Ale_ShowAlert (Ale_SUCCESS,Txt_One_user_has_been_eliminated); break; default: - sprintf (Gbl.Alert.Txt,Txt_X_users_have_been_eliminated, - NumUsrsEliminated); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_users_have_been_eliminated, + NumUsrsEliminated); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); break; } @@ -1772,8 +1795,9 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role) Ale_ShowAlert (Ale_SUCCESS,Txt_One_user_has_been_removed); break; default: - sprintf (Gbl.Alert.Txt,Txt_X_users_have_been_removed, - NumUsrsRemoved); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_users_have_been_removed, + NumUsrsRemoved); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); break; } @@ -1788,8 +1812,9 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role) Ale_ShowAlert (Ale_SUCCESS,Txt_One_user_has_been_enroled); break; default: - sprintf (Gbl.Alert.Txt,Txt_X_users_have_been_enroled_including_possible_repetitions, - NumUsrsRegistered); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_users_have_been_enroled_including_possible_repetitions, + NumUsrsRegistered); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); break; } @@ -1886,9 +1911,10 @@ void Enr_AskRemAllStdsThisCrs (void) { /***** Show question and button to remove students *****/ /* Start alert */ - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_X_students_from_the_course_Y_, - Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD], - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_X_students_from_the_course_Y_, + Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD], + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt); /* Show form to request confirmation */ @@ -1922,8 +1948,9 @@ void Enr_RemAllStdsThisCrs (void) { if ((NumStdsInCrs = Enr_RemAllStdsInCrs (&Gbl.CurrentCrs.Crs))) { - sprintf (Gbl.Alert.Txt,Txt_The_X_students_who_belonged_to_the_course_Y_have_been_removed_from_it, - NumStdsInCrs,Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_X_students_who_belonged_to_the_course_Y_have_been_removed_from_it, + NumStdsInCrs,Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else // NumStdsInCrs == 0 @@ -1975,9 +2002,10 @@ void Enr_ReqSignUpInCrs (void) /***** Check if I already belong to course *****/ if (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role >= Rol_STD) { - sprintf (Gbl.Alert.Txt,Txt_You_were_already_enroled_as_X_in_the_course_Y, - Txt_ROLES_SINGUL_abc[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role][Gbl.Usrs.Me.UsrDat.Sex], - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_were_already_enroled_as_X_in_the_course_Y, + Txt_ROLES_SINGUL_abc[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role][Gbl.Usrs.Me.UsrDat.Sex], + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (Gbl.Usrs.Me.Role.Logged == Rol_GST || @@ -2006,9 +2034,10 @@ void Enr_SignUpInCrs (void) /***** Check if I already belong to course *****/ if (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role >= Rol_STD) { - sprintf (Gbl.Alert.Txt,Txt_You_were_already_enroled_as_X_in_the_course_Y, - Txt_ROLES_SINGUL_abc[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role][Gbl.Usrs.Me.UsrDat.Sex], - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_were_already_enroled_as_X_in_the_course_Y, + Txt_ROLES_SINGUL_abc[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role][Gbl.Usrs.Me.UsrDat.Sex], + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -2064,9 +2093,10 @@ void Enr_SignUpInCrs (void) } /***** Show confirmation message *****/ - sprintf (Gbl.Alert.Txt,Txt_Your_request_for_enrolment_as_X_in_the_course_Y_has_been_accepted_for_processing, - Txt_ROLES_SINGUL_abc[RoleFromForm][Gbl.Usrs.Me.UsrDat.Sex], - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Your_request_for_enrolment_as_X_in_the_course_Y_has_been_accepted_for_processing, + Txt_ROLES_SINGUL_abc[RoleFromForm][Gbl.Usrs.Me.UsrDat.Sex], + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Notify teachers or admins by email about the new enrolment request *****/ @@ -2159,8 +2189,9 @@ void Enr_AskIfRejectSignUp (void) if (Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat)) { /* User already belongs to this course */ - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_enroled_in_the_course_Y, - Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_is_already_enroled_in_the_course_Y, + Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); Rec_ShowSharedRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat); @@ -2176,10 +2207,11 @@ void Enr_AskIfRejectSignUp (void) { /***** Show question and button to reject user's enrolment request *****/ /* Start alert */ - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_reject_the_enrolment_request_, - Gbl.Usrs.Other.UsrDat.FullName, - Txt_ROLES_SINGUL_abc[Role][Gbl.Usrs.Other.UsrDat.Sex], - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_reject_the_enrolment_request_, + Gbl.Usrs.Other.UsrDat.FullName, + Txt_ROLES_SINGUL_abc[Role][Gbl.Usrs.Other.UsrDat.Sex], + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt); /* Show user's record */ @@ -2216,8 +2248,9 @@ void Enr_RejectSignUp (void) if (Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat)) { /* User already belongs to this course */ - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_enroled_in_the_course_Y, - Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_is_already_enroled_in_the_course_Y, + Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); Rec_ShowSharedRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat); } @@ -2226,8 +2259,9 @@ void Enr_RejectSignUp (void) Enr_RemoveEnrolmentRequest (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Other.UsrDat.UsrCod); /* Confirmation message */ - sprintf (Gbl.Alert.Txt,Txt_Enrolment_of_X_rejected, - Gbl.Usrs.Other.UsrDat.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Enrolment_of_X_rejected, + Gbl.Usrs.Other.UsrDat.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -3254,8 +3288,9 @@ static void Enr_AskIfRegRemUsr (struct ListUsrCods *ListUsrCods,Rol_Role_t Role) /***** Warning if more than one user found *****/ if (ListUsrCods->NumUsrs > 1) { - sprintf (Gbl.Alert.Txt,Txt_There_are_X_users_with_the_ID_Y, - ListUsrCods->NumUsrs,Gbl.Usrs.Other.UsrDat.UsrIDNickOrEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_are_X_users_with_the_ID_Y, + ListUsrCods->NumUsrs,Gbl.Usrs.Other.UsrDat.UsrIDNickOrEmail); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } @@ -3275,19 +3310,23 @@ static void Enr_AskIfRegRemUsr (struct ListUsrCods *ListUsrCods,Rol_Role_t Role) { Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat); if (Gbl.Usrs.Other.UsrDat.Accepted) - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_enroled_in_the_course_Y, - Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_is_already_enroled_in_the_course_Y, + Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); else // Enrolment not yet accepted - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_in_the_course_Y_but_has_not_yet_accepted_the_enrolment, - Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_is_already_in_the_course_Y_but_has_not_yet_accepted_the_enrolment, + Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); Enr_ShowFormToEditOtherUsr (); } else // User does not belong to the current course { - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_already_exists_in_Y_but_is_not_yet_enroled_in_the_course_Z, - Gbl.Usrs.Other.UsrDat.FullName,Cfg_PLATFORM_SHORT_NAME,Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_already_exists_in_Y_but_is_not_yet_enroled_in_the_course_Z, + Gbl.Usrs.Other.UsrDat.FullName, + Cfg_PLATFORM_SHORT_NAME,Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); Enr_ShowFormToEditOtherUsr (); @@ -3295,8 +3334,9 @@ static void Enr_AskIfRegRemUsr (struct ListUsrCods *ListUsrCods,Rol_Role_t Role) } else // No course selected { - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_already_exists_in_Y, - Gbl.Usrs.Other.UsrDat.FullName,Cfg_PLATFORM_SHORT_NAME); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_already_exists_in_Y, + Gbl.Usrs.Other.UsrDat.FullName,Cfg_PLATFORM_SHORT_NAME); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); Enr_ShowFormToEditOtherUsr (); @@ -3318,16 +3358,18 @@ static void Enr_AskIfRegRemUsr (struct ListUsrCods *ListUsrCods,Rol_Role_t Role) if (NewUsrIDValid) { /***** Show form to enter the data of a new user *****/ - sprintf (Gbl.Alert.Txt,Txt_The_user_is_new_not_yet_in_X, - Cfg_PLATFORM_SHORT_NAME); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_user_is_new_not_yet_in_X, + Cfg_PLATFORM_SHORT_NAME); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); Rec_ShowFormOtherNewSharedRecord (&Gbl.Usrs.Other.UsrDat,Role); } else // User's ID is not valid { /* Write message and request a new user's ID */ - sprintf (Gbl.Alert.Txt,Txt_If_this_is_a_new_user_in_X_you_should_indicate_her_his_ID, - Cfg_PLATFORM_SHORT_NAME); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_If_this_is_a_new_user_in_X_you_should_indicate_her_his_ID, + Cfg_PLATFORM_SHORT_NAME); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); Enr_ReqRegRemUsr (Role); } @@ -3420,8 +3462,9 @@ static void Enr_RegisterAdmin (struct UsrData *UsrDat,Sco_Scope_t Scope,long Cod /***** Check if user was and administrator of current institution/centre/degree *****/ if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,Scope,Cod)) - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_an_administrator_of_Y, - UsrDat->FullName,InsCtrDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_is_already_an_administrator_of_Y, + UsrDat->FullName,InsCtrDegName); else // User was not administrator of current institution/centre/degree { /***** Insert or replace administrator in current institution/centre/degree *****/ @@ -3432,8 +3475,9 @@ static void Enr_RegisterAdmin (struct UsrData *UsrDat,Sco_Scope_t Scope,long Cod UsrDat->UsrCod,Sco_ScopeDB[Scope],Cod); DB_QueryREPLACE (Query,"can not create administrator"); - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y, - UsrDat->FullName,InsCtrDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y, + UsrDat->FullName,InsCtrDegName); } Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -3632,8 +3676,9 @@ static void Enr_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,Sco_Scope_t } else // The other user is not an administrator of current institution { - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_not_an_administrator_of_Y, - Gbl.Usrs.Other.UsrDat.FullName,InsCtrDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_is_not_an_administrator_of_Y, + Gbl.Usrs.Other.UsrDat.FullName,InsCtrDegName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } } @@ -3680,8 +3725,9 @@ static void Enr_ReqAddAdm (Sco_Scope_t Scope,long Cod,const char *InsCtrDegName) { if (Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Scope,Cod)) // User is already an administrator of current institution/centre/degree { - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_already_an_administrator_of_Y, - Gbl.Usrs.Other.UsrDat.FullName,InsCtrDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_is_already_an_administrator_of_Y, + Gbl.Usrs.Other.UsrDat.FullName,InsCtrDegName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); Rec_ShowSharedRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat); } @@ -3689,8 +3735,9 @@ static void Enr_ReqAddAdm (Sco_Scope_t Scope,long Cod,const char *InsCtrDegName) { /***** Show question and button to register user as administrator *****/ /* Start alert */ - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_register_the_following_user_as_an_administrator_of_X, - InsCtrDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_register_the_following_user_as_an_administrator_of_X, + InsCtrDegName); Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt); /* Show user's record */ @@ -3729,8 +3776,9 @@ void Enr_AcceptRegisterMeInCrs (void) Gbl.Usrs.Me.UsrDat.UsrCod); /***** Confirmation message *****/ - sprintf (Gbl.Alert.Txt,Txt_You_have_confirmed_your_enrolment_in_the_course_X, - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_have_confirmed_your_enrolment_in_the_course_X, + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -3781,10 +3829,12 @@ void Enr_CreateNewUsr1 (void) /* Success message */ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_role_of_THE_USER_X_in_the_course_Y_has_changed_from_A_to_B, - Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName, - Txt_ROLES_SINGUL_abc[OldRole][Gbl.Usrs.Other.UsrDat.Sex], - Txt_ROLES_SINGUL_abc[NewRole][Gbl.Usrs.Other.UsrDat.Sex]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_role_of_THE_USER_X_in_the_course_Y_has_changed_from_A_to_B, + Gbl.Usrs.Other.UsrDat.FullName, + Gbl.CurrentCrs.Crs.FullName, + Txt_ROLES_SINGUL_abc[OldRole][Gbl.Usrs.Other.UsrDat.Sex], + Txt_ROLES_SINGUL_abc[NewRole][Gbl.Usrs.Other.UsrDat.Sex]); } } else // User does not belong to current course @@ -3795,8 +3845,10 @@ void Enr_CreateNewUsr1 (void) /* Success message */ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_enroled_in_the_course_Y, - Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_enroled_in_the_course_Y, + Gbl.Usrs.Other.UsrDat.FullName, + Gbl.CurrentCrs.Crs.FullName); } /***** Change user's groups *****/ @@ -3829,8 +3881,9 @@ void Enr_CreateNewUsr1 (void) { /***** Error message *****/ Gbl.Alert.Type = Ale_ERROR; - sprintf (Gbl.Alert.Txt,Txt_The_ID_X_is_not_valid, - Gbl.Usrs.Other.UsrDat.IDs.List[0].ID); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_ID_X_is_not_valid, + Gbl.Usrs.Other.UsrDat.IDs.List[0].ID); } } @@ -3904,10 +3957,12 @@ void Enr_ModifyUsr1 (void) /* Set success message */ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_role_of_THE_USER_X_in_the_course_Y_has_changed_from_A_to_B, - Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName, - Txt_ROLES_SINGUL_abc[OldRole][Gbl.Usrs.Other.UsrDat.Sex], - Txt_ROLES_SINGUL_abc[NewRole][Gbl.Usrs.Other.UsrDat.Sex]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_role_of_THE_USER_X_in_the_course_Y_has_changed_from_A_to_B, + Gbl.Usrs.Other.UsrDat.FullName, + Gbl.CurrentCrs.Crs.FullName, + Txt_ROLES_SINGUL_abc[OldRole][Gbl.Usrs.Other.UsrDat.Sex], + Txt_ROLES_SINGUL_abc[NewRole][Gbl.Usrs.Other.UsrDat.Sex]); } } else // User does not belong to current course @@ -3918,8 +3973,9 @@ void Enr_ModifyUsr1 (void) /* Set success message */ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_enroled_in_the_course_Y, - Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_enroled_in_the_course_Y, + Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); } /***** Change user's groups *****/ @@ -4097,10 +4153,10 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat) /***** Show question and button to remove user as administrator *****/ /* Start alert */ - sprintf (Gbl.Alert.Txt, - ItsMe ? Txt_Do_you_really_want_to_be_removed_from_the_course_X : - Txt_Do_you_really_want_to_remove_the_following_user_from_the_course_X, - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + ItsMe ? Txt_Do_you_really_want_to_be_removed_from_the_course_X : + Txt_Do_you_really_want_to_remove_the_following_user_from_the_course_X, + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt); /* Show user's record */ @@ -4216,8 +4272,9 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course * if (QuietOrVerbose == Cns_VERBOSE) { Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_removed_from_the_course_Y, - UsrDat->FullName,Crs->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_removed_from_the_course_Y, + UsrDat->FullName,Crs->FullName); } } else // User does not belong to course @@ -4255,10 +4312,10 @@ static void Enr_AskIfRemAdm (bool ItsMe,Sco_Scope_t Scope, { /***** Show question and button to remove user as administrator *****/ /* Start alert */ - sprintf (Gbl.Alert.Txt, - ItsMe ? Txt_Do_you_really_want_to_be_removed_as_an_administrator_of_X : - Txt_Do_you_really_want_to_remove_the_following_user_as_an_administrator_of_X, - InsCtrDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + ItsMe ? Txt_Do_you_really_want_to_be_removed_as_an_administrator_of_X : + Txt_Do_you_really_want_to_remove_the_following_user_as_an_administrator_of_X, + InsCtrDegName); Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt); /* Show user's record */ @@ -4295,14 +4352,16 @@ static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Sco_Scope_t Scope, UsrDat->UsrCod,Sco_ScopeDB[Scope],Cod); DB_QueryDELETE (Query,"can not remove an administrator"); - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_removed_as_administrator_of_Y, - UsrDat->FullName,InsCtrDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_removed_as_administrator_of_Y, + UsrDat->FullName,InsCtrDegName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else // User is not an administrator of the current institution/centre/degree { - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_not_an_administrator_of_Y, - UsrDat->FullName,InsCtrDegName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_is_not_an_administrator_of_Y, + UsrDat->FullName,InsCtrDegName); Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt); } } diff --git a/swad_exam.c b/swad_exam.c index 0ec3e722..0dbdee4b 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -658,8 +658,9 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx /***** The result of the query may be empty *****/ if (!NumExaAnns) { - sprintf (Gbl.Alert.Txt,Txt_No_announcements_of_exams_of_X, - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_No_announcements_of_exams_of_X, + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } diff --git a/swad_file.c b/swad_file.c index aa1db9b0..eacf0b57 100644 --- a/swad_file.c +++ b/swad_file.c @@ -141,11 +141,13 @@ bool Fil_ReadStdinIntoTmpFile (void) { Fil_EndOfReadingStdin (); // If stdin were not fully read, there will be problems with buffers if (FileIsTooBig) - sprintf (Gbl.Alert.Txt,Txt_UPLOAD_FILE_File_too_large_maximum_X_MiB_NO_HTML, - (unsigned long) (Fil_MAX_FILE_SIZE / (1024ULL * 1024ULL))); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_UPLOAD_FILE_File_too_large_maximum_X_MiB_NO_HTML, + (unsigned long) (Fil_MAX_FILE_SIZE / (1024ULL * 1024ULL))); else - sprintf (Gbl.Alert.Txt,Txt_UPLOAD_FILE_Upload_time_too_long_maximum_X_minutes_NO_HTML, - (unsigned long) (Cfg_TIME_TO_ABORT_FILE_UPLOAD / 60UL)); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_UPLOAD_FILE_Upload_time_too_long_maximum_X_minutes_NO_HTML, + (unsigned long) (Cfg_TIME_TO_ABORT_FILE_UPLOAD / 60UL)); /* Don't write HTML at all */ Gbl.Layout.HTMLStartWritten = @@ -341,7 +343,9 @@ void Fil_CreateUpdateFile (const char CurrentName[PATH_MAX + 1], /* Open the new file */ if ((*NewFile = fopen (NewName,"wb")) == NULL) { - sprintf (Gbl.Alert.Txt,"Can not create file %s.",NewName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Can not create file %s.", + NewName); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } } @@ -358,14 +362,16 @@ void Fil_CloseUpdateFile (const char *CurrentName,const char *OldName,const char /* Rename the old file and the new file */ if (rename (CurrentName,OldName)) // mv CurrentName OldName Ej: mv file.html file.old { - sprintf (Gbl.Alert.Txt,"Can not rename the file %s as %s.", - CurrentName,OldName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Can not rename the file %s as %s.", + CurrentName,OldName); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } if (rename (NewName,CurrentName)) // mv NewName CurrentName Ej: mv file.new file.html { - sprintf (Gbl.Alert.Txt,"Can not rename the file %s as %s.", - NewName,CurrentName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Can not rename the file %s as %s.", + NewName,CurrentName); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } } @@ -386,12 +392,14 @@ bool Fil_RenameFileOrDir (const char *PathOld,const char *PathNew) { case ENOTEMPTY: case EEXIST: - sprintf (Gbl.Alert.Txt,Txt_There_is_already_a_non_empty_folder_named_X, - PathNew); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_is_already_a_non_empty_folder_named_X, + PathNew); break; case ENOTDIR: - sprintf (Gbl.Alert.Txt,Txt_There_is_already_a_file_named_X, - PathNew); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_is_already_a_file_named_X, + PathNew); break; case EACCES: Lay_ShowErrorAndExit ("Write is forbidden."); @@ -426,7 +434,9 @@ void Fil_CreateDirIfNotExists (const char *Path) if (!Fil_CheckIfPathExists (Path)) if (mkdir (Path,(mode_t) 0xFFF) != 0) { - sprintf (Gbl.Alert.Txt,"Can not create folder %s.",Path); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Can not create folder %s.", + Path); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } } @@ -485,7 +495,9 @@ void Fil_RemoveTree (const char *Path) Error = true; if (Error) { - sprintf (Gbl.Alert.Txt,"Can not remove folder %s.",Path); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Can not remove folder %s.", + Path); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } } diff --git a/swad_file_browser.c b/swad_file_browser.c index c9cd2dad..12c02d59 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -3124,12 +3124,13 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con } /***** Summary message *****/ - sprintf (Gbl.Alert.Txt,"%s: %u
    " - "%s: %u
    " - "%s: %u.", - Txt_Users,NumUsrs, - Txt_Folders_renamed,NumUsrsSuccess, - Txt_Folders_not_renamed,NumUsrsError); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "%s: %u
    " + "%s: %u
    " + "%s: %u.", + Txt_Users,NumUsrs, + Txt_Folders_renamed,NumUsrsSuccess, + Txt_Folders_not_renamed,NumUsrsError); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } else @@ -3816,9 +3817,10 @@ void Brw_ShowAgainFileBrowserOrWorks (void) } /***** Legal notice *****/ - sprintf (Gbl.Alert.Txt,Txt_Disclaimer_the_files_hosted_here_, - Cfg_PLATFORM_SHORT_NAME, - Cfg_PLATFORM_RESPONSIBLE_EMAIL); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Disclaimer_the_files_hosted_here_, + Cfg_PLATFORM_SHORT_NAME, + Cfg_PLATFORM_RESPONSIBLE_EMAIL); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } @@ -7027,8 +7029,9 @@ void Brw_AskRemFileFromTree (void) Gbl.FileBrowser.FileType, Gbl.FileBrowser.FilFolLnkName, FileNameToShow); - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_FILE_OR_LINK_X, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_FILE_OR_LINK_X, + FileNameToShow); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, Brw_ActRemoveFile[Gbl.FileBrowser.Type],NULL,NULL, Brw_PutParamsRemFile, @@ -7096,7 +7099,9 @@ void Brw_RemFileFromTree (void) Gbl.Usrs.Other.UsrDat.UsrCod); /* Message of confirmation of removing */ - sprintf (Gbl.Alert.Txt,Txt_FILE_X_removed,FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_FILE_X_removed, + FileNameToShow); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else // File / link not found @@ -7152,8 +7157,9 @@ void Brw_RemFolderFromTree (void) Gbl.Usrs.Other.UsrDat.UsrCod); /* Message of confirmation of successfull removing */ - sprintf (Gbl.Alert.Txt,Txt_Folder_X_removed, - Gbl.FileBrowser.FilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Folder_X_removed, + Gbl.FileBrowser.FilFolLnkName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else // Folder not found @@ -7176,8 +7182,9 @@ static void Brw_AskConfirmRemoveFolderNotEmpty (void) extern const char *Txt_Remove_folder; /***** Show question and button to remove not empty folder *****/ - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_folder_X, - Gbl.FileBrowser.FilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_folder_X, + Gbl.FileBrowser.FilFolLnkName); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, Brw_ActRemoveFolderNotEmpty[Gbl.FileBrowser.Type],NULL,NULL, Brw_PutParamsRemFolder, @@ -7230,8 +7237,9 @@ void Brw_RemSubtreeInFileBrowser (void) Brw_RemoveAffectedExpandedFolders (Gbl.FileBrowser.Priv.FullPathInTree); /***** Write message of confirmation *****/ - sprintf (Gbl.Alert.Txt,Txt_Folder_X_and_all_its_contents_removed, - Gbl.FileBrowser.FilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Folder_X_and_all_its_contents_removed, + Gbl.FileBrowser.FilFolLnkName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -7523,16 +7531,18 @@ static void Brw_WriteCurrentClipboard (void) Gbl.FileBrowser.Clipboard.FileName, FileNameToShow); - sprintf (Gbl.Alert.Txt,"%s: %s, %s %s.", - Txt_Copy_source,TxtClipboardZone, - TxtFileType[Gbl.FileBrowser.Clipboard.FileType], - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "%s: %s, %s %s.", + Txt_Copy_source,TxtClipboardZone, + TxtFileType[Gbl.FileBrowser.Clipboard.FileType], + FileNameToShow); } else // The root folder - sprintf (Gbl.Alert.Txt,"%s: %s, %s.", - Txt_Copy_source,TxtClipboardZone, - Txt_all_files_inside_the_root_folder); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "%s: %s, %s.", + Txt_Copy_source,TxtClipboardZone, + Txt_all_files_inside_the_root_folder); Ale_ShowAlert (Ale_CLIPBOARD,Gbl.Alert.Txt); } @@ -8434,14 +8444,15 @@ static void Brw_PasteClipboard (void) &FirstFilCod)) { /***** Write message of success *****/ - sprintf (Gbl.Alert.Txt,"%s
    " - "%s: %u
    " - "%s: %u
    " - "%s: %u", - Txt_The_copy_has_been_successful, - Txt_Files_copied ,Pasted.NumFiles, - Txt_Links_copied ,Pasted.NumLinks, - Txt_Folders_copied,Pasted.NumFolds); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "%s
    " + "%s: %u
    " + "%s: %u
    " + "%s: %u", + Txt_The_copy_has_been_successful, + Txt_Files_copied ,Pasted.NumFiles, + Txt_Links_copied ,Pasted.NumLinks, + Txt_Folders_copied,Pasted.NumFolds); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Notify new files *****/ @@ -8582,16 +8593,19 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg, switch (FileType) { case Brw_IS_FILE: - sprintf (Gbl.Alert.Txt,Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_it_would_exceed_the_maximum_allowed_number_of_levels, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_it_would_exceed_the_maximum_allowed_number_of_levels, + FileNameToShow); break; case Brw_IS_FOLDER: - sprintf (Gbl.Alert.Txt,Txt_The_copy_has_stopped_when_trying_to_paste_the_folder_X_because_it_would_exceed_the_maximum_allowed_number_of_levels, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_copy_has_stopped_when_trying_to_paste_the_folder_X_because_it_would_exceed_the_maximum_allowed_number_of_levels, + FileNameToShow); break; case Brw_IS_LINK: - sprintf (Gbl.Alert.Txt,Txt_The_copy_has_stopped_when_trying_to_paste_the_link_X_because_it_would_exceed_the_maximum_allowed_number_of_levels, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_copy_has_stopped_when_trying_to_paste_the_link_X_because_it_would_exceed_the_maximum_allowed_number_of_levels, + FileNameToShow); break; default: Lay_ShowErrorAndExit ("Can not paste unknown file type."); @@ -8608,10 +8622,10 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg, /***** Check if exists the destination file */ if (Fil_CheckIfPathExists (PathDstWithFile)) { - sprintf (Gbl.Alert.Txt, - FileType == Brw_IS_FILE ? Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_there_is_already_an_object_with_that_name : - Txt_The_copy_has_stopped_when_trying_to_paste_the_link_X_because_there_is_already_an_object_with_that_name, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + FileType == Brw_IS_FILE ? Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_there_is_already_an_object_with_that_name : + Txt_The_copy_has_stopped_when_trying_to_paste_the_link_X_because_there_is_already_an_object_with_that_name, + FileNameToShow); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); CopyIsGoingSuccessful = false; } @@ -8627,8 +8641,9 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg, Mrk_CheckFileOfMarks (PathOrg,&Marks); // Gbl.Alert.Txt contains feedback text else { - sprintf (Gbl.Alert.Txt,Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_you_can_not_paste_a_file_here_of_a_type_other_than_HTML, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_you_can_not_paste_a_file_here_of_a_type_other_than_HTML, + FileNameToShow); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); CopyIsGoingSuccessful = false; } @@ -8641,9 +8656,10 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg, Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size; if (Brw_CheckIfQuotaExceded ()) { - sprintf (Gbl.Alert.Txt,FileType == Brw_IS_FILE ? Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_it_would_exceed_the_disk_quota : - Txt_The_copy_has_stopped_when_trying_to_paste_the_link_X_because_it_would_exceed_the_disk_quota, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + FileType == Brw_IS_FILE ? Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_it_would_exceed_the_disk_quota : + Txt_The_copy_has_stopped_when_trying_to_paste_the_link_X_because_it_would_exceed_the_disk_quota, + FileNameToShow); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); CopyIsGoingSuccessful = false; } @@ -8684,8 +8700,9 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg, Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size; if (Brw_CheckIfQuotaExceded ()) { - sprintf (Gbl.Alert.Txt,Txt_The_copy_has_stopped_when_trying_to_paste_the_folder_X_because_it_would_exceed_the_disk_quota, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_copy_has_stopped_when_trying_to_paste_the_folder_X_because_it_would_exceed_the_disk_quota, + FileNameToShow); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); CopyIsGoingSuccessful = false; } @@ -8811,8 +8828,9 @@ static void Brw_PutFormToCreateAFolder (const char FileNameToShow[NAME_MAX + 1]) /***** Start box *****/ Box_StartBox (NULL,Txt_Create_folder,NULL, NULL,Box_NOT_CLOSABLE); - sprintf (Gbl.Alert.Txt,Txt_You_can_create_a_new_folder_inside_the_folder_X, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_create_a_new_folder_inside_the_folder_X, + FileNameToShow); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Folder *****/ @@ -8850,8 +8868,9 @@ static void Brw_PutFormToUploadFilesUsingDropzone (const char *FileNameToShow) NULL,Box_NOT_CLOSABLE); /***** Help message *****/ - sprintf (Gbl.Alert.Txt,Txt_or_you_can_upload_new_files_to_the_folder_X, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_or_you_can_upload_new_files_to_the_folder_X, + FileNameToShow); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Form to upload files using the library Dropzone.js *****/ @@ -8912,8 +8931,9 @@ static void Brw_PutFormToUploadOneFileClassic (const char *FileNameToShow) NULL,Box_NOT_CLOSABLE); /***** Help message *****/ - sprintf (Gbl.Alert.Txt,Txt_or_you_can_upload_a_new_file_to_the_folder_X, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_or_you_can_upload_a_new_file_to_the_folder_X, + FileNameToShow); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Form to upload one files using the classic way *****/ @@ -8955,8 +8975,9 @@ static void Brw_PutFormToPasteAFileOrFolder (const char *FileNameToShow) NULL,Box_NOT_CLOSABLE); /***** Help message *****/ - sprintf (Gbl.Alert.Txt,Txt_or_you_can_make_a_file_copy_to_the_folder_X, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_or_you_can_make_a_file_copy_to_the_folder_X, + FileNameToShow); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Send button and end box *****/ @@ -8991,8 +9012,9 @@ static void Brw_PutFormToCreateALink (const char *FileNameToShow) NULL,Box_NOT_CLOSABLE); /***** Help message *****/ - sprintf (Gbl.Alert.Txt,Txt_or_you_can_create_a_new_link_inside_the_folder_X, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_or_you_can_create_a_new_link_inside_the_folder_X, + FileNameToShow); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** URL *****/ @@ -9080,8 +9102,9 @@ void Brw_RecFolderFileBrowser (void) if (Brw_CheckIfQuotaExceded ()) { Fil_RemoveTree (Path); - sprintf (Gbl.Alert.Txt,Txt_Can_not_create_the_folder_X_because_it_would_exceed_the_disk_quota, - Gbl.FileBrowser.NewFilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Can_not_create_the_folder_X_because_it_would_exceed_the_disk_quota, + Gbl.FileBrowser.NewFilFolLnkName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -9107,8 +9130,9 @@ void Brw_RecFolderFileBrowser (void) Brw_IS_FOLDER, Gbl.FileBrowser.FilFolLnkName, FileNameToShow); - sprintf (Gbl.Alert.Txt,Txt_The_folder_X_has_been_created_inside_the_folder_Y, - Gbl.FileBrowser.NewFilFolLnkName,FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_folder_X_has_been_created_inside_the_folder_Y, + Gbl.FileBrowser.NewFilFolLnkName,FileNameToShow); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } @@ -9117,8 +9141,9 @@ void Brw_RecFolderFileBrowser (void) switch (errno) { case EEXIST: - sprintf (Gbl.Alert.Txt,Txt_Can_not_create_the_folder_X_because_there_is_already_a_folder_or_a_file_with_that_name, - Gbl.FileBrowser.NewFilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Can_not_create_the_folder_X_because_there_is_already_a_folder_or_a_file_with_that_name, + Gbl.FileBrowser.NewFilFolLnkName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); break; case EACCES: @@ -9195,8 +9220,9 @@ void Brw_RenFolderFileBrowser (void) case ENOTEMPTY: case EEXIST: case ENOTDIR: - sprintf (Gbl.Alert.Txt,Txt_The_folder_name_X_has_not_changed_because_there_is_already_a_folder_or_a_file_with_the_name_Y, - Gbl.FileBrowser.FilFolLnkName,Gbl.FileBrowser.NewFilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_folder_name_X_has_not_changed_because_there_is_already_a_folder_or_a_file_with_the_name_Y, + Gbl.FileBrowser.FilFolLnkName,Gbl.FileBrowser.NewFilFolLnkName); break; case EACCES: Lay_ShowErrorAndExit ("Write forbidden."); @@ -9230,17 +9256,19 @@ void Brw_RenFolderFileBrowser (void) NewPathInTree); /* Write message of confirmation */ - sprintf (Gbl.Alert.Txt,Txt_The_folder_name_X_has_changed_to_Y, - Gbl.FileBrowser.FilFolLnkName, - Gbl.FileBrowser.NewFilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_folder_name_X_has_changed_to_Y, + Gbl.FileBrowser.FilFolLnkName, + Gbl.FileBrowser.NewFilFolLnkName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } else // Names are equal. This may happens if we have press INTRO without changing the name { - sprintf (Gbl.Alert.Txt,Txt_The_folder_name_X_has_not_changed, - Gbl.FileBrowser.FilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_folder_name_X_has_not_changed, + Gbl.FileBrowser.FilFolLnkName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -9366,8 +9394,9 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType) if (Fil_CheckIfPathExists (Path)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_UPLOAD_FILE_X_file_already_exists_NO_HTML, - Gbl.FileBrowser.NewFilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_UPLOAD_FILE_X_file_already_exists_NO_HTML, + Gbl.FileBrowser.NewFilFolLnkName); } else // Destination file does not exist { @@ -9388,8 +9417,9 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType) { Fil_RemoveTree (PathTmp); Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_UPLOAD_FILE_could_not_create_file_NO_HTML, - Gbl.FileBrowser.NewFilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_UPLOAD_FILE_could_not_create_file_NO_HTML, + Gbl.FileBrowser.NewFilFolLnkName); } else // Success { @@ -9400,8 +9430,9 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType) { Fil_RemoveTree (Path); Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_UPLOAD_FILE_X_quota_exceeded_NO_HTML, - Gbl.FileBrowser.NewFilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_UPLOAD_FILE_X_quota_exceeded_NO_HTML, + Gbl.FileBrowser.NewFilFolLnkName); } else { @@ -9429,9 +9460,10 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType) Gbl.FileBrowser.FilFolLnkName, FileNameToShow); Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_file_X_has_been_placed_inside_the_folder_Y, - Gbl.FileBrowser.NewFilFolLnkName, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_file_X_has_been_placed_inside_the_folder_Y, + Gbl.FileBrowser.NewFilFolLnkName, + FileNameToShow); } UploadSucessful = true; @@ -9572,8 +9604,9 @@ void Brw_RecLinkFileBrowser (void) /* Check if the URL file exists */ if (Fil_CheckIfPathExists (Path)) { - sprintf (Gbl.Alert.Txt,Txt_Can_not_create_the_link_X_because_there_is_already_a_folder_or_a_link_with_that_name, - FileName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Can_not_create_the_link_X_because_there_is_already_a_folder_or_a_link_with_that_name, + FileName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // URL file does not exist @@ -9593,8 +9626,9 @@ void Brw_RecLinkFileBrowser (void) if (Brw_CheckIfQuotaExceded ()) { Fil_RemoveTree (Path); - sprintf (Gbl.Alert.Txt,Txt_Can_not_create_the_link_X_because_it_would_exceed_the_disk_quota, - FileName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Can_not_create_the_link_X_because_it_would_exceed_the_disk_quota, + FileName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -9620,8 +9654,9 @@ void Brw_RecLinkFileBrowser (void) Brw_IS_FOLDER, Gbl.FileBrowser.FilFolLnkName, FileNameToShow); - sprintf (Gbl.Alert.Txt,Txt_The_link_X_has_been_placed_inside_the_folder_Y, - FileName,FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_link_X_has_been_placed_inside_the_folder_Y, + FileName,FileNameToShow); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); FileMetadata.FilCod = FilCod; @@ -9695,15 +9730,17 @@ static bool Brw_CheckIfUploadIsAllowed (const char *MIMEType) if (strcmp (MIMEType,"application/octetstream")) if (strcmp (MIMEType,"application/octet")) { // MIME type forbidden - sprintf (Gbl.Alert.Txt,Txt_UPLOAD_FILE_X_MIME_type_Y_not_allowed_NO_HTML, - Gbl.FileBrowser.NewFilFolLnkName,MIMEType); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_UPLOAD_FILE_X_MIME_type_Y_not_allowed_NO_HTML, + Gbl.FileBrowser.NewFilFolLnkName,MIMEType); return false; } } else { - sprintf (Gbl.Alert.Txt,Txt_UPLOAD_FILE_X_not_HTML_NO_HTML, - Gbl.FileBrowser.NewFilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_UPLOAD_FILE_X_not_HTML_NO_HTML, + Gbl.FileBrowser.NewFilFolLnkName); return false; } break; @@ -9730,15 +9767,17 @@ static bool Brw_CheckIfUploadIsAllowed (const char *MIMEType) } if (!MIMETypeIsAllowed) { - sprintf (Gbl.Alert.Txt,Txt_UPLOAD_FILE_X_MIME_type_Y_not_allowed_NO_HTML, - Gbl.FileBrowser.NewFilFolLnkName,MIMEType); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_UPLOAD_FILE_X_MIME_type_Y_not_allowed_NO_HTML, + Gbl.FileBrowser.NewFilFolLnkName,MIMEType); return false; } } else { - sprintf (Gbl.Alert.Txt,Txt_UPLOAD_FILE_X_extension_not_allowed_NO_HTML, - Gbl.FileBrowser.NewFilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_UPLOAD_FILE_X_extension_not_allowed_NO_HTML, + Gbl.FileBrowser.NewFilFolLnkName); return false; } break; @@ -9775,8 +9814,9 @@ void Brw_SetDocumentAsVisible (void) Gbl.FileBrowser.FileType, Gbl.FileBrowser.FilFolLnkName, FileNameToShow); - sprintf (Gbl.Alert.Txt,Txt_FILE_FOLDER_OR_LINK_X_is_now_visible, - FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_FILE_FOLDER_OR_LINK_X_is_now_visible, + FileNameToShow); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show again the file browser *****/ @@ -9812,7 +9852,9 @@ void Brw_SetDocumentAsHidden (void) Gbl.FileBrowser.FileType, Gbl.FileBrowser.FilFolLnkName, FileNameToShow); - sprintf (Gbl.Alert.Txt,Txt_FILE_FOLDER_OR_LINK_X_is_now_hidden,FileNameToShow); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_FILE_FOLDER_OR_LINK_X_is_now_hidden, + FileNameToShow); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show again the file browser *****/ @@ -10777,15 +10819,17 @@ void Brw_ChgFileMetadata (void) } /***** Write message of confirmation *****/ - sprintf (Gbl.Alert.Txt,Txt_The_properties_of_file_X_have_been_saved, - Gbl.FileBrowser.FilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_properties_of_file_X_have_been_saved, + Gbl.FileBrowser.FilFolLnkName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else { /***** Write message of error *****/ - sprintf (Gbl.Alert.Txt,Txt_You_dont_have_permission_to_change_the_properties_of_file_X, - Gbl.FileBrowser.FilFolLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_dont_have_permission_to_change_the_properties_of_file_X, + Gbl.FileBrowser.FilFolLnkName); Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt); } @@ -12793,12 +12837,13 @@ void Brw_RemoveOldFilesBriefcase (void) Brw_RemoveOldFilesInBrowser (Months,&Removed); /***** Success message *****/ - sprintf (Gbl.Alert.Txt,"%s: %u
    " - "%s: %u
    " - "%s: %u", - Txt_Files_removed ,Removed.NumFiles, - Txt_Links_removed ,Removed.NumLinks, - Txt_Folders_removed,Removed.NumFolds); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "%s: %u
    " + "%s: %u
    " + "%s: %u", + Txt_Files_removed ,Removed.NumFiles, + Txt_Links_removed ,Removed.NumLinks, + Txt_Folders_removed,Removed.NumFolds); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_forum.c b/swad_forum.c index 2efeedba..ac14c0a9 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -4162,8 +4162,9 @@ void For_RequestRemoveThread (void) /***** Show question and button to remove the thread *****/ Lay_StartSection (For_REMOVE_THREAD_SECTION_ID); if (Subject[0]) - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_entire_thread_X, - Subject); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_entire_thread_X, + Subject); else Str_Copy (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_entire_thread, Ale_MAX_BYTES_ALERT); @@ -4218,7 +4219,8 @@ void For_RemoveThread (void) /***** Show the threads again *****/ if (Subject[0]) { - sprintf (Gbl.Alert.Txt,Txt_Thread_X_removed,Subject); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Thread_X_removed,Subject); For_ShowForumThreadsHighlightingOneThread (Gbl.Forum.ForumSelected.ThrCod, Ale_SUCCESS,Gbl.Alert.Txt); } @@ -4255,7 +4257,8 @@ void For_CutThread (void) /***** Show the threads again *****/ if (Subject[0]) { - sprintf (Gbl.Alert.Txt,Txt_Thread_X_marked_to_be_moved,Subject); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Thread_X_marked_to_be_moved,Subject); For_ShowForumThreadsHighlightingOneThread (Gbl.Forum.ForumSelected.ThrCod, Ale_SUCCESS,Gbl.Alert.Txt); } @@ -4292,8 +4295,9 @@ void For_PasteThread (void) /***** Show the threads again *****/ if (Subject[0]) { - sprintf (Gbl.Alert.Txt,Txt_The_thread_X_is_already_in_this_forum, - Subject); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_thread_X_is_already_in_this_forum, + Subject); For_ShowForumThreadsHighlightingOneThread (Gbl.Forum.ForumSelected.ThrCod, Ale_WARNING,Gbl.Alert.Txt); } @@ -4312,8 +4316,9 @@ void For_PasteThread (void) /***** Show the threads again *****/ if (Subject[0]) { - sprintf (Gbl.Alert.Txt,Txt_Thread_X_moved_to_this_forum, - Subject); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Thread_X_moved_to_this_forum, + Subject); For_ShowForumThreadsHighlightingOneThread (Gbl.Forum.ForumSelected.ThrCod, Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_game.c b/swad_game.c index 32e78fa9..fd5981dd 100644 --- a/swad_game.c +++ b/swad_game.c @@ -1495,8 +1495,9 @@ void Gam_AskRemGame (void) /***** Show question and button to remove game *****/ Gbl.Games.CurrentGamCod = Game.GamCod; - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_game_X, - Game.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_game_X, + Game.Title); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, ActRemGam,NULL,NULL,Gam_PutParams, Btn_REMOVE_BUTTON,Txt_Remove_game); @@ -1544,8 +1545,9 @@ void Gam_RemoveGame (void) DB_QueryDELETE (Query,"can not remove game"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Game_X_removed, - Game.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Game_X_removed, + Game.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show games again *****/ @@ -1576,8 +1578,9 @@ void Gam_AskResetGame (void) Lay_ShowErrorAndExit ("You can not reset this game."); /***** Ask for confirmation of reset *****/ - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_reset_the_game_X, - Game.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_reset_the_game_X, + Game.Title); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); /***** Button of confirmation of reset *****/ @@ -1634,8 +1637,9 @@ void Gam_ResetGame (void) DB_QueryUPDATE (Query,"can not reset answers of a game"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Game_X_reset, - Game.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Game_X_reset, + Game.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show games again *****/ @@ -1667,8 +1671,9 @@ void Gam_HideGame (void) DB_QueryUPDATE (Query,"can not hide game"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Game_X_is_now_hidden, - Game.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Game_X_is_now_hidden, + Game.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show games again *****/ @@ -1700,8 +1705,9 @@ void Gam_UnhideGame (void) DB_QueryUPDATE (Query,"can not show game"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Game_X_is_now_visible, - Game.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Game_X_is_now_visible, + Game.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show games again *****/ @@ -2143,8 +2149,9 @@ void Gam_RecFormGame (void) if (Gam_CheckIfSimilarGameExists (&NewGame)) { NewGameIsCorrect = false; - sprintf (Gbl.Alert.Txt,Txt_Already_existed_a_game_with_the_title_X, - NewGame.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Already_existed_a_game_with_the_title_X, + NewGame.Title); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } } @@ -2208,8 +2215,9 @@ static void Gam_CreateGame (struct Game *Game,const char *Txt) Gam_CreateGrps (Game->GamCod); /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_game_X, - Game->Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_game_X, + Game->Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -3272,8 +3280,9 @@ void Gam_RequestRemoveQst (void) /***** Show question and button to remove question *****/ Gbl.Games.CurrentGamCod = Game.GamCod; Gbl.Games.CurrentQstCod = QstCod; - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_question_X, - (unsigned long) (QstInd + 1)); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_question_X, + (unsigned long) (QstInd + 1)); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, ActRemGamQst,NULL,NULL,Gam_PutParamsOneQst, Btn_REMOVE_BUTTON,Txt_Remove_question); diff --git a/swad_group.c b/swad_group.c index cfc2e270..566850e5 100644 --- a/swad_group.c +++ b/swad_group.c @@ -281,8 +281,9 @@ static void Grp_EditGroupTypes (void) Grp_ListGroupTypesForEdition (); else // No group types found in this course { - sprintf (Gbl.Alert.Txt,Txt_There_are_no_types_of_group_in_the_course_X, - Gbl.CurrentCrs.Crs.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_are_no_types_of_group_in_the_course_X, + Gbl.CurrentCrs.Crs.ShrtName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } @@ -312,8 +313,9 @@ static void Grp_EditGroups (void) Grp_ListGroupsForEdition (); else // There are group types, but there aren't groups { - sprintf (Gbl.Alert.Txt,Txt_No_groups_have_been_created_in_the_course_X, - Gbl.CurrentCrs.Crs.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_No_groups_have_been_created_in_the_course_X, + Gbl.CurrentCrs.Crs.ShrtName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } @@ -1103,17 +1105,19 @@ void Grp_RegisterUsrIntoGroups (struct UsrData *UsrDat,struct ListCodGrps *LstGr /* If the enrolment is single and the group to which the user belongs is different from the selected ==> remove user from the group to which he belongs */ Grp_RemoveUsrFromGroup (UsrDat->UsrCod,LstGrpsHeBelongs.GrpCods[NumGrpHeBelongs]); - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_removed_from_the_group_of_type_Y_to_which_it_belonged, - UsrDat->FullName,Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_removed_from_the_group_of_type_Y_to_which_it_belonged, + UsrDat->FullName,Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } if (!AlreadyRegisteredInGrp) // If the user does not belong to the selected group { Grp_AddUsrToGroup (UsrDat,LstGrps->GrpCods[NumGrpSel]); - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_enroled_in_the_group_of_type_Y_Z, - UsrDat->FullName,Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName, - Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].LstGrps[NumGrpThisType].GrpName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_enroled_in_the_group_of_type_Y_Z, + UsrDat->FullName,Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName, + Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].LstGrps[NumGrpThisType].GrpName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1162,14 +1166,17 @@ unsigned Grp_RemoveUsrFromGroups (struct UsrData *UsrDat,struct ListCodGrps *Lst /***** Write message to inform about how many groups the student has been removed from *****/ if (NumGrpsHeIsRemoved == 0) - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_not_been_removed_from_any_group, - UsrDat->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_not_been_removed_from_any_group, + UsrDat->FullName); else if (NumGrpsHeIsRemoved == 1) - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_removed_from_one_group, - UsrDat->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_removed_from_one_group, + UsrDat->FullName); else // NumGrpsHeIsRemoved > 1 - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_removed_from_Y_groups, - UsrDat->FullName,NumGrpsHeIsRemoved); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_removed_from_Y_groups, + UsrDat->FullName,NumGrpsHeIsRemoved); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Free the list of groups of this type to which the user belonged *****/ @@ -1800,8 +1807,9 @@ void Grp_ShowLstGrpsToChgMyGrps (void) } else // This course has no groups { - sprintf (Gbl.Alert.Txt,Txt_No_groups_have_been_created_in_the_course_X, - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_No_groups_have_been_created_in_the_course_X, + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Button to create group *****/ @@ -1854,18 +1862,18 @@ static void Grp_ShowWarningToStdsToChangeGrps (void) { if (GrpTyp->MandatoryEnrolment) { - sprintf (Gbl.Alert.Txt, - GrpTyp->MultipleEnrolment ? Txt_You_have_to_register_compulsorily_at_least_in_one_group_of_type_X : - Txt_You_have_to_register_compulsorily_in_one_group_of_type_X, - GrpTyp->GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + GrpTyp->MultipleEnrolment ? Txt_You_have_to_register_compulsorily_at_least_in_one_group_of_type_X : + Txt_You_have_to_register_compulsorily_in_one_group_of_type_X, + GrpTyp->GrpTypName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else { - sprintf (Gbl.Alert.Txt, - GrpTyp->MultipleEnrolment ? Txt_You_can_register_voluntarily_in_one_or_more_groups_of_type_X : - Txt_You_can_register_voluntarily_in_one_group_of_type_X, - GrpTyp->GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + GrpTyp->MultipleEnrolment ? Txt_You_can_register_voluntarily_in_one_or_more_groups_of_type_X : + Txt_You_can_register_voluntarily_in_one_group_of_type_X, + GrpTyp->GrpTypName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -3678,16 +3686,18 @@ void Grp_RecFormNewGrpTyp (void) if (Grp_CheckIfGroupTypeNameExists (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,-1L)) { AlertType = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_type_of_group_X_already_exists, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_group_X_already_exists, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); } else // Add new group type to database { Grp_CreateGroupType (); AlertType = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_Created_new_type_of_group_X, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_type_of_group_X, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); } } else // If there is not a group type name @@ -3747,8 +3757,9 @@ void Grp_RecFormNewGrp (void) if (Grp_CheckIfGroupNameExists (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod,Gbl.CurrentCrs.Grps.GrpName,-1L)) { AlertType = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_group_X_already_exists, - Gbl.CurrentCrs.Grps.GrpName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_group_X_already_exists, + Gbl.CurrentCrs.Grps.GrpName); } else // Add new group to database { @@ -3756,8 +3767,9 @@ void Grp_RecFormNewGrp (void) /* Write success message */ AlertType = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_Created_new_group_X, - Gbl.CurrentCrs.Grps.GrpName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_group_X, + Gbl.CurrentCrs.Grps.GrpName); } } else // If there is not a group name @@ -3904,11 +3916,13 @@ static void Grp_AskConfirmRemGrpTypWithGrps (unsigned NumGrps) /***** Show question and button to remove type of group *****/ if (NumGrps == 1) - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_type_of_group_X_1_group_, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_type_of_group_X_1_group_, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); else - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_type_of_group_X_Y_groups_, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,NumGrps); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_type_of_group_X_Y_groups_, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,NumGrps); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, ActRemGrpTyp,Grp_GROUP_TYPES_SECTION_ID,NULL, Grp_PutParamRemGrpTyp, @@ -3954,14 +3968,17 @@ static void Grp_AskConfirmRemGrp (void) /***** Show question and button to remove group *****/ if (NumStds == 0) - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_group_X, - GrpDat.GrpName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_group_X, + GrpDat.GrpName); else if (NumStds == 1) - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_group_X_1_student_, - GrpDat.GrpName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_group_X_1_student_, + GrpDat.GrpName); else - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_group_X_Y_students_, - GrpDat.GrpName,NumStds); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_group_X_Y_students_, + GrpDat.GrpName,NumStds); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, ActRemGrp,Grp_GROUPS_SECTION_ID,NULL, Grp_PutParamRemGrp, @@ -4055,9 +4072,10 @@ static void Grp_RemoveGroupTypeCompletely (void) Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod); DB_QueryDELETE (Query,"can not remove a type of group"); - /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Type_of_group_X_removed, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); + /***** Create message to show the change made *****/ + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Type_of_group_X_removed, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); /***** Show the form again *****/ Grp_ReqEditGroupsInternal (Ale_SUCCESS,Gbl.Alert.Txt, @@ -4105,8 +4123,10 @@ static void Grp_RemoveGroupCompletely (void) Gbl.CurrentCrs.Grps.GrpCod); DB_QueryDELETE (Query,"can not remove a group"); - /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Group_X_removed,GrpDat.GrpName); + /***** Create message to show the change made *****/ + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Group_X_removed, + GrpDat.GrpName); /***** Show the form again *****/ Grp_ReqEditGroupsInternal (Ale_INFO,NULL, @@ -4136,8 +4156,10 @@ void Grp_OpenGroup (void) Gbl.CurrentCrs.Grps.GrpCod); DB_QueryUPDATE (Query,"can not open a group"); - /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_group_X_is_now_open,GrpDat.GrpName); + /***** Create message to show the change made *****/ + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_group_X_is_now_open, + GrpDat.GrpName); /***** Show the form again *****/ Gbl.CurrentCrs.Grps.Open = true; @@ -4168,8 +4190,10 @@ void Grp_CloseGroup (void) Gbl.CurrentCrs.Grps.GrpCod); DB_QueryUPDATE (Query,"can not close a group"); - /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_group_X_is_now_closed,GrpDat.GrpName); + /***** Create message to show the change made *****/ + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_group_X_is_now_closed, + GrpDat.GrpName); /***** Show the form again *****/ Gbl.CurrentCrs.Grps.Open = false; @@ -4200,9 +4224,10 @@ void Grp_EnableFileZonesGrp (void) Gbl.CurrentCrs.Grps.GrpCod); DB_QueryUPDATE (Query,"can not enable file zones of a group"); - /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_File_zones_of_the_group_X_are_now_enabled, - GrpDat.GrpName); + /***** Create message to show the change made *****/ + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_File_zones_of_the_group_X_are_now_enabled, + GrpDat.GrpName); /***** Show the form again *****/ Gbl.CurrentCrs.Grps.FileZones = true; @@ -4233,9 +4258,10 @@ void Grp_DisableFileZonesGrp (void) Gbl.CurrentCrs.Grps.GrpCod); DB_QueryUPDATE (Query,"can not disable file zones of a group"); - /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_File_zones_of_the_group_X_are_now_disabled, - GrpDat.GrpName); + /***** Create message to show the change made *****/ + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_File_zones_of_the_group_X_are_now_disabled, + GrpDat.GrpName); /***** Show the form again *****/ Gbl.CurrentCrs.Grps.FileZones = false; @@ -4271,20 +4297,24 @@ void Grp_ChangeGroupType (void) /***** If group was in database... *****/ if (Grp_CheckIfGroupNameExists (NewGrpTypCod,GrpDat.GrpName,-1L)) { + /* Create warning message */ AlertType = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_group_X_already_exists,GrpDat.GrpName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_group_X_already_exists, + GrpDat.GrpName); } - else + else // Group is not in database { /* Update the table of groups changing old type by new type */ sprintf (Query,"UPDATE crs_grp SET GrpTypCod=%ld WHERE GrpCod=%ld", NewGrpTypCod,Gbl.CurrentCrs.Grps.GrpCod); DB_QueryUPDATE (Query,"can not update the type of a group"); - /***** Write message to show the change made *****/ + /* Create message to show the change made */ AlertType = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_type_of_group_of_the_group_X_has_changed, - GrpDat.GrpName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_group_of_the_group_X_has_changed, + GrpDat.GrpName); } /***** Show the form again *****/ @@ -4322,8 +4352,9 @@ void Grp_ChangeMandatGrpTyp (void) if (Gbl.CurrentCrs.Grps.GrpTyp.MandatoryEnrolment == NewMandatoryEnrolment) { AlertType = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_type_of_enrolment_of_the_type_of_group_X_has_not_changed, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_enrolment_of_the_type_of_group_X_has_not_changed, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); } else { @@ -4336,10 +4367,10 @@ void Grp_ChangeMandatGrpTyp (void) /***** Write message to show the change made *****/ AlertType = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt, - NewMandatoryEnrolment ? Txt_The_enrolment_of_students_into_groups_of_type_X_is_now_mandatory : - Txt_The_enrolment_of_students_into_groups_of_type_X_is_now_voluntary, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + NewMandatoryEnrolment ? Txt_The_enrolment_of_students_into_groups_of_type_X_is_now_mandatory : + Txt_The_enrolment_of_students_into_groups_of_type_X_is_now_voluntary, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); } /***** Show the form again *****/ @@ -4377,8 +4408,9 @@ void Grp_ChangeMultiGrpTyp (void) if (Gbl.CurrentCrs.Grps.GrpTyp.MultipleEnrolment == NewMultipleEnrolment) { AlertType = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_type_of_enrolment_of_the_type_of_group_X_has_not_changed, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_enrolment_of_the_type_of_group_X_has_not_changed, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); } else { @@ -4392,10 +4424,10 @@ void Grp_ChangeMultiGrpTyp (void) /***** Write message to show the change made *****/ AlertType = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt, - NewMultipleEnrolment ? Txt_Now_each_student_can_belong_to_multiple_groups_of_type_X : - Txt_Now_each_student_can_only_belong_to_a_group_of_type_X, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + NewMultipleEnrolment ? Txt_Now_each_student_can_belong_to_multiple_groups_of_type_X : + Txt_Now_each_student_can_only_belong_to_a_group_of_type_X, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); } /***** Show the form again *****/ @@ -4477,8 +4509,9 @@ void Grp_ChangeMaxStdsGrp (void) if (GrpDat.MaxStudents == NewMaxStds) { AlertType = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_maximum_number_of_students_in_the_group_X_has_not_changed, - GrpDat.GrpName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_maximum_number_of_students_in_the_group_X_has_not_changed, + GrpDat.GrpName); } else { @@ -4490,11 +4523,13 @@ void Grp_ChangeMaxStdsGrp (void) /***** Write message to show the change made *****/ AlertType = Ale_SUCCESS; if (NewMaxStds > Grp_MAX_STUDENTS_IN_A_GROUP) - sprintf (Gbl.Alert.Txt,Txt_The_group_X_now_has_no_limit_of_students, - GrpDat.GrpName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_group_X_now_has_no_limit_of_students, + GrpDat.GrpName); else - sprintf (Gbl.Alert.Txt,Txt_The_maximum_number_of_students_in_the_group_X_is_now_Y, - GrpDat.GrpName,NewMaxStds); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_maximum_number_of_students_in_the_group_X_is_now_Y, + GrpDat.GrpName,NewMaxStds); } /***** Show the form again *****/ @@ -4557,8 +4592,9 @@ void Grp_RenameGroupType (void) if (!NewNameGrpTyp[0]) { AlertType = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_type_of_group_X_empty, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_type_of_group_X_empty, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); } else { @@ -4569,8 +4605,9 @@ void Grp_RenameGroupType (void) if (Grp_CheckIfGroupTypeNameExists (NewNameGrpTyp,Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod)) { AlertType = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_type_of_group_X_already_exists, - NewNameGrpTyp); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_group_X_already_exists, + NewNameGrpTyp); } else { @@ -4583,15 +4620,17 @@ void Grp_RenameGroupType (void) /***** Write message to show the change made *****/ AlertType = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_type_of_group_X_has_been_renamed_as_Y, - Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,NewNameGrpTyp); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_group_X_has_been_renamed_as_Y, + Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,NewNameGrpTyp); } } else // The same name { AlertType = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_type_of_group_X_has_not_changed, - NewNameGrpTyp); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_type_of_group_X_has_not_changed, + NewNameGrpTyp); } } @@ -4633,8 +4672,9 @@ void Grp_RenameGroup (void) if (!NewNameGrp[0]) { AlertType = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_group_X_empty, - GrpDat.GrpName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_group_X_empty, + GrpDat.GrpName); } else { @@ -4645,7 +4685,9 @@ void Grp_RenameGroup (void) if (Grp_CheckIfGroupNameExists (GrpDat.GrpTypCod,NewNameGrp,Gbl.CurrentCrs.Grps.GrpCod)) { AlertType = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_group_X_already_exists,NewNameGrp); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_group_X_already_exists, + NewNameGrp); } else { @@ -4656,15 +4698,17 @@ void Grp_RenameGroup (void) /***** Write message to show the change made *****/ AlertType = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_group_X_has_been_renamed_as_Y, - GrpDat.GrpName,NewNameGrp); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_group_X_has_been_renamed_as_Y, + GrpDat.GrpName,NewNameGrp); } } else // The same name { AlertType = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_group_X_has_not_changed, - NewNameGrp); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_group_X_has_not_changed, + NewNameGrp); } } diff --git a/swad_help.c b/swad_help.c index f773693d..37d18323 100644 --- a/swad_help.c +++ b/swad_help.c @@ -121,10 +121,11 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) if (Gbl.Usrs.Me.Logged && !Gbl.Usrs.Me.MyCrss.Num) { - sprintf (Gbl.Alert.Txt,"%s
    %s
    %s", - Txt_You_are_not_enroled_in_any_course[Gbl.Usrs.Me.UsrDat.Sex], - Txt_You_can_search_for_courses_select_them_and_request_your_enrolment_in_them, - Txt_If_you_can_not_find_your_institution_your_centre_your_degree_or_your_courses_you_can_create_them); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "%s
    %s
    %s", + Txt_You_are_not_enroled_in_any_course[Gbl.Usrs.Me.UsrDat.Sex], + Txt_You_can_search_for_courses_select_them_and_request_your_enrolment_in_them, + Txt_If_you_can_not_find_your_institution_your_centre_your_degree_or_your_courses_you_can_create_them); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } diff --git a/swad_holiday.c b/swad_holiday.c index 34aa2e0a..292b757f 100644 --- a/swad_holiday.c +++ b/swad_holiday.c @@ -656,7 +656,9 @@ void Hld_RemoveHoliday1 (void) /***** Write message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_Holiday_X_removed,Hld.Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Holiday_X_removed, + Hld.Name); } @@ -706,8 +708,9 @@ void Hld_ChangeHolidayPlace1 (void) /***** Write message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_place_of_the_holiday_X_has_changed_to_Y, - Hld->Name,NewPlace.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_place_of_the_holiday_X_has_changed_to_Y, + Hld->Name,NewPlace.FullName); } void Hld_ChangeHolidayPlace2 (void) @@ -750,8 +753,9 @@ void Hld_ChangeHolidayType1 (void) /***** Write message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_type_of_the_holiday_X_has_changed, - Hld->Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_type_of_the_holiday_X_has_changed, + Hld->Name); } void Hld_ChangeHolidayType2 (void) @@ -850,8 +854,9 @@ static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate) /***** Write message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; Dat_ConvDateToDateStr (&NewDate,StrDate); - sprintf (Gbl.Alert.Txt,Txt_The_date_of_the_holiday_X_has_changed_to_Y, - Hld->Name,StrDate); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_date_of_the_holiday_X_has_changed_to_Y, + Hld->Name,StrDate); } /*****************************************************************************/ @@ -897,8 +902,9 @@ void Hld_RenameHoliday1 (void) if (!NewHldName[0]) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_holiday_X_empty, - Hld->Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_holiday_X_empty, + Hld->Name); } else { @@ -915,14 +921,16 @@ void Hld_RenameHoliday1 (void) /***** Write message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_holiday_X_has_changed_to_Y, - Hld->Name,NewHldName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_holiday_X_has_changed_to_Y, + Hld->Name,NewHldName); } else // The same name { Gbl.Alert.Type = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_holiday_X_has_not_changed, - Hld->Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_holiday_X_has_not_changed, + Hld->Name); } } } @@ -1152,7 +1160,9 @@ void Hld_RecFormNewHoliday1 (void) /* Success message */ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_Created_new_holiday_X,Hld->Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_holiday_X, + Hld->Name); } else // If there is not a holiday name { diff --git a/swad_image.c b/swad_image.c index 10258963..74762554 100644 --- a/swad_image.c +++ b/swad_image.c @@ -489,9 +489,10 @@ static void Img_ProcessImage (struct Image *Image, ReturnCode = WEXITSTATUS(ReturnCode); if (ReturnCode != 0) { - sprintf (Gbl.Alert.Txt,"Image could not be processed successfully.
    " - "Error code returned by the program of processing: %d", - ReturnCode); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Image could not be processed successfully.
    " + "Error code returned by the program of processing: %d", + ReturnCode); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } } diff --git a/swad_indicator.c b/swad_indicator.c index 189ca04d..ecb63054 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -529,8 +529,9 @@ static void Ind_PutButtonToConfirmIWantToSeeBigList (unsigned NumCrss) extern const char *Txt_Show_anyway; /***** Show alert and button to confirm that I want to see the big list *****/ - sprintf (Gbl.Alert.Txt,Txt_The_list_of_X_courses_is_too_large_to_be_displayed, - NumCrss); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_list_of_X_courses_is_too_large_to_be_displayed, + NumCrss); Ale_ShowAlertAndButton (Ale_WARNING,Gbl.Alert.Txt, Gbl.Action.Act,NULL,NULL, Ind_PutParamsConfirmIWantToSeeBigList, diff --git a/swad_info.c b/swad_info.c index 35af6ad0..bd87ed78 100644 --- a/swad_info.c +++ b/swad_info.c @@ -2234,8 +2234,9 @@ void Inf_ReceiveURLInfo (void) fclose (FileURL); /***** Write message *****/ - sprintf (Gbl.Alert.Txt,Txt_The_URL_X_has_been_updated, - Gbl.CurrentCrs.Info.URL); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_URL_X_has_been_updated, + Gbl.CurrentCrs.Info.URL); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); URLIsOK = true; } @@ -2303,8 +2304,9 @@ void Inf_ReceivePagInfo (void) WrongType = true; if (WrongType) { - sprintf (Gbl.Alert.Txt,Txt_The_file_type_is_X_and_should_be_HTML_or_ZIP, - MIMEType); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_file_type_is_X_and_should_be_HTML_or_ZIP, + MIMEType); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } else diff --git a/swad_institution.c b/swad_institution.c index 71f6a122..1d7ccb7a 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -1727,8 +1727,9 @@ void Ins_RemoveInstitution (void) Ins_FlushCacheFullNameAndCtyOfInstitution (); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Institution_X_removed, - Ins.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Institution_X_removed, + Ins.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1808,8 +1809,9 @@ static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtO if (!NewInsName[0]) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_institution_X_empty, - CurrentInsName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_institution_X_empty, + CurrentInsName); } else { @@ -1820,8 +1822,9 @@ static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtO if (Ins_CheckIfInsNameExistsInCty (ParamName,NewInsName,Ins->InsCod,Gbl.CurrentCty.Cty.CtyCod)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_institution_X_already_exists, - NewInsName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_institution_X_already_exists, + NewInsName); } else { @@ -1830,8 +1833,9 @@ static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtO /* Create message to show the change made */ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_institution_X_has_been_renamed_as_Y, - CurrentInsName,NewInsName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_institution_X_has_been_renamed_as_Y, + CurrentInsName,NewInsName); /* Change current institution name in order to display it properly */ Str_Copy (CurrentInsName,NewInsName, @@ -1841,8 +1845,9 @@ static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtO else // The same name { Gbl.Alert.Type = Ale_INFO; - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_institution_X_has_not_changed, - CurrentInsName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_institution_X_has_not_changed, + CurrentInsName); } } } @@ -1903,14 +1908,16 @@ void Ins_ChangeInsCtyInConfig (void) if (Ins_CheckIfInsNameExistsInCty ("ShortName",Gbl.CurrentIns.Ins.ShrtName,-1L,NewCty.CtyCod)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_institution_X_already_exists, - Gbl.CurrentIns.Ins.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_institution_X_already_exists, + Gbl.CurrentIns.Ins.ShrtName); } else if (Ins_CheckIfInsNameExistsInCty ("FullName",Gbl.CurrentIns.Ins.FullName,-1L,NewCty.CtyCod)) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_The_institution_X_already_exists, - Gbl.CurrentIns.Ins.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_institution_X_already_exists, + Gbl.CurrentIns.Ins.FullName); } else { @@ -1924,8 +1931,9 @@ void Ins_ChangeInsCtyInConfig (void) /***** Write message to show the change made *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_country_of_the_institution_X_has_changed_to_Y, - Gbl.CurrentIns.Ins.FullName,NewCty.Name[Gbl.Prefs.Language]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_country_of_the_institution_X_has_changed_to_Y, + Gbl.CurrentIns.Ins.FullName,NewCty.Name[Gbl.Prefs.Language]); } } } @@ -1988,7 +1996,9 @@ void Ins_ChangeInsWWW (void) /***** Write message to show the change made and put button to go to institution changed *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X,NewWWW); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_web_address_is_X, + NewWWW); Ins_ShowAlertAndButtonToGoToIns (); } else @@ -2017,7 +2027,9 @@ void Ins_ChangeInsWWWInConfig (void) Cns_MAX_BYTES_WWW); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X,NewWWW); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_web_address_is_X, + NewWWW); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -2079,8 +2091,9 @@ void Ins_ChangeInsStatus (void) /***** Write message to show the change made and put button to go to institution changed *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_The_status_of_the_institution_X_has_changed, - Gbl.Inss.EditingIns.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_status_of_the_institution_X_has_changed, + Gbl.Inss.EditingIns.ShrtName); Ins_ShowAlertAndButtonToGoToIns (); /***** Show the form again *****/ @@ -2358,14 +2371,16 @@ static void Ins_RecFormRequestOrCreateIns (unsigned Status) /***** If name of institution was in database... *****/ if (Ins_CheckIfInsNameExistsInCty ("ShortName",Gbl.Inss.EditingIns.ShrtName,-1L,Gbl.CurrentCty.Cty.CtyCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_institution_X_already_exists, - Gbl.Inss.EditingIns.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_institution_X_already_exists, + Gbl.Inss.EditingIns.ShrtName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (Ins_CheckIfInsNameExistsInCty ("FullName",Gbl.Inss.EditingIns.FullName,-1L,Gbl.CurrentCty.Cty.CtyCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_institution_X_already_exists, - Gbl.Inss.EditingIns.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_institution_X_already_exists, + Gbl.Inss.EditingIns.FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // Add new institution to database @@ -2410,8 +2425,9 @@ static void Ins_CreateInstitution (unsigned Status) /***** Write message to show the change made and put button to go to institution created *****/ Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_Created_new_institution_X, - Gbl.Inss.EditingIns.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_institution_X, + Gbl.Inss.EditingIns.FullName); Ins_ShowAlertAndButtonToGoToIns (); } diff --git a/swad_link.c b/swad_link.c index 4586941a..89c648e5 100644 --- a/swad_link.c +++ b/swad_link.c @@ -503,8 +503,9 @@ void Lnk_RemoveLink (void) DB_QueryDELETE (Query,"can not remove an institutional link"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Link_X_removed, - Lnk.ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Link_X_removed, + Lnk.ShrtName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show the form again *****/ @@ -577,8 +578,9 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Check if new name is empty *****/ if (!NewLnkName[0]) { - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_link_X_empty, - CurrentLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_link_X_empty, + CurrentLnkName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -589,8 +591,9 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName) /***** If link was in database... *****/ if (Lnk_CheckIfLinkNameExists (ParamName,NewLnkName,Lnk->LnkCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_link_X_already_exists, - NewLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_link_X_already_exists, + NewLnkName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -599,15 +602,17 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName) Lnk_UpdateLnkNameDB (Lnk->LnkCod,FieldName,NewLnkName); /* Write message to show the change made */ - sprintf (Gbl.Alert.Txt,Txt_The_link_X_has_been_renamed_as_Y, - CurrentLnkName,NewLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_link_X_has_been_renamed_as_Y, + CurrentLnkName,NewLnkName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } else // The same name { - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_link_X_has_not_changed, - CurrentLnkName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_link_X_has_not_changed, + CurrentLnkName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -677,8 +682,9 @@ void Lnk_ChangeLinkWWW (void) DB_QueryUPDATE (Query,"can not update the web of an institutional link"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X, - NewWWW); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_web_address_is_X, + NewWWW); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -813,14 +819,16 @@ void Lnk_RecFormNewLink (void) /***** If name of link was in database... *****/ if (Lnk_CheckIfLinkNameExists ("ShortName",Lnk->ShrtName,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_link_X_already_exists, - Lnk->ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_link_X_already_exists, + Lnk->ShrtName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (Lnk_CheckIfLinkNameExists ("FullName",Lnk->FullName,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_link_X_already_exists, - Lnk->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_link_X_already_exists, + Lnk->FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (!Lnk->WWW[0]) @@ -856,7 +864,8 @@ static void Lnk_CreateLink (struct Link *Lnk) DB_QueryINSERT (Query,"can not create institutional link"); /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_link_X, - Lnk->ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_link_X, + Lnk->ShrtName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_logo.c b/swad_logo.c index 87aaa22d..a7d04982 100644 --- a/swad_logo.c +++ b/swad_logo.c @@ -288,8 +288,9 @@ void Log_RequestLogo (Sco_Scope_t Scope) NULL,Box_NOT_CLOSABLE); /***** Write help message *****/ - sprintf (Gbl.Alert.Txt,Txt_You_can_send_a_file_with_an_image_in_PNG_format_transparent_background_and_size_X_Y, - 64,64); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_send_a_file_with_an_image_in_PNG_format_transparent_background_and_size_X_Y, + 64,64); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Upload logo *****/ @@ -377,7 +378,9 @@ void Log_ReceiveLogo (Sco_Scope_t Scope) WrongType = true; if (WrongType) { - sprintf (Gbl.Alert.Txt,Txt_The_file_is_not_X,"png"); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_file_is_not_X, + "png"); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else diff --git a/swad_mail.c b/swad_mail.c index 92cf467c..65abd548 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -376,12 +376,13 @@ void Mai_WriteWarningEmailNotifications (void) Tab_Tab_t TabMyAccount = Act_GetTab (ActFrmMyAcc ); Tab_Tab_t TabMailDomains = Act_GetTab (ActSeeMai); - sprintf (Gbl.Alert.Txt,Txt_You_can_only_receive_email_notifications_if_, - Txt_TABS_TXT [TabMyAccount ], - Txt_MENU_TITLE[TabMyAccount ][Act_GetIndexInMenu (ActFrmMyAcc)], - Txt_TABS_TXT [TabMailDomains], - Txt_MENU_TITLE[TabMailDomains][Act_GetIndexInMenu (ActSeeMai )], - Txt_Domains); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_only_receive_email_notifications_if_, + Txt_TABS_TXT [TabMyAccount ], + Txt_MENU_TITLE[TabMyAccount ][Act_GetIndexInMenu (ActFrmMyAcc)], + Txt_TABS_TXT [TabMailDomains], + Txt_MENU_TITLE[TabMailDomains][Act_GetIndexInMenu (ActSeeMai )], + Txt_Domains); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } @@ -559,8 +560,9 @@ void Mai_RemoveMailDomain (void) DB_QueryDELETE (Query,"can not remove a mail domain"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Email_domain_X_removed, - Mai.Domain); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Email_domain_X_removed, + Mai.Domain); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show the form again *****/ @@ -635,8 +637,9 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName) { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_email_domain_X_empty, - CurrentMaiName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_email_domain_X_empty, + CurrentMaiName); } else { @@ -648,8 +651,9 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName) { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_email_domain_X_already_exists, - NewMaiName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_domain_X_already_exists, + NewMaiName); } else { @@ -659,16 +663,18 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName) /* Write message to show the change made */ Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_email_domain_X_has_been_renamed_as_Y, - CurrentMaiName,NewMaiName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_domain_X_has_been_renamed_as_Y, + CurrentMaiName,NewMaiName); } } else // The same name { Gbl.Alert.Type = Ale_INFO; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_email_domain_X_has_not_changed, - CurrentMaiName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_domain_X_has_not_changed, + CurrentMaiName); } } @@ -821,14 +827,16 @@ void Mai_RecFormNewMailDomain (void) /***** If name of mail was in database... *****/ if (Mai_CheckIfMailDomainNameExists ("Domain",Mai->Domain,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_email_domain_X_already_exists, - Mai->Domain); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_domain_X_already_exists, + Mai->Domain); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (Mai_CheckIfMailDomainNameExists ("Info",Mai->Info,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_email_domain_X_already_exists, - Mai->Info); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_domain_X_already_exists, + Mai->Info); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // Add new mail to database @@ -861,8 +869,9 @@ static void Mai_CreateMailDomain (struct Mail *Mai) DB_QueryINSERT (Query,"can not create mail domain"); /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_email_domain_X, - Mai->Domain); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_email_domain_X, + Mai->Domain); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -1462,7 +1471,9 @@ static void Mai_RemoveEmail (struct UsrData *UsrDat) /***** Show message *****/ Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_Email_X_removed,Email); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Email_X_removed, + Email); /***** Update list of emails *****/ Mai_GetEmailFromUsrCod (UsrDat); @@ -1558,8 +1569,9 @@ static void Mai_NewUsrEmail (struct UsrData *UsrDat,bool ItsMe) { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_email_address_X_matches_one_previously_registered, - NewEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_address_X_matches_one_previously_registered, + NewEmail); } else { @@ -1568,8 +1580,9 @@ static void Mai_NewUsrEmail (struct UsrData *UsrDat,bool ItsMe) /***** Email updated sucessfully *****/ Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_email_address_X_has_been_registered_successfully, - NewEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_address_X_has_been_registered_successfully, + NewEmail); /***** Update list of emails *****/ Mai_GetEmailFromUsrCod (UsrDat); @@ -1583,8 +1596,9 @@ static void Mai_NewUsrEmail (struct UsrData *UsrDat,bool ItsMe) { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_email_address_X_had_been_registered_by_another_user, - NewEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_address_X_had_been_registered_by_another_user, + NewEmail); } } } @@ -1592,8 +1606,9 @@ static void Mai_NewUsrEmail (struct UsrData *UsrDat,bool ItsMe) { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_email_address_entered_X_is_not_valid, - NewEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_address_entered_X_is_not_valid, + NewEmail); } } else @@ -1731,8 +1746,9 @@ bool Mai_SendMailMsgToConfirmEmail (void) Gbl.Usrs.Me.ConfirmEmailJustSent = true; Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_A_message_has_been_sent_to_email_address_X_to_confirm_that_address, - Gbl.Usrs.Me.UsrDat.Email); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_A_message_has_been_sent_to_email_address_X_to_confirm_that_address, + Gbl.Usrs.Me.UsrDat.Email); return true; case 1: Gbl.Alert.Type = Ale_ERROR; @@ -1743,9 +1759,10 @@ bool Mai_SendMailMsgToConfirmEmail (void) default: Gbl.Alert.Type = Ale_ERROR; Gbl.Alert.Section = Mai_EMAIL_SECTION_ID; - sprintf (Gbl.Alert.Txt,"Internal error: an email message has not been sent successfully." - " Error code returned by the script: %d", - ReturnCode); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Internal error: an email message has not been sent successfully." + " Error code returned by the script: %d", + ReturnCode); return false; } } @@ -1841,8 +1858,9 @@ void Mai_ConfirmEmail (void) /***** Confirm email *****/ if (Confirmed) - sprintf (Gbl.Alert.Txt,Txt_Email_X_has_already_been_confirmed_before, - Email); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Email_X_has_already_been_confirmed_before, + Email); else { sprintf (Query,"UPDATE usr_emails SET Confirmed='Y'" @@ -1851,7 +1869,9 @@ void Mai_ConfirmEmail (void) UsrCod,Email); DB_QueryUPDATE (Query,"can not confirm email"); - sprintf (Gbl.Alert.Txt,Txt_The_email_X_has_been_confirmed,Email); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_email_X_has_been_confirmed, + Email); } Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_mark.c b/swad_mark.c index 4d555cac..58873be5 100644 --- a/swad_mark.c +++ b/swad_mark.c @@ -281,8 +281,9 @@ static void Mrk_ChangeNumRowsHeaderOrFooter (Brw_HeadOrFoot_t HeaderOrFooter) DB_QueryUPDATE (Query,"can not update properties of marks"); /***** Write message of success *****/ - sprintf (Gbl.Alert.Txt,Txt_The_number_of_rows_is_now_X, - NumRows); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_number_of_rows_is_now_X, + NumRows); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -399,8 +400,9 @@ bool Mrk_CheckFileOfMarks (const char *Path,struct MarksProperties *Marks) } /* if (FileIsCorrect) - sprintf (Gbl.Alert.Txt,Txt_X_header_rows_Y_student_rows_and_Z_footer_rows_found, - Marks->Header,NumRowsStds,Marks->Footer); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_header_rows_Y_student_rows_and_Z_footer_rows_found, + Marks->Header,NumRowsStds,Marks->Footer); */ return FileIsCorrect; @@ -599,8 +601,9 @@ static bool Mrk_GetUsrMarks (FILE *FileUsrMarks,struct UsrData *UsrDat, /***** User's ID not found in table *****/ fclose (FileAllMarks); - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_is_not_found_in_the_file_of_marks, - UsrDat->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_is_not_found_in_the_file_of_marks, + UsrDat->FullName); return false; } diff --git a/swad_message.c b/swad_message.c index 68dda994..f876ba67 100644 --- a/swad_message.c +++ b/swad_message.c @@ -750,7 +750,9 @@ void Msg_RecMsgFromUsr (void) if (RecipientHasBannedMe) { /***** Show an alert indicating that the message has not been sent successfully *****/ - sprintf (Gbl.Alert.Txt,Txt_message_not_sent_to_X,UsrDstData.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_message_not_sent_to_X, + UsrDstData.FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -786,9 +788,10 @@ void Msg_RecMsgFromUsr (void) 0)); /***** Show an alert indicating that the message has been sent successfully *****/ - sprintf (Gbl.Alert.Txt,NotifyByEmail ? Txt_message_sent_to_X_notified_by_email : - Txt_message_sent_to_X_not_notified_by_email, - UsrDstData.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + NotifyByEmail ? Txt_message_sent_to_X_notified_by_email : + Txt_message_sent_to_X_not_notified_by_email, + UsrDstData.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Increment number of recipients *****/ @@ -826,8 +829,9 @@ void Msg_RecMsgFromUsr (void) Ale_ShowAlert (Ale_SUCCESS,Txt_The_message_has_been_sent_to_1_recipient); else { - sprintf (Gbl.Alert.Txt,Txt_The_message_has_been_sent_to_X_recipients, - (unsigned) NumRecipients); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_message_has_been_sent_to_X_recipients, + (unsigned) NumRecipients); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } @@ -837,8 +841,9 @@ void Msg_RecMsgFromUsr (void) /***** Show alert about errors on sending message *****/ if (NumErrors > 1) { - sprintf (Gbl.Alert.Txt,Txt_There_have_been_X_errors_in_sending_the_message, - (unsigned) NumErrors); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_have_been_X_errors_in_sending_the_message, + (unsigned) NumErrors); Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt); } } @@ -867,28 +872,32 @@ void Msg_ReqDelAllRecMsgs (void) if (Gbl.Msg.FilterContent[0]) { if (Gbl.Msg.ShowOnlyUnreadMsgs) - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_delete_the_unread_messages_received_from_USER_X_from_COURSE_Y_related_to_CONTENT_Z, - Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : - Txt_any_user, - Gbl.Msg.FilterCrsShrtName,Gbl.Msg.FilterContent); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_delete_the_unread_messages_received_from_USER_X_from_COURSE_Y_related_to_CONTENT_Z, + Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : + Txt_any_user, + Gbl.Msg.FilterCrsShrtName,Gbl.Msg.FilterContent); else - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_delete_all_messages_received_from_USER_X_from_COURSE_Y_related_to_CONTENT_Z, - Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : - Txt_any_user, - Gbl.Msg.FilterCrsShrtName,Gbl.Msg.FilterContent); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_delete_all_messages_received_from_USER_X_from_COURSE_Y_related_to_CONTENT_Z, + Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : + Txt_any_user, + Gbl.Msg.FilterCrsShrtName,Gbl.Msg.FilterContent); } else { if (Gbl.Msg.ShowOnlyUnreadMsgs) - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_delete_the_unread_messages_received_from_USER_X_from_COURSE_Y, - Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : - Txt_any_user, - Gbl.Msg.FilterCrsShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_delete_the_unread_messages_received_from_USER_X_from_COURSE_Y, + Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : + Txt_any_user, + Gbl.Msg.FilterCrsShrtName); else - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_delete_all_messages_received_from_USER_X_from_COURSE_Y, - Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : - Txt_any_user, - Gbl.Msg.FilterCrsShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_delete_all_messages_received_from_USER_X_from_COURSE_Y, + Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : + Txt_any_user, + Gbl.Msg.FilterCrsShrtName); } Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt); @@ -921,15 +930,17 @@ void Msg_ReqDelAllSntMsgs (void) /***** Show question and button to remove messages received *****/ /* Start alert */ if (Gbl.Msg.FilterContent[0]) - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_delete_all_messages_sent_to_USER_X_from_COURSE_Y_related_to_CONTENT_Z, - Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : - Txt_any_user, - Gbl.Msg.FilterCrsShrtName,Gbl.Msg.FilterContent); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_delete_all_messages_sent_to_USER_X_from_COURSE_Y_related_to_CONTENT_Z, + Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : + Txt_any_user, + Gbl.Msg.FilterCrsShrtName,Gbl.Msg.FilterContent); else - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_delete_all_messages_sent_to_USER_X_from_COURSE_Y, - Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : - Txt_any_user, - Gbl.Msg.FilterCrsShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_delete_all_messages_sent_to_USER_X_from_COURSE_Y, + Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo : + Txt_any_user, + Gbl.Msg.FilterCrsShrtName); Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt); /* Show sent messages again */ @@ -998,8 +1009,9 @@ static void Msg_ShowNumMsgsDeleted (unsigned NumMsgs) Ale_ShowAlert (Ale_SUCCESS,Txt_One_message_has_been_deleted); else { - sprintf (Gbl.Alert.Txt,Txt_X_messages_have_been_deleted, - NumMsgs); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_messages_have_been_deleted, + NumMsgs); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } @@ -3645,8 +3657,9 @@ void Msg_BanSenderWhenShowingMsgs (void) DB_QueryREPLACE (Query,"can not ban sender"); /***** Show alert with the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_From_this_time_you_will_not_receive_messages_from_X, - Gbl.Usrs.Other.UsrDat.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_From_this_time_you_will_not_receive_messages_from_X, + Gbl.Usrs.Other.UsrDat.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /**** Show received messages again */ @@ -3702,8 +3715,9 @@ static void Msg_UnbanSender (void) DB_QueryDELETE (Query,"can not ban sender"); /***** Show alert with the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_From_this_time_you_can_receive_messages_from_X, - Gbl.Usrs.Other.UsrDat.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_From_this_time_you_can_receive_messages_from_X, + Gbl.Usrs.Other.UsrDat.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_nickname.c b/swad_nickname.c index c4f85911..b4fb956e 100644 --- a/swad_nickname.c +++ b/swad_nickname.c @@ -441,7 +441,9 @@ void Nck_RemoveMyNick (void) /***** Show message *****/ Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = Nck_NICKNAME_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_Nickname_X_removed,NicknameWithoutArroba); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Nickname_X_removed, + NicknameWithoutArroba); } else { @@ -480,7 +482,9 @@ void Nck_RemoveOtherUsrNick (void) /***** Show message *****/ Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = Nck_NICKNAME_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_Nickname_X_removed,NicknameWithoutArroba); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Nickname_X_removed, + NicknameWithoutArroba); /***** Show user's account again *****/ Acc_ShowFormChgOtherUsrAccount (); @@ -575,8 +579,9 @@ static void Nck_UpdateUsrNick (struct UsrData *UsrDat) { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = Nck_NICKNAME_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_nickname_X_matches_the_one_you_had_previously_registered, - NewNicknameWithoutArroba); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_nickname_X_matches_the_one_you_had_previously_registered, + NewNicknameWithoutArroba); } else if (strcasecmp (UsrDat->Nickname,NewNicknameWithoutArroba)) // User's nickname does not match, not even case insensitive, the new nickname { @@ -594,8 +599,9 @@ static void Nck_UpdateUsrNick (struct UsrData *UsrDat) { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = Nck_NICKNAME_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_nickname_X_had_been_registered_by_another_user, - NewNicknameWithoutArroba); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_nickname_X_had_been_registered_by_another_user, + NewNicknameWithoutArroba); } } } @@ -609,18 +615,20 @@ static void Nck_UpdateUsrNick (struct UsrData *UsrDat) Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Section = Nck_NICKNAME_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_nickname_X_has_been_registered_successfully, - NewNicknameWithoutArroba); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_nickname_X_has_been_registered_successfully, + NewNicknameWithoutArroba); } } else // New nickname is not valid { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = Nck_NICKNAME_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_nickname_entered_X_is_not_valid_, - NewNicknameWithArroba, - Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA, - Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_nickname_entered_X_is_not_valid_, + NewNicknameWithArroba, + Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA, + Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA); } } diff --git a/swad_notice.c b/swad_notice.c index d6109c70..b2a897ee 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -95,8 +95,9 @@ void Not_ShowFormNotice (void) extern const char *Txt_Create_notice; /***** Help message *****/ - sprintf (Gbl.Alert.Txt,Txt_The_notice_will_appear_as_a_yellow_note_, - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_notice_will_appear_as_a_yellow_note_, + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Start form *****/ diff --git a/swad_parameter.c b/swad_parameter.c index 26e10dc7..728125c5 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -555,9 +555,10 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, /* Check if there is space to copy separator */ if (BytesAlreadyCopied + 1 > MaxBytes) { - sprintf (Gbl.Alert.Txt,"Multiple parameter %s too large," - " it exceed the maximum allowed size (%lu bytes).", - ParamName,(unsigned long) MaxBytes); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Multiple parameter %s too large," + " it exceed the maximum allowed size (%lu bytes).", + ParamName,(unsigned long) MaxBytes); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } @@ -573,9 +574,10 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, /* Check if there is space to copy the parameter value */ if (BytesAlreadyCopied + Param->Value.Length > MaxBytes) { - sprintf (Gbl.Alert.Txt,"Parameter %s too large," - " it exceed the maximum allowed size (%lu bytes).", - ParamName,(unsigned long) MaxBytes); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Parameter %s too large," + " it exceed the maximum allowed size (%lu bytes).", + ParamName,(unsigned long) MaxBytes); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } diff --git a/swad_password.c b/swad_password.c index c24c5043..98c6d3c8 100644 --- a/swad_password.c +++ b/swad_password.c @@ -403,9 +403,10 @@ void Pwd_ChkIdLoginAndSendNewPwd (void) Ale_ShowAlert (Ale_WARNING,Txt_There_was_a_problem_sending_an_email_automatically); break; default: - sprintf (Gbl.Alert.Txt,"Internal error: an email message has not been sent successfully." - " Error code returned by the script: %d", - ReturnCode); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Internal error: an email message has not been sent successfully." + " Error code returned by the script: %d", + ReturnCode); Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt); break; } @@ -418,8 +419,9 @@ void Pwd_ChkIdLoginAndSendNewPwd (void) /***** Help message *****/ // TODO: This message allows to know if a ID exists in database (when no unique). // This should be hidden! - sprintf (Gbl.Alert.Txt,Txt_There_are_more_than_one_user_with_the_ID_X_Please_type_a_nick_or_email, - Gbl.Usrs.Me.UsrIdLogin); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_are_more_than_one_user_with_the_ID_X_Please_type_a_nick_or_email, + Gbl.Usrs.Me.UsrIdLogin); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); Pwd_ShowFormSendNewPwd (); @@ -629,8 +631,9 @@ bool Pwd_FastCheckIfPasswordSeemsGood (const char *PlainPassword) { Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Section = Pwd_PASSWORD_SECTION_ID; - sprintf (Gbl.Alert.Txt,Txt_The_password_must_be_at_least_X_characters, - Pwd_MIN_CHARS_PLAIN_PASSWORD); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_password_must_be_at_least_X_characters, + Pwd_MIN_CHARS_PLAIN_PASSWORD); return false; } @@ -729,8 +732,9 @@ void Pwd_ShowFormChgMyPwd (void) /***** Help message *****/ fprintf (Gbl.F.Out,"" ""); - sprintf (Gbl.Alert.Txt,Txt_Your_password_must_be_at_least_X_characters_and_can_not_contain_spaces_, - Pwd_MIN_CHARS_PLAIN_PASSWORD); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Your_password_must_be_at_least_X_characters_and_can_not_contain_spaces_, + Pwd_MIN_CHARS_PLAIN_PASSWORD); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); fprintf (Gbl.F.Out,"" ""); @@ -760,7 +764,9 @@ void Pwd_PutFormToGetNewPasswordOnce (void) extern const char *Txt_Password; extern const char *Txt_HELP_password; - sprintf (Gbl.Alert.Txt,Txt_HELP_password,Pwd_MIN_CHARS_PLAIN_PASSWORD); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_HELP_password, + Pwd_MIN_CHARS_PLAIN_PASSWORD); fprintf (Gbl.F.Out,"" "" "" @@ -788,7 +794,9 @@ void Pwd_PutFormToGetNewPasswordTwice (void) extern const char *Txt_HELP_password; extern const char *Txt_Retype_new_password; - sprintf (Gbl.Alert.Txt,Txt_HELP_password,Pwd_MIN_CHARS_PLAIN_PASSWORD); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_HELP_password, + Pwd_MIN_CHARS_PLAIN_PASSWORD); fprintf (Gbl.F.Out,"" "" "" diff --git a/swad_photo.c b/swad_photo.c index adb0e310..2aa82caa 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -501,8 +501,9 @@ void Pho_ReqRemoveUsrPhoto (void) { /***** Show question and button to remove user's photo *****/ /* Start alert */ - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_photo_of_X, - Gbl.Usrs.Other.UsrDat.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_photo_of_X, + Gbl.Usrs.Other.UsrDat.FullName); Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt); /* Show current photo */ @@ -644,7 +645,9 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr WrongType = true; if (WrongType) { - sprintf (Gbl.Alert.Txt,Txt_The_file_is_not_X,"jpg"); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_file_is_not_X, + "jpg"); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); return false; } @@ -726,9 +729,10 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr NumFacesTotal = NumFacesGreen = NumFacesRed = 0; break; default: // Error - sprintf (Gbl.Alert.Txt,"Photo could not be processed successfully.
    " - "Error code returned by the program of processing: %d", - ReturnCode); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Photo could not be processed successfully.
    " + "Error code returned by the program of processing: %d", + ReturnCode); Lay_ShowErrorAndExit (Gbl.Alert.Txt); break; } @@ -760,24 +764,28 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr if (NumFacesRed == 0) { Gbl.Alert.Type = Ale_SUCCESS; - sprintf (Gbl.Alert.Txt,Txt_X_faces_marked_in_green_have_been_detected_, - NumFacesGreen); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_faces_marked_in_green_have_been_detected_, + NumFacesGreen); } else if (NumFacesGreen == 0) { Gbl.Alert.Type = Ale_WARNING; - sprintf (Gbl.Alert.Txt,Txt_X_faces_marked_in_red_have_been_detected_, - NumFacesRed); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_faces_marked_in_red_have_been_detected_, + NumFacesRed); } else // NumFacesGreen > 0 { Gbl.Alert.Type = Ale_SUCCESS; if (NumFacesGreen == 1) - sprintf (Gbl.Alert.Txt,Txt_X_faces_have_been_detected_in_front_position_1_Z_, - NumFacesTotal,NumFacesRed); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_faces_have_been_detected_in_front_position_1_Z_, + NumFacesTotal,NumFacesRed); else - sprintf (Gbl.Alert.Txt,Txt_X_faces_have_been_detected_in_front_position_Y_Z_, - NumFacesTotal,NumFacesGreen,NumFacesRed); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_X_faces_have_been_detected_in_front_position_Y_Z_, + NumFacesTotal,NumFacesGreen,NumFacesRed); } } diff --git a/swad_place.c b/swad_place.c index e0685b9f..2905b57c 100644 --- a/swad_place.c +++ b/swad_place.c @@ -577,8 +577,9 @@ void Plc_RemovePlace (void) DB_QueryDELETE (Query,"can not remove a place"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Place_X_removed, - Plc.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Place_X_removed, + Plc.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -652,8 +653,9 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Check if new name is empty *****/ if (!NewPlcName[0]) { - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_place_X_empty, - CurrentPlcName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_place_X_empty, + CurrentPlcName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -664,8 +666,9 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName) /***** If place was in database... *****/ if (Plc_CheckIfPlaceNameExists (ParamName,NewPlcName,Plc->PlcCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_place_X_already_exists, - NewPlcName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_place_X_already_exists, + NewPlcName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -674,15 +677,17 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName) Plc_UpdatePlcNameDB (Plc->PlcCod,FieldName,NewPlcName); /* Write message to show the change made */ - sprintf (Gbl.Alert.Txt,Txt_The_place_X_has_been_renamed_as_Y, - CurrentPlcName,NewPlcName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_place_X_has_been_renamed_as_Y, + CurrentPlcName,NewPlcName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } else // The same name { - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_place_X_has_not_changed, - CurrentPlcName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_place_X_has_not_changed, + CurrentPlcName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -839,14 +844,16 @@ void Plc_RecFormNewPlace (void) /***** If name of place was in database... *****/ if (Plc_CheckIfPlaceNameExists ("ShortName",Plc->ShrtName,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_place_X_already_exists, - Plc->ShrtName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_place_X_already_exists, + Plc->ShrtName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else if (Plc_CheckIfPlaceNameExists ("FullName",Plc->FullName,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_place_X_already_exists, - Plc->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_place_X_already_exists, + Plc->FullName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // Add new place to database @@ -879,7 +886,8 @@ static void Plc_CreatePlace (struct Place *Plc) DB_QueryINSERT (Query,"can not create place"); /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_place_X, - Plc->FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_place_X, + Plc->FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_plugin.c b/swad_plugin.c index ab4411e9..af644840 100644 --- a/swad_plugin.c +++ b/swad_plugin.c @@ -501,8 +501,9 @@ void Plg_RemovePlugin (void) DB_QueryDELETE (Query,"can not remove a plugin"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Plugin_X_removed, - Plg.Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Plugin_X_removed, + Plg.Name); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show the form again *****/ @@ -539,8 +540,9 @@ void Plg_RenamePlugin (void) /***** Check if new name is empty *****/ if (!NewPlgName[0]) { - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_plugin_X_empty, - Plg->Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_plugin_X_empty, + Plg->Name); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -551,8 +553,9 @@ void Plg_RenamePlugin (void) /***** If plugin was in database... *****/ if (Plg_CheckIfPluginNameExists (NewPlgName,Plg->PlgCod)) { - sprintf (Gbl.Alert.Txt,Txt_The_plugin_X_already_exists, - NewPlgName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_plugin_X_already_exists, + NewPlgName); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else @@ -563,15 +566,17 @@ void Plg_RenamePlugin (void) DB_QueryUPDATE (Query,"can not update the name of a plugin"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_plugin_X_has_been_renamed_as_Y, - Plg->Name,NewPlgName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_plugin_X_has_been_renamed_as_Y, + Plg->Name,NewPlgName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } else // The same name { - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_plugin_X_has_not_changed, - Plg->Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_plugin_X_has_not_changed, + Plg->Name); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -628,8 +633,9 @@ void Plg_ChangePlgDescription (void) DB_QueryUPDATE (Query,"can not update the description of a plugin"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_description_is_X, - NewDescription); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_description_is_X, + NewDescription); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -672,8 +678,9 @@ void Plg_ChangePlgLogo (void) DB_QueryUPDATE (Query,"can not update the logo of a plugin"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_logo_is_X, - NewLogo); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_logo_is_X, + NewLogo); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -716,8 +723,9 @@ void Plg_ChangePlgAppKey (void) DB_QueryUPDATE (Query,"can not update the application key of a plugin"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_logo_is_X, // TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - NewAppKey); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_logo_is_X, // TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + NewAppKey); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -760,8 +768,9 @@ void Plg_ChangePlgURL (void) DB_QueryUPDATE (Query,"can not update the URL of a plugin"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_URL_is_X, - NewURL); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_URL_is_X, + NewURL); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -804,8 +813,9 @@ void Plg_ChangePlgIP (void) DB_QueryUPDATE (Query,"can not update the IP address of a plugin"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_new_IP_address_is_X, - NewIP); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_new_IP_address_is_X, + NewIP); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -1013,8 +1023,9 @@ void Plg_RecFormNewPlg (void) /***** If name of plugin was in database... *****/ if (Plg_CheckIfPluginNameExists (Plg->Name,-1L)) { - sprintf (Gbl.Alert.Txt,Txt_The_plugin_X_already_exists, - Plg->Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_plugin_X_already_exists, + Plg->Name); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // Add new plugin to database @@ -1053,8 +1064,9 @@ static void Plg_CreatePlugin (struct Plugin *Plg) DB_QueryINSERT (Query,"can not create plugin"); /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_plugin_X, - Plg->Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_plugin_X, + Plg->Name); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_project.c b/swad_project.c index 1a36b301..266759ea 100644 --- a/swad_project.c +++ b/swad_project.c @@ -1981,9 +1981,10 @@ static void Prj_AddUsrToProject (Prj_RoleInProject_t RoleInProject) Prj_FlushCacheMyRoleInProject (); /* Show success alert */ - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_enroled_as_a_Y_in_the_project, - Gbl.Usrs.Other.UsrDat.FullName, - Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_enroled_as_a_Y_in_the_project, + Gbl.Usrs.Other.UsrDat.FullName, + Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject]); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -2054,11 +2055,11 @@ static void Prj_ReqRemUsrFromPrj (Prj_RoleInProject_t RoleInProject) /***** Show question and button to remove user as administrator *****/ /* Start alert */ - sprintf (Gbl.Alert.Txt, - ItsMe ? Txt_Do_you_really_want_to_be_removed_as_a_X_from_the_project_Y : - Txt_Do_you_really_want_to_remove_the_following_user_as_a_X_from_the_project_Y, - Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject], - Prj.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + ItsMe ? Txt_Do_you_really_want_to_be_removed_as_a_X_from_the_project_Y : + Txt_Do_you_really_want_to_remove_the_following_user_as_a_X_from_the_project_Y, + Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject], + Prj.Title); Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt); /* Show user's record */ @@ -2146,10 +2147,11 @@ static void Prj_RemUsrFromPrj (Prj_RoleInProject_t RoleInProject) Prj_FlushCacheMyRoleInProject (); /***** Show success alert *****/ - sprintf (Gbl.Alert.Txt,Txt_THE_USER_X_has_been_removed_as_a_Y_from_the_project_Z, - Gbl.Usrs.Other.UsrDat.FullName, - Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject], - Prj.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_THE_USER_X_has_been_removed_as_a_Y_from_the_project_Z, + Gbl.Usrs.Other.UsrDat.FullName, + Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject], + Prj.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -2731,8 +2733,9 @@ void Prj_ReqRemProject (void) { /***** Show question and button to remove the project *****/ Gbl.Prjs.PrjCod = Prj.PrjCod; - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_project_X, - Prj.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_project_X, + Prj.Title); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, ActRemPrj,NULL,NULL,Prj_PutCurrentParams, Btn_REMOVE_BUTTON,Txt_Remove_project); @@ -2797,8 +2800,9 @@ void Prj_RemoveProject (void) Fil_RemoveTree (PathRelPrj); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Project_X_removed, - Prj.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Project_X_removed, + Prj.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -2841,8 +2845,9 @@ void Prj_HideProject (void) DB_QueryUPDATE (Query,"can not hide project"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Project_X_is_now_hidden, - Prj.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Project_X_is_now_hidden, + Prj.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -2885,8 +2890,9 @@ void Prj_ShowProject (void) DB_QueryUPDATE (Query,"can not show project"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Project_X_is_now_visible, - Prj.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Project_X_is_now_visible, + Prj.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else @@ -3305,7 +3311,9 @@ void Prj_RecFormProject (void) Prj_CreateProject (&Prj); // Add new project to database /* Write success message */ - sprintf (Gbl.Alert.Txt,Txt_Created_new_project_X,Prj.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_project_X, + Prj.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } else if (NewProjectIsCorrect) diff --git a/swad_record.c b/swad_record.c index 80804166..e6c1b594 100644 --- a/swad_record.c +++ b/swad_record.c @@ -202,8 +202,9 @@ void Rec_ReqEditRecordFields (void) } else // No fields of records found for current course in the database { - sprintf (Gbl.Alert.Txt,Txt_There_are_no_record_fields_in_the_course_X, - Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_are_no_record_fields_in_the_course_X, + Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } @@ -482,8 +483,9 @@ void Rec_ReceiveFormField (void) /***** If the field already was in the database... *****/ if (Rec_CheckIfRecordFieldIsRepeated (Gbl.CurrentCrs.Records.Field.Name)) { - sprintf (Gbl.Alert.Txt,Txt_The_record_field_X_already_exists, - Gbl.CurrentCrs.Records.Field.Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_record_field_X_already_exists, + Gbl.CurrentCrs.Records.Field.Name); Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt); } else // Add the new field to the database @@ -586,8 +588,9 @@ void Rec_CreateRecordField (void) DB_QueryINSERT (Query,"can not create field of record"); /***** Write message of success *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_record_field_X, - Gbl.CurrentCrs.Records.Field.Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_record_field_X, + Gbl.CurrentCrs.Records.Field.Name); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -655,8 +658,9 @@ void Rec_AskConfirmRemFieldWithRecords (unsigned NumRecords) &Gbl.CurrentCrs.Records.Field.Visibility); /***** Show question and button to remove my photo *****/ - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_X, - Gbl.CurrentCrs.Records.Field.Name,Gbl.CurrentCrs.Crs.FullName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_X, + Gbl.CurrentCrs.Records.Field.Name,Gbl.CurrentCrs.Crs.FullName); if (NumRecords == 1) Str_Concat (Gbl.Alert.Txt,Txt_this_field_is_filled_in_the_record_of_one_student, Ale_MAX_BYTES_ALERT); @@ -701,8 +705,9 @@ void Rec_RemoveFieldFromDB (void) DB_QueryDELETE (Query,"can not remove field of record"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Record_field_X_removed, - Gbl.CurrentCrs.Records.Field.Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Record_field_X_removed, + Gbl.CurrentCrs.Records.Field.Name); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show the form again *****/ @@ -807,8 +812,9 @@ void Rec_RenameField (void) /***** Check if new name is empty *****/ if (!NewFieldName[0]) { - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_field_X_empty, - Gbl.CurrentCrs.Records.Field.Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_field_X_empty, + Gbl.CurrentCrs.Records.Field.Name); Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt); } else @@ -820,8 +826,9 @@ void Rec_RenameField (void) /***** If the group ya estaba in the database... *****/ if (Rec_CheckIfRecordFieldIsRepeated (NewFieldName)) { - sprintf (Gbl.Alert.Txt,Txt_The_record_field_X_already_exists, - NewFieldName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_record_field_X_already_exists, + NewFieldName); Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt); } else @@ -833,15 +840,17 @@ void Rec_RenameField (void) DB_QueryUPDATE (Query,"can not update name of field of record"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_record_field_X_has_been_renamed_as_Y, - Gbl.CurrentCrs.Records.Field.Name,NewFieldName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_record_field_X_has_been_renamed_as_Y, + Gbl.CurrentCrs.Records.Field.Name,NewFieldName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } else // The same name { - sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_field_X_has_not_changed, - NewFieldName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_name_of_the_field_X_has_not_changed, + NewFieldName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } } @@ -882,8 +891,9 @@ void Rec_ChangeLinesField (void) (this happens when return is pressed without changes) *****/ if (Gbl.CurrentCrs.Records.Field.NumLines == NewNumLines) { - sprintf (Gbl.Alert.Txt,Txt_The_number_of_editing_lines_in_the_record_field_X_has_not_changed, - Gbl.CurrentCrs.Records.Field.Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_number_of_editing_lines_in_the_record_field_X_has_not_changed, + Gbl.CurrentCrs.Records.Field.Name); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } else @@ -895,8 +905,9 @@ void Rec_ChangeLinesField (void) DB_QueryUPDATE (Query,"can not update the number of lines of a field of record"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_From_now_on_the_number_of_editing_lines_of_the_field_X_is_Y, - Gbl.CurrentCrs.Records.Field.Name,NewNumLines); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_From_now_on_the_number_of_editing_lines_of_the_field_X_is_Y, + Gbl.CurrentCrs.Records.Field.Name,NewNumLines); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -935,8 +946,9 @@ void Rec_ChangeVisibilityField (void) (this happens whe return is pressed without changes in the form) *****/ if (Gbl.CurrentCrs.Records.Field.Visibility == NewVisibility) { - sprintf (Gbl.Alert.Txt,Txt_The_visibility_of_the_record_field_X_has_not_changed, - Gbl.CurrentCrs.Records.Field.Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_visibility_of_the_record_field_X_has_not_changed, + Gbl.CurrentCrs.Records.Field.Name); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } else @@ -948,8 +960,9 @@ void Rec_ChangeVisibilityField (void) DB_QueryUPDATE (Query,"can not update the visibility of a field of record"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_RECORD_FIELD_VISIBILITY_MSG[NewVisibility], - Gbl.CurrentCrs.Records.Field.Name); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_RECORD_FIELD_VISIBILITY_MSG[NewVisibility], + Gbl.CurrentCrs.Records.Field.Name); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } diff --git a/swad_session.c b/swad_session.c index 7fbefc8e..aee201eb 100644 --- a/swad_session.c +++ b/swad_session.c @@ -485,9 +485,10 @@ unsigned Ses_GetHiddenParFromDB (Act_Action_t NextAction, if (ParameterIsTooBig) { - sprintf (Gbl.Alert.Txt,"Hidden parameter %s too large," - " it exceed the maximum allowed size (%lu bytes).", - ParamName,(unsigned long) MaxBytes); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Hidden parameter %s too large," + " it exceed the maximum allowed size (%lu bytes).", + ParamName,(unsigned long) MaxBytes); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } diff --git a/swad_statistic.c b/swad_statistic.c index bf16c619..1b241421 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -1041,8 +1041,9 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; if (!ICanQueryWholeRange && NumDays > Cfg_DAYS_IN_RECENT_LOG) { - sprintf (Gbl.Alert.Txt,Txt_The_date_range_must_be_less_than_or_equal_to_X_days, - Cfg_DAYS_IN_RECENT_LOG); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_date_range_must_be_less_than_or_equal_to_X_days, + Cfg_DAYS_IN_RECENT_LOG); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); // ...write warning message and show the form again return; } diff --git a/swad_string.c b/swad_string.c index c84bc467..1039138e 100644 --- a/swad_string.c +++ b/swad_string.c @@ -1038,7 +1038,9 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo, /* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM) { - sprintf (Gbl.Alert.Txt,"Str_ChangeFormat ("%s")",Str); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Str_ChangeFormat ("%s")", + Str); Lay_ShowAlert (Lay_INFO,Gbl.Alert.Txt); } */ @@ -2880,8 +2882,9 @@ void Str_Copy (char *Dst,const char *Src,size_t DstSize) /***** Check if buffer has enough space for source *****/ if (LengthSrc > DstSize) { - sprintf (Gbl.Alert.Txt,"Trying to copy %lu chars into a %lu-chars buffer.", - LengthSrc,DstSize); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Trying to copy %lu chars into a %lu-chars buffer.", + LengthSrc,DstSize); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } @@ -2903,8 +2906,9 @@ void Str_Concat (char *Dst,const char *Src,size_t DstSize) LengthDst = strlen (Dst); if (LengthDst > DstSize) { - sprintf (Gbl.Alert.Txt,"%lu-chars buffer has %lu chars!", - DstSize,LengthDst); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "%lu-chars buffer has %lu chars!", + DstSize,LengthDst); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } @@ -2914,8 +2918,9 @@ void Str_Concat (char *Dst,const char *Src,size_t DstSize) LengthSrc = strlen (Src); if (FreeSpace < LengthSrc) { - sprintf (Gbl.Alert.Txt,"Trying to concatenate %lu chars to a %lu-chars buffer with free space for only %lu chars!", - LengthSrc,DstSize,FreeSpace); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Trying to concatenate %lu chars to a %lu-chars buffer with free space for only %lu chars!", + LengthSrc,DstSize,FreeSpace); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } diff --git a/swad_survey.c b/swad_survey.c index 625b28c5..84f43d97 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -1508,8 +1508,9 @@ void Svy_AskRemSurvey (void) /***** Show question and button to remove survey *****/ Gbl.Svys.SvyCodToEdit = Svy.SvyCod; - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_survey_X, - Svy.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_survey_X, + Svy.Title); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, ActRemSvy,NULL,NULL,Svy_PutParams, Btn_REMOVE_BUTTON,Txt_Remove_survey); @@ -1571,8 +1572,9 @@ void Svy_RemoveSurvey (void) Ntf_MarkNotifAsRemoved (Ntf_EVENT_SURVEY,Svy.SvyCod); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Survey_X_removed, - Svy.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Survey_X_removed, + Svy.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show surveys again *****/ @@ -1607,8 +1609,9 @@ void Svy_AskResetSurvey (void) Lay_ShowErrorAndExit ("You can not reset this survey."); /***** Ask for confirmation of reset *****/ - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_reset_the_survey_X, - Svy.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_reset_the_survey_X, + Svy.Title); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); /***** Button of confirmation of reset *****/ @@ -1669,8 +1672,9 @@ void Svy_ResetSurvey (void) DB_QueryUPDATE (Query,"can not reset answers of a survey"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Survey_X_reset, - Svy.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Survey_X_reset, + Svy.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show surveys again *****/ @@ -1706,8 +1710,9 @@ void Svy_HideSurvey (void) DB_QueryUPDATE (Query,"can not hide survey"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Survey_X_is_now_hidden, - Svy.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Survey_X_is_now_hidden, + Svy.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show surveys again *****/ @@ -1743,8 +1748,9 @@ void Svy_UnhideSurvey (void) DB_QueryUPDATE (Query,"can not show survey"); /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_Survey_X_is_now_visible, - Svy.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Survey_X_is_now_visible, + Svy.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show surveys again *****/ @@ -2195,8 +2201,9 @@ void Svy_RecFormSurvey (void) if (Svy_CheckIfSimilarSurveyExists (&NewSvy)) { NewSurveyIsCorrect = false; - sprintf (Gbl.Alert.Txt,Txt_Already_existed_a_survey_with_the_title_X, - NewSvy.Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Already_existed_a_survey_with_the_title_X, + NewSvy.Title); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } } @@ -2281,8 +2288,9 @@ static void Svy_CreateSurvey (struct Survey *Svy,const char *Txt) Svy_CreateGrps (Svy->SvyCod); /***** Write success message *****/ - sprintf (Gbl.Alert.Txt,Txt_Created_new_survey_X, - Svy->Title); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Created_new_survey_X, + Svy->Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -2915,7 +2923,8 @@ static bool Svy_AllocateTextChoiceAnswer (struct SurveyQuestion *SvyQst, Svy_FreeTextChoiceAnswer (SvyQst,NumAns); if ((SvyQst->AnsChoice[NumAns].Text = (char *) malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL) { - sprintf (Gbl.Alert.Txt,"Not enough memory to store answer."); + Str_Copy (Gbl.Alert.Txt,"Not enough memory to store answer.", + Ale_MAX_BYTES_ALERT); return false; } SvyQst->AnsChoice[NumAns].Text[0] = '\0'; @@ -3586,8 +3595,9 @@ void Svy_RequestRemoveQst (void) /***** Show question and button to remove question *****/ Gbl.Svys.SvyCodToEdit = SvyCod; Gbl.Svys.SvyQstCodToEdit = SvyQst.QstCod; - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_question_X, - (unsigned long) (SvyQst.QstInd + 1)); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_question_X, + (unsigned long) (SvyQst.QstInd + 1)); Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, ActRemSvyQst,NULL,NULL,Svy_PutParamsRemoveOneQst, Btn_REMOVE_BUTTON,Txt_Remove_question); diff --git a/swad_test.c b/swad_test.c index 00a486d2..4b8648e6 100644 --- a/swad_test.c +++ b/swad_test.c @@ -584,13 +584,15 @@ void Tst_AssessTest (void) Tst_SetTstStatus (NumTst,Tst_STATUS_ASSESSED); break; case Tst_STATUS_ASSESSED: - sprintf (Gbl.Alert.Txt,Txt_The_test_X_has_already_been_assessed_previously, - NumTst); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_test_X_has_already_been_assessed_previously, + NumTst); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); break; case Tst_STATUS_ERROR: - sprintf (Gbl.Alert.Txt,Txt_There_was_an_error_in_assessing_the_test_X, - NumTst); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_was_an_error_in_assessing_the_test_X, + NumTst); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); break; } @@ -698,14 +700,15 @@ static bool Tst_CheckIfNextTstAllowed (void) if (NumSecondsFromNowToNextAccTst > 0) { /***** Write warning *****/ - sprintf (Gbl.Alert.Txt,"%s:
    ." - "", - Txt_You_can_not_take_a_new_test_until, - (long) TimeNextTestUTC, - (unsigned) Gbl.Prefs.DateFormat,Txt_Today); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "%s:
    ." + "", + Txt_You_can_not_take_a_new_test_until, + (long) TimeNextTestUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); return false; @@ -1552,8 +1555,9 @@ void Tst_RenameTag (void) /***** Check that the new tag is not empty *****/ if (!NewTagTxt[0]) // New tag empty { - sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_tag_X_empty, - OldTagTxt); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_can_not_leave_the_name_of_the_tag_X_empty, + OldTagTxt); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else // New tag not empty @@ -1564,8 +1568,9 @@ void Tst_RenameTag (void) // This happens when user press INTRO // without changing anything in the form. { - sprintf (Gbl.Alert.Txt,Txt_The_tag_X_has_not_changed, - NewTagTxt); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_tag_X_has_not_changed, + NewTagTxt); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } else // The old and the new tag @@ -1648,8 +1653,9 @@ void Tst_RenameTag (void) } /***** Write message to show the change made *****/ - sprintf (Gbl.Alert.Txt,Txt_The_tag_X_has_been_renamed_as_Y, - OldTagTxt,NewTagTxt); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_tag_X_has_been_renamed_as_Y, + OldTagTxt,NewTagTxt); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } } @@ -4760,8 +4766,9 @@ static bool Tst_GetParamsTst (Tst_ActionToDoWithQuestions_t ActionToDoWithQuesti if (Gbl.Test.NumQsts < Gbl.Test.Config.Min || Gbl.Test.NumQsts > Gbl.Test.Config.Max) { - sprintf (Gbl.Alert.Txt,Txt_The_number_of_questions_must_be_in_the_interval_X, - Gbl.Test.Config.Min,Gbl.Test.Config.Max); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_number_of_questions_must_be_in_the_interval_X, + Gbl.Test.Config.Min,Gbl.Test.Config.Max); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); Error = true; } @@ -5419,13 +5426,15 @@ int Tst_AllocateTextChoiceAnswer (unsigned NumOpt) if ((Gbl.Test.Answer.Options[NumOpt].Text = (char *) malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL) { - sprintf (Gbl.Alert.Txt,"Not enough memory to store answer."); + Str_Copy (Gbl.Alert.Txt,"Not enough memory to store answer.", + Ale_MAX_BYTES_ALERT); return 0; } if ((Gbl.Test.Answer.Options[NumOpt].Feedback = (char *) malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL) { - sprintf (Gbl.Alert.Txt,"Not enough memory to store feedback."); + Str_Copy (Gbl.Alert.Txt,"Not enough memory to store feedback.", + Ale_MAX_BYTES_ALERT); return 0; } @@ -6325,8 +6334,9 @@ void Tst_RequestRemoveQst (void) Lay_ShowErrorAndExit ("Wrong test parameters."); /***** Show question and button to remove question *****/ - sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_question_X, - (unsigned long) Gbl.Test.QstCod); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Do_you_really_want_to_remove_the_question_X, + (unsigned long) Gbl.Test.QstCod); if (EditingOnlyThisQst) Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt, ActRemTstQst,NULL,NULL, @@ -6448,10 +6458,10 @@ void Tst_ChangeShuffleQst (void) DB_QueryUPDATE (Query,"can not update the shuffle type of a question"); /***** Write message *****/ - sprintf (Gbl.Alert.Txt, - Shuffle ? Txt_The_answers_of_the_question_with_code_X_will_appear_shuffled : - Txt_The_answers_of_the_question_with_code_X_will_appear_without_shuffling, - Gbl.Test.QstCod); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Shuffle ? Txt_The_answers_of_the_question_with_code_X_will_appear_shuffled : + Txt_The_answers_of_the_question_with_code_X_will_appear_without_shuffling, + Gbl.Test.QstCod); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Continue editing questions *****/ diff --git a/swad_test_import.c b/swad_test_import.c index d6fa38d4..fd607945 100644 --- a/swad_test_import.c +++ b/swad_test_import.c @@ -426,7 +426,9 @@ void TsI_ImportQstsFromXML (void) if (WrongType) { - sprintf (Gbl.Alert.Txt,Txt_The_file_is_not_X,"xml"); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_file_is_not_X, + "xml"); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } else diff --git a/swad_user.c b/swad_user.c index fd662495..5f413605 100644 --- a/swad_user.c +++ b/swad_user.c @@ -2473,12 +2473,14 @@ void Usr_WelcomeUsr (void) Gbl.Prefs.PathIconSet,Cfg_ICON_128x128, Txt_Happy_birthday, Txt_Happy_birthday); - sprintf (Gbl.Alert.Txt,Txt_Welcome_X_and_happy_birthday[Gbl.Usrs.Me.UsrDat.Sex], - Gbl.Usrs.Me.UsrDat.FirstName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Welcome_X_and_happy_birthday[Gbl.Usrs.Me.UsrDat.Sex], + Gbl.Usrs.Me.UsrDat.FirstName); } if (!CongratulateMyBirthday) - sprintf (Gbl.Alert.Txt,Txt_Welcome_X[Gbl.Usrs.Me.UsrDat.Sex], - Gbl.Usrs.Me.UsrDat.FirstName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_Welcome_X[Gbl.Usrs.Me.UsrDat.Sex], + Gbl.Usrs.Me.UsrDat.FirstName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); } else @@ -2749,8 +2751,9 @@ unsigned Usr_GetParamOtherUsrIDNickOrEMailAndGetUsrCods (struct ListUsrCods *Lis if (Wrong) { /***** String is not a valid user's nickname, email or ID *****/ - sprintf (Gbl.Alert.Txt,Txt_The_ID_nickname_or_email_X_is_not_valid, - Gbl.Usrs.Other.UsrDat.UsrIDNickOrEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_ID_nickname_or_email_X_is_not_valid, + Gbl.Usrs.Other.UsrDat.UsrIDNickOrEmail); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } @@ -3182,8 +3185,9 @@ static void Usr_ShowAlertThereAreMoreThanOneUsr (void) Gbl.Action.Act = ActFrmLogIn; Tab_SetCurrentTab (); - sprintf (Gbl.Alert.Txt,Txt_There_are_more_than_one_user_with_the_ID_X_Please_type_a_nick_or_email, - Gbl.Usrs.Me.UsrIdLogin); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_are_more_than_one_user_with_the_ID_X_Please_type_a_nick_or_email, + Gbl.Usrs.Me.UsrIdLogin); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } @@ -3277,9 +3281,10 @@ void Usr_ShowFormsLogoutAndRole (void) /***** Write message with my new logged role *****/ if (Gbl.Usrs.Me.Role.HasChanged) { - sprintf (Gbl.Alert.Txt,Txt_You_are_now_LOGGED_IN_as_X, - Txt_logged[Gbl.Usrs.Me.UsrDat.Sex], - Txt_ROLES_SINGUL_abc[Gbl.Usrs.Me.Role.Logged][Gbl.Usrs.Me.UsrDat.Sex]); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_You_are_now_LOGGED_IN_as_X, + Txt_logged[Gbl.Usrs.Me.UsrDat.Sex], + Txt_ROLES_SINGUL_abc[Gbl.Usrs.Me.Role.Logged][Gbl.Usrs.Me.UsrDat.Sex]); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } @@ -5130,8 +5135,9 @@ static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scop { if (Gbl.Usrs.LstUsrs[Role].NumUsrs > Cfg_MAX_USRS_IN_LIST) { - sprintf (Gbl.Alert.Txt,Txt_The_list_of_X_users_is_too_large_to_be_displayed, - Gbl.Usrs.LstUsrs[Role].NumUsrs); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_list_of_X_users_is_too_large_to_be_displayed, + Gbl.Usrs.LstUsrs[Role].NumUsrs); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); Abort = true; } @@ -5319,7 +5325,9 @@ static void Usr_AllocateUsrsList (Rol_Role_t Role) /* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM) { - sprintf (Gbl.Alert.Txt,"Memory used by list = %lu",(long) sizeof (struct UsrInList) * NumUsrs); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "Memory used by list = %lu", + (long) sizeof (struct UsrInList) * NumUsrs); Lay_ShowAlert (Lay_INFO,Gbl.Alert.Txt); } */ @@ -5380,8 +5388,9 @@ static void Usr_PutButtonToConfirmIWantToSeeBigList (unsigned NumUsrs,const char extern const char *Txt_Show_anyway; /***** Show alert and button to confirm that I want to see the big list *****/ - sprintf (Gbl.Alert.Txt,Txt_The_list_of_X_users_is_too_large_to_be_displayed, - NumUsrs); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_list_of_X_users_is_too_large_to_be_displayed, + NumUsrs); Ale_ShowAlertAndButton (Ale_WARNING,Gbl.Alert.Txt, Gbl.Action.Act,Usr_USER_LIST_SECTION_ID,OnSubmit, Usr_PutParamsConfirmIWantToSeeBigList, @@ -5525,8 +5534,9 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs) { if (WriteErrorMsgs) { - sprintf (Gbl.Alert.Txt,Txt_There_is_no_user_with_nickname_X, - UsrIDNickOrEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_is_no_user_with_nickname_X, + UsrIDNickOrEmail); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } Error = true; @@ -5544,8 +5554,9 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs) { if (WriteErrorMsgs) { - sprintf (Gbl.Alert.Txt,Txt_There_is_no_user_with_email_X, - UsrIDNickOrEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_is_no_user_with_email_X, + UsrIDNickOrEmail); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } Error = true; @@ -5572,8 +5583,9 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs) {// TODO: Consider forbid IDs here if (WriteErrorMsgs) { - sprintf (Gbl.Alert.Txt,Txt_There_are_more_than_one_user_with_the_ID_X_Please_type_a_nick_or_email, - UsrIDNickOrEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_are_more_than_one_user_with_the_ID_X_Please_type_a_nick_or_email, + UsrIDNickOrEmail); Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt); } Error = true; @@ -5583,8 +5595,9 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs) { if (WriteErrorMsgs) { - sprintf (Gbl.Alert.Txt,Txt_There_is_no_user_with_ID_nick_or_email_X, - UsrIDNickOrEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_There_is_no_user_with_ID_nick_or_email_X, + UsrIDNickOrEmail); Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt); } Error = true; @@ -5594,8 +5607,9 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs) { if (WriteErrorMsgs) { - sprintf (Gbl.Alert.Txt,Txt_The_ID_nickname_or_email_X_is_not_valid, - UsrIDNickOrEmail); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + Txt_The_ID_nickname_or_email_X_is_not_valid, + UsrIDNickOrEmail); Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); } Error = true; diff --git a/swad_xml.c b/swad_xml.c index b2fc2ca8..e819d6af 100644 --- a/swad_xml.c +++ b/swad_xml.c @@ -151,12 +151,16 @@ static void XML_GetElement (struct XMLElement *ParentElem) EndTagNameLength = strcspn (Gbl.XMLPtr,">"); if (ParentElem->TagNameLength != EndTagNameLength) { - sprintf (Gbl.Alert.Txt,"XML syntax error. Expect end tag </%s>.",ParentElem->TagName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "XML syntax error. Expect end tag </%s>.", + ParentElem->TagName); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } if (strncmp (ParentElem->TagName,Gbl.XMLPtr,EndTagNameLength)) // XML tags are case sensitive { - sprintf (Gbl.Alert.Txt,"XML syntax error. Expect end tag </%s>.",ParentElem->TagName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "XML syntax error. Expect end tag </%s>.", + ParentElem->TagName); Lay_ShowErrorAndExit (Gbl.Alert.Txt); } @@ -360,8 +364,9 @@ static void XML_GetAttributes (struct XMLElement *Elem) } else { - sprintf (Gbl.Alert.Txt,"XML syntax error after attribute "%s" inside element "%s".", - Attribute->AttributeName,Elem->TagName); + snprintf (Gbl.Alert.Txt,Ale_MAX_BYTES_ALERT, + "XML syntax error after attribute "%s" inside element "%s".", + Attribute->AttributeName,Elem->TagName); Lay_ShowErrorAndExit (Gbl.Alert.Txt); }