Changeset 4083c49


Ignore:
Timestamp:
Aug 22, 2009, 12:49:20 AM (15 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
303a9e1
Parents:
f4d4a00
git-author:
Anders Kaseorg <andersk@mit.edu> (08/22/09 00:18:32)
git-committer:
Anders Kaseorg <andersk@mit.edu> (08/22/09 00:49:20)
Message:
Fix unchecked accesses to s[strlen(s) - 1].

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rf4d4a00 r4083c49  
    19281928        myargv++;
    19291929      }
    1930       newbuff[strlen(newbuff)-1]='\0'; /* remove last space */
     1930      if (strlen(newbuff) >= 1)
     1931        newbuff[strlen(newbuff) - 1] = '\0'; /* remove last space */
    19311932
    19321933      recip=owl_malloc(strlen(argv[0])+5);
  • functions.c

    r27f6487 r4083c49  
    33493349  }
    33503350  while (fgets(buff, LINE, file)!=NULL) {
    3351     if (buff[0] == '#') continue;
    3352     buff[strlen(buff)-1]='\0';
     3351    if (buff[0] == '\0' || buff[0] == '#') continue;
     3352    if (buff[strlen(buff) - 1] == '\n')
     3353      buff[strlen(buff) - 1] = '\0';
    33533354    owl_function_command(buff);
    33543355  }
  • util.c

    re30ed92 r4083c49  
    595595    /* strip the newline */
    596596    newline=0;
    597     if (buff[strlen(buff)-1]=='\n') {
     597    if (buff[0] != '\0' && buff[strlen(buff) - 1] == '\n') {
    598598      buff[strlen(buff)-1]='\0';
    599599      newline=1;
  • viewwin.c

    r075ba92 r4083c49  
    1212  if (text) {
    1313    owl_fmtext_append_normal(&(v->fmtext), text);
    14     if (text[strlen(text)-1]!='\n' && text[0]!='\0') {
     14    if (text[0] != '\0' && text[strlen(text) - 1] != '\n') {
    1515      owl_fmtext_append_normal(&(v->fmtext), "\n");
    1616    }
  • zephyr.c

    r27f6487 r4083c49  
    378378  if (file) {
    379379    while ( fgets(buffer, 1024, file)!=NULL ) {
    380       if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue;
     380      if (buffer[0] == '\0' || buffer[0] == '#' || buffer[0] == '\n') continue;
    381381     
    382382      if (count == numSubs) {
     
    385385      }
    386386
    387       buffer[strlen(buffer)-1]='\0';
     387      if (buffer[strlen(buffer) - 1] == '\n')
     388        buffer[strlen(buffer) - 1] = '\0';
    388389      subs[count].zsub_class=owl_strdup("login");
    389390      subs[count].zsub_recipient=owl_strdup("*");
  • zwrite.c

    r4db2355 r4083c49  
    188188        }
    189189        pclose(file);
    190         if (z->zsig[strlen(z->zsig)-1]=='\n') {
     190        if (z->zsig[0] != '\0' && z->zsig[strlen(z->zsig) - 1] == '\n') {
    191191          z->zsig[strlen(z->zsig)-1]='\0';
    192192        }
Note: See TracChangeset for help on using the changeset viewer.