Commit 622cbc53 authored by Andrew Price's avatar Andrew Price
Browse files

Fix up new -Wformat-truncate and -Wrestrict errors

New gcc features finding new issues break the build.
parent a5d3430d
Loading
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -622,7 +622,6 @@ static void users_lastread(int folnum)

void edit_folder(const char *args, const char *name)
{
	char fullpath[256];
	int folnum;
	int afile;
	struct folder fold;
@@ -636,6 +635,9 @@ void edit_folder(const char *args, const char *name)
	if (!get_folder_number(&fold,folnum)) return;
	if (stringcmp(args,"status",2))
	{
		char log[256];
		int n = 0;

		show_fold_stats(fold.status,tmp,true);
		printf(_("Folder %s\nCurrent status:-\n"),fold.name);
		printf(_("User not in group [%s]\n"),tmp);
@@ -647,7 +649,7 @@ void edit_folder(const char *args, const char *name)
		if (*tmp)
		{
			fold.status=folder_stats(tmp,fold.status);
			snprintf(fullpath, 255, "FOLDER(STATUS) of %s by %s", fold.name, tmp);
			n = snprintf(log, 255, "FOLDER(STATUS) of %s by %s", fold.name, tmp);
			show_fold_stats(fold.status,tmp,true);
			printf(_("Status changed to [%s]\n"),tmp);
			if(!f_active(fold.status))
@@ -658,13 +660,14 @@ void edit_folder(const char *args, const char *name)
		if (*tmp)
		{
			fold.g_status=folder_stats(tmp,fold.g_status);
			snprintf(fullpath, 255, "%s %s", fullpath, tmp);
			snprintf(log + n, 255 - n, " %s", tmp);
			show_fold_stats(fold.g_status,tmp,true);
			printf(_("Status changed to [%s]\n"),tmp);
			if(!f_active(fold.g_status))
				printf(_("WARNING: folder may get written over by the next folder created.\n"));
		}
		mwlog("%s", fullpath);
		log[255] = '\0';
		mwlog("%s", log);
	}else
	if (stringcmp(args,"groups",2))
	{
+14 −14
Original line number Diff line number Diff line
@@ -1852,20 +1852,20 @@ void broadcast_onoffcode(int ocode, int method, const char *sourceuser, const ch
{
	char logofftext[MAXTEXTLENGTH];
	extern int talker_logontype;
	const char *usr;

	/* create the broadcast string */
	snprintf(logofftext, MAXTEXTLENGTH-1, "%d,%d,%d,%s", ocode, method,
	         talker_logontype & LOGONMASK_QUIET,
	         (sourceuser)?(sourceuser):(user->record.name));
	if (sourceuser == NULL)
		usr = user->record.name;
	else
		usr = sourceuser;

	/* add an optional reason */
	if (reason != NULL)
	{
		char	reasontext[MAXTEXTLENGTH];
		snprintf(reasontext, MAXTEXTLENGTH - 1, "%s,%s", logofftext, reason);
		snprintf(logofftext, MAXTEXTLENGTH - 1, "%s", reasontext);
	}
	if (reason == NULL)
		snprintf(logofftext, MAXTEXTLENGTH-1, "%d,%d,%d,%s", ocode, method,
		         talker_logontype & LOGONMASK_QUIET, usr);
	else
		snprintf(logofftext, MAXTEXTLENGTH-1, "%d,%d,%d,%s,%s", ocode, method,
		         talker_logontype & LOGONMASK_QUIET, usr, reason);

	/* send the message */
	logofftext[MAXTEXTLENGTH-1] = '\0';
	ipc_send_to_all(IPC_CHECKONOFF, logofftext);
}
+21 −23
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <util.h>
#include "talker_privs.h"
@@ -50,12 +52,12 @@ void postinfo(struct user *who, struct folder *fol, struct Header *mesg)
void broadcast(int state, const char *fmt, ...)
{
	char buff[MAXTEXTLENGTH];
	char text[MAXTEXTLENGTH];
	char text[MAXTEXTLENGTH - 14];
	va_list va;
	int israw;

	va_start(va, fmt);
	vsnprintf(text, MAXTEXTLENGTH-1, fmt, va);
	vsnprintf(text, MAXTEXTLENGTH - 15, fmt, va);
	va_end(va);

	israw = (state & 0x100) != 0;
@@ -103,32 +105,28 @@ void broadcast(int state, const char *fmt, ...)

void mwlog(const char *fmt, ...)
{
	char detail[LOGLINESIZE];
	mode_t mask;
	va_list ap;
	int file;
	char outmsg[LOGLINESIZE];
	char addstr[LOGLINESIZE];
	char new[LOGLINESIZE];
	time_t t;

	va_start(ap, fmt);

	if ((file=open(LOGFILE,O_WRONLY|O_CREAT|O_APPEND,0600))<0)
	{
		perror("log");
	char *ts;
	FILE *fp;

	mask = umask(077);
	fp = fopen(LOGFILE, "a");
	umask(mask);
	if (fp == NULL) {
		perror(LOGFILE);
		return;
	}
	t=time(0);

	vsnprintf(addstr, LOGLINESIZE-1, fmt, ap);
	snprintf(outmsg, LOGLINESIZE-1, "%s", asctime(gmtime(&t)));
	outmsg[strlen(outmsg)-1] = ' ';

	snprintf(new, LOGLINESIZE-2, "%s| %*s | %s", outmsg, NAMESIZE, user->record.name, addstr);
	strcat(new, "\n");

	write(file,new,strlen(new));
	close(file);

	ts = asctime(gmtime(&t));
	if (ts != NULL && *ts != '\0')
		ts[strlen(ts) - 1] = '\0';
	va_start(ap, fmt);
	vsnprintf(detail, LOGLINESIZE-1, fmt, ap);
	va_end(ap);
	fprintf(fp, "%s | %*s | %s\n", ts, NAMESIZE, user->record.name, detail);
	fclose(fp);
}
+12 −14
Original line number Diff line number Diff line
@@ -1030,22 +1030,20 @@ void c_quit(CommandList *cm, int argc, const char **argv, char *args)

void c_save(CommandList *cm, int argc, const char **argv, char *args)
{
#define SAVEDIR "/tmp"
#define SAVEFILESIZE (128 + sizeof(SAVEDIR))
	int msg=atoi(argv[1]);
	char buff[128],file[128];
	char file[SAVEFILESIZE];
	char *c;
	FILE *f;
	int x;

	int i,len,x;
	snprintf(file, SAVEFILESIZE - 1, SAVEDIR "/%s", argv[2]);
	file[SAVEFILESIZE - 1] = '\0';

	len=strlen(argv[2]);
	for(i=0;i<len;i++)
	{
		if (argv[2][i]=='/') file[i]='_';
		else
			file[i]=argv[2][i];
	}
	file[len]=0;

	sprintf(buff,"/tmp/%s",file);
	for(c = file + sizeof(SAVEDIR); *c != '\0'; c++)
		if (*c == '/')
			*c = '_';

	x=fork();
	if (x==-1)
@@ -1056,7 +1054,7 @@ void c_save(CommandList *cm, int argc, const char **argv, char *args)
	{
		/* we are child */
		if (perms_drop()==-1) {perror("setuid");exit(0);}
		if ((f=fopen(buff,"a"))==NULL)
		if ((f = fopen(file, "a")) == NULL)
		{
			perror(file);
			exit(0);
@@ -1066,7 +1064,7 @@ void c_save(CommandList *cm, int argc, const char **argv, char *args)
		perms_restore();
		read_msg(currentfolder, msg, user);
		fclose(output);
		printf("Mesg no %d saved to %s\n",msg,buff);
		printf("Message %d saved to %s\n", msg, file);
		output=stdout;
		exit(0);
	}else
+5 −3
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ void display_article(struct Header *tmp, int datafile)
	char title[80];
	time_t when;

	buff=(char *)malloc(tmp->size);
	buff = calloc(1, tmp->size + 1);

	if (!remote)
	{
@@ -115,8 +115,10 @@ int read_msg(int folnum, int msgnum, struct user *user)

	close(file);

	if (!(data.status&1))
		{printf("That folder does not exist.\n");return(false);}
	if (!(f_active(data.status))) {
		printf("Folder %d does not exist.\n", folnum);
		return false;
	}
	if (msgnum>data.last || msgnum<data.first)
		{printf("There is no message %d.\n",msgnum);return(false);}
	if (data.last<data.first || data.last==0)
Loading