]> code.citadel.org Git - citadel.git/blobdiff - citadel/support.c
more sprintf bashing
[citadel.git] / citadel / support.c
index 3262890b2cabec271475df30acbd6b45a5c5b1e5..1e176ad959ce8b0c5904f14c2dedc4d6d2bb94ba 100644 (file)
@@ -104,14 +104,15 @@ int pattern2(char *search, char *patn)
 /*
  * mesg_locate()  -  locate a message or help file, case insensitive
  */
-void mesg_locate(char *targ, char *searchfor, int numdirs, char **dirs)
+void mesg_locate(char *targ, size_t n, const char *searchfor,
+                int numdirs, const char * const *dirs)
 {
        int a;
        char buf[SIZ];
        FILE *ls;
 
        for (a=0; a<numdirs; ++a) {
-               sprintf(buf,"cd %s; exec ls",dirs[a]);
+               snprintf(buf, sizeof buf, "cd %s; exec ls",dirs[a]);
                ls = (FILE *) popen(buf,"r");
                if (ls != NULL) {
                        while(fgets(buf,sizeof buf,ls)!=NULL) {
@@ -119,7 +120,7 @@ void mesg_locate(char *targ, char *searchfor, int numdirs, char **dirs)
                                        buf[strlen(buf)-1] = 0;
                                if (!strcasecmp(buf,searchfor)) {
                                        pclose(ls);
-                                       sprintf(targ,"%s/%s",dirs[a],buf);
+                                       snprintf(targ,n,"%s/%s",dirs[a],buf);
                                        return;
                                        }
                                }
@@ -138,7 +139,7 @@ char *strerror(int e)
 {
        static char buf[32];
 
-       sprintf(buf,"errno = %d",e);
+       snprintf(buf,sizeof buf,"errno = %d",e);
        return(buf);
        }
 #endif