Changeset 76 for trunk/src/trustfile.c


Ignore:
Timestamp:
Dec 19, 2006, 10:01:59 PM (18 years ago)
Author:
rainer
Message:

Fix for ticket #38 (csv escaping) and #39 (building on cygwin). Also optimize a bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/trustfile.c

    r1 r76  
    687687      if (retry_lstat(FIL__, __LINE__, fexp, &stbuf) < 0)
    688688        {
    689           (void) strcpy(tf_path, fexp);                  /* known to fit  */
     689          (void) strncpy(tf_path, fexp, sizeof(tf_path));
     690          tf_path[sizeof(tf_path)-1] = '\0';
    690691#ifdef TRUST_MAIN
    691692          fprintf(stderr, "---------------------------------------------\n");
    692               fprintf(stderr, "trustfile: ESTAT: stat(%s) failed, maybe the file does not exist\n",
    693                       fexp);
     693          fprintf(stderr, "trustfile: ESTAT: stat(%s) failed,\n", fexp);
     694          fprintf(stderr, "maybe the file does not exist\n");
    694695          fprintf(stderr, "---------------------------------------------\n");
    695696#endif
     
    781782                  /* yes -- error
    782783                   */
    783                   (void) strcpy(tf_path, fexp);          /* known to fit  */
     784                  (void) strncpy(tf_path, fexp, sizeof(tf_path));
     785                  tf_path[sizeof(tf_path)-1] = '\0';
    784786#ifdef TRUST_MAIN
    785787                  fprintf(stderr, "---------------------------------------------\n");
     
    850852          fprintf(stderr, "---------------------------------------------\n");
    851853#endif
    852           (void) strcpy(tf_path, fexp);                  /* known to fit  */
     854          (void) strncpy(tf_path, fexp, sizeof(tf_path));
     855          tf_path[sizeof(tf_path)-1] = '\0';
     856
    853857          tf_baduid = (uid_t) stbuf.st_uid;
    854858          SL_IRETURN(SL_EBADUID, _("sl_trustfile"));
     
    887891          fprintf(stderr, "---------------------------------------------\n");
    888892#endif
    889           (void) strcpy(tf_path, fexp);                  /* known to fit  */
     893          (void) strncpy(tf_path, fexp, sizeof(tf_path));
     894          tf_path[sizeof(tf_path)-1] = '\0';
     895
    890896          tf_badgid = (gid_t) stbuf.st_gid;
    891897          SL_IRETURN(SL_EBADGID, _("sl_trustfile"));
     
    909915          fprintf(stderr, "---------------------------------------------\n");
    910916#endif
    911           (void) strcpy(tf_path, fexp);                  /* known to fit  */
     917          (void) strncpy(tf_path, fexp, sizeof(tf_path));
     918          tf_path[sizeof(tf_path)-1] = '\0';
     919
    912920          SL_IRETURN(SL_EBADOTH, _("sl_trustfile"));
    913921        }
     
    932940   * yes, it can be trusted
    933941   */
    934   (void) strcpy(tf_path, fexp);                      /* known to fit  */
     942  (void) strncpy(tf_path, fexp, sizeof(tf_path));
     943  tf_path[sizeof(tf_path)-1] = '\0';
     944
    935945  SL_IRETURN(SL_ENONE, _("sl_trustfile"));
    936946}
Note: See TracChangeset for help on using the changeset viewer.